[PATCH] md autostart and name fixes, 2.4.0test1-ac7

From: Dave Dillow (dillow@icx.net)
Date: Sat Jun 03 2000 - 15:18:19 EST


The first patch provides partition type information, which the md driver
relies on to find RAID slices, so that it can autostart them. It also
modifies d/b/Config.in to get the right config option defined. It
supports msdos partitions, and sun disklabels. Someone else will have to
determine what should be done about the others, as those are the only
machines I have access to. Compiled and test on x86; sun compiled, but
not tested (machine is at work).

The second patch fixes md's disk names when using devfs. devfs builds
it's pathname from the end of the buffer, and returns an offset to
disk_name(), which then returns a pointer to the beginning of the
string. This resulted in a bunch of Z's in front of the name. This just
adds a pointer to the starting place.

Enjoy,
D

diff -ru linux-2.4.0test1-ac7/drivers/block/Config.in linux-2.4.0test1-ac7.il1/drivers/block/Config.in
--- linux-2.4.0test1-ac7/drivers/block/Config.in Sat Jun 3 12:51:49 2000
+++ linux-2.4.0test1-ac7.il1/drivers/block/Config.in Sat Jun 3 14:28:51 2000
@@ -54,6 +54,9 @@
     dep_tristate ' RAID-4/RAID-5 mode' CONFIG_MD_RAID5 $CONFIG_BLK_DEV_MD
   fi
 fi
+if [ "$CONFIG_MD_LINEAR" = "y" -o "$CONFIG_MD_RAID0" = "y"]; then
+ bool ' Boot support (linear, raid0)' CONFIG_AUTODETECT_RAID
+fi
 tristate 'RAM disk support' CONFIG_BLK_DEV_RAM
 dep_bool ' Initial RAM disk (initrd) support' CONFIG_BLK_DEV_INITRD $CONFIG_BLK_DEV_RAM
 
diff -ru linux-2.4.0test1-ac7/fs/partitions/acorn.c linux-2.4.0test1-ac7.il1/fs/partitions/acorn.c
--- linux-2.4.0test1-ac7/fs/partitions/acorn.c Fri Apr 14 12:37:10 2000
+++ linux-2.4.0test1-ac7.il1/fs/partitions/acorn.c Sat Jun 3 13:57:56 2000
@@ -58,7 +58,7 @@
 
         if (name)
                 printk(" [%s]", name);
- add_gd_partition(hd, minor, first_sector, nr_sects);
+ add_gd_partition(hd, minor, first_sector, nr_sects, 0);
         return dr;
 }
 
@@ -75,7 +75,7 @@
 
         printk(" [RISCiX]");
 
- add_gd_partition(hd, riscix_minor = minor++, first_sect, nr_sects);
+ add_gd_partition(hd, riscix_minor = minor++, first_sect, nr_sects, 0);
         hd->sizes[riscix_minor] = hd->part[riscix_minor].nr_sects >> (BLOCK_SIZE_BITS - 9);
         dev = MKDEV(hd->major, riscix_minor);
 
@@ -93,7 +93,7 @@
                             memcmp(rr->part[part].name, "All\0", 4)) {
                                 add_gd_partition(hd, minor++,
                                                 le32_to_cpu(rr->part[part].start),
- le32_to_cpu(rr->part[part].length));
+ le32_to_cpu(rr->part[part].length), 0);
                                 printk("(%s)", rr->part[part].name);
                         }
                 }
@@ -121,7 +121,7 @@
                 
         printk(" [Linux]");
 
- add_gd_partition(hd, linux_minor = minor++, first_sect, nr_sects);
+ add_gd_partition(hd, linux_minor = minor++, first_sect, nr_sects, 0);
         hd->sizes[linux_minor] = hd->part[linux_minor].nr_sects >> (BLOCK_SIZE_BITS - 9);
         dev = MKDEV(hd->major, linux_minor);
 
@@ -136,7 +136,7 @@
                         break;
                 add_gd_partition(hd, minor++, first_sect +
                                  le32_to_cpu(linuxp->start_sect),
- le32_to_cpu(linuxp->nr_sects));
+ le32_to_cpu(linuxp->nr_sects), 0);
                 linuxp ++;
         }
         printk(" >\n");
@@ -381,7 +381,7 @@
                 }
 
                 if (size) {
- add_gd_partition(hd, minor, first_sector + start, size);
+ add_gd_partition(hd, minor, first_sector + start, size, 0);
                         minor++;
                 }
         }
@@ -443,7 +443,7 @@
 
                 if (size)
                         add_gd_partition(hd, minor, first_sector + start,
- size);
+ size, 0);
                 minor++;
         }
 
diff -ru linux-2.4.0test1-ac7/fs/partitions/amiga.c linux-2.4.0test1-ac7.il1/fs/partitions/amiga.c
--- linux-2.4.0test1-ac7/fs/partitions/amiga.c Wed Feb 16 18:42:06 2000
+++ linux-2.4.0test1-ac7.il1/fs/partitions/amiga.c Sat Jun 3 13:50:57 2000
@@ -101,7 +101,7 @@
                                         start_sect = be32_to_cpu(pb->pb_Environment[9]) *
                                                      be32_to_cpu(pb->pb_Environment[3]) *
                                                      be32_to_cpu(pb->pb_Environment[5]);
- add_gd_partition(hd,first_part_minor,start_sect,nr_sects);
+ add_gd_partition(hd,first_part_minor,start_sect,nr_sects, 0);
                                         first_part_minor++;
                                         res = 1;
                                 }
diff -ru linux-2.4.0test1-ac7/fs/partitions/atari.c linux-2.4.0test1-ac7.il1/fs/partitions/atari.c
--- linux-2.4.0test1-ac7/fs/partitions/atari.c Sun Mar 12 22:39:39 2000
+++ linux-2.4.0test1-ac7.il1/fs/partitions/atari.c Sat Jun 3 13:53:57 2000
@@ -106,7 +106,7 @@
 
                   add_gd_partition(hd, minor,
                                    partsect + be32_to_cpu(xrs->part[0].st),
- be32_to_cpu(xrs->part[0].siz));
+ be32_to_cpu(xrs->part[0].siz), 0);
 
                   if (!(xrs->part[1].flg & 1)) {
                     /* end of linked partition list */
@@ -133,7 +133,7 @@
             {
               /* we don't care about other id's */
               add_gd_partition (hd, minor, be32_to_cpu(pi->st),
- be32_to_cpu(pi->siz));
+ be32_to_cpu(pi->siz), 0);
             }
         }
     }
@@ -161,7 +161,7 @@
         {
           part_fmt = 2;
           add_gd_partition (hd, minor, be32_to_cpu(pi->st),
- be32_to_cpu(pi->siz));
+ be32_to_cpu(pi->siz), 0);
         }
       }
       printk(" >");
diff -ru linux-2.4.0test1-ac7/fs/partitions/check.c linux-2.4.0test1-ac7.il1/fs/partitions/check.c
--- linux-2.4.0test1-ac7/fs/partitions/check.c Wed May 24 21:38:26 2000
+++ linux-2.4.0test1-ac7.il1/fs/partitions/check.c Sat Jun 3 13:20:36 2000
@@ -166,7 +166,8 @@
 /*
  * Add a partitions details to the devices partition description.
  */
-void add_gd_partition(struct gendisk *hd, int minor, int start, int size)
+void add_gd_partition(struct gendisk *hd, int minor, int start, int size,
+ int type)
 {
 #ifndef CONFIG_DEVFS_FS
         char buf[40];
@@ -174,6 +175,7 @@
 
         hd->part[minor].start_sect = start;
         hd->part[minor].nr_sects = size;
+ hd->part[minor].type = type;
 #ifdef CONFIG_DEVFS_FS
         printk(" p%d", (minor & ((1 << hd->minor_shift) - 1)));
 #else
diff -ru linux-2.4.0test1-ac7/fs/partitions/check.h linux-2.4.0test1-ac7.il1/fs/partitions/check.h
--- linux-2.4.0test1-ac7/fs/partitions/check.h Wed Feb 16 18:42:06 2000
+++ linux-2.4.0test1-ac7.il1/fs/partitions/check.h Sat Jun 3 13:20:58 2000
@@ -2,7 +2,8 @@
  * add_partition adds a partitions details to the devices partition
  * description.
  */
-void add_gd_partition(struct gendisk *hd, int minor, int start, int size);
+void add_gd_partition(struct gendisk *hd, int minor, int start, int size,
+ int type);
 
 /*
  * Get the default block size for this device
diff -ru linux-2.4.0test1-ac7/fs/partitions/ibm.c linux-2.4.0test1-ac7.il1/fs/partitions/ibm.c
--- linux-2.4.0test1-ac7/fs/partitions/ibm.c Wed Apr 12 12:47:30 2000
+++ linux-2.4.0test1-ac7.il1/fs/partitions/ibm.c Sat Jun 3 13:59:13 2000
@@ -70,7 +70,7 @@
                                   dasd_info [di]->sizes.s2b_shift,
                                   (dasd_info [di]->sizes.blocks -
                                    dasd_info [di]->sizes.label_block - 1) <<
- dasd_info [di]->sizes.s2b_shift );
+ dasd_info [di]->sizes.s2b_shift, 0);
                 break;
         case ibm_partition_vol1:
                 printk ( "(VOL1)/%6s:",name);
@@ -84,7 +84,7 @@
                                     dasd_info [di]->sizes.s2b_shift,
                                     (dasd_info [di]->sizes.blocks -
                                      dasd_info [di]->sizes.label_block) <<
- dasd_info [di]->sizes.s2b_shift );
+ dasd_info [di]->sizes.s2b_shift, 0);
                   printk ("(CMS)");
                 } else {
                   /* disk is reserved minidisk */
@@ -94,7 +94,7 @@
                     ((*(((long *)bh->b_data) + 3)) >> 9);
                   add_gd_partition( hd, MINOR(dev) + 1,
                                     offset << dasd_info [di]->sizes.s2b_shift,
- size << dasd_info [di]->sizes.s2b_shift );
+ size << dasd_info [di]->sizes.s2b_shift, 0);
                   printk ("(MDSK)");
                 }
                 break;
@@ -113,7 +113,7 @@
                                   dasd_info [di]->sizes.s2b_shift,
                                   (dasd_info [di]->sizes.blocks -
                                    dasd_info [di]->sizes.label_block - 1) <<
- dasd_info [di]->sizes.s2b_shift );
+ dasd_info [di]->sizes.s2b_shift, 0);
                 break;
         }
         printk ( "\n" );
diff -ru linux-2.4.0test1-ac7/fs/partitions/mac.c linux-2.4.0test1-ac7.il1/fs/partitions/mac.c
--- linux-2.4.0test1-ac7/fs/partitions/mac.c Wed Feb 9 22:43:53 2000
+++ linux-2.4.0test1-ac7.il1/fs/partitions/mac.c Sat Jun 3 13:51:24 2000
@@ -95,7 +95,7 @@
                 blocks_in_map = be32_to_cpu(part->map_count);
                 add_gd_partition(hd, first_part_minor,
                         fsec + be32_to_cpu(part->start_block) * (secsize/512),
- be32_to_cpu(part->block_count) * (secsize/512));
+ be32_to_cpu(part->block_count) * (secsize/512), 0);
 
 #ifdef CONFIG_PPC
                 /*
diff -ru linux-2.4.0test1-ac7/fs/partitions/msdos.c linux-2.4.0test1-ac7.il1/fs/partitions/msdos.c
--- linux-2.4.0test1-ac7/fs/partitions/msdos.c Wed May 24 11:40:41 2000
+++ linux-2.4.0test1-ac7.il1/fs/partitions/msdos.c Sat Jun 3 14:36:39 2000
@@ -131,7 +131,8 @@
 
                         add_gd_partition(hd, current_minor,
                                          this_sector+START_SECT(p)*sector_size,
- NR_SECTS(p)*sector_size);
+ NR_SECTS(p)*sector_size,
+ ptype(SYS_IND(p)));
                         current_minor++;
                         loopct = 0;
                         if ((current_minor & mask) == 0)
@@ -210,7 +211,8 @@
                  * one but add_gd_partition starts relative to sector
                  * zero of the disk. Therefore, must add the offset
                  * of the current partition */
- add_gd_partition(hd, current_minor, s->s_start+offset, s->s_size);
+ add_gd_partition(hd, current_minor, s->s_start+offset,
+ s->s_size, 0);
                 current_minor++;
         }
         brelse(bh);
@@ -256,7 +258,7 @@
         } /* if the bsd partition is not currently known to linux, we end
            * up here
            */
- add_gd_partition(hd, current_minor, bsd_p->p_offset, bsd_p->p_size);
+ add_gd_partition(hd, current_minor, bsd_p->p_offset, bsd_p->p_size, 0);
         current_minor++;
 }
 
@@ -331,7 +333,7 @@
 
                 if (p->s_label != UNIXWARE_FS_UNUSED) {
                         add_gd_partition(hd, current_minor, START_SECT(p),
- NR_SECTS(p));
+ NR_SECTS(p), 0);
                         current_minor++;
                 }
                 p++;
@@ -437,7 +439,7 @@
                 if (!NR_SECTS(p))
                         continue;
                 add_gd_partition(hd, minor, first_sector+START_SECT(p)*sector_size,
- NR_SECTS(p)*sector_size);
+ NR_SECTS(p)*sector_size, ptype(SYS_IND(p)));
                 if (is_extended_partition(p)) {
                         printk(" <");
                         /*
@@ -468,7 +470,7 @@
                                 break;
                         if (!(START_SECT(p) && NR_SECTS(p)))
                                 continue;
- add_gd_partition(hd, current_minor, START_SECT(p), NR_SECTS(p));
+ add_gd_partition(hd, current_minor, START_SECT(p), NR_SECTS(p), 0);
                 }
         }
         printk("\n");
diff -ru linux-2.4.0test1-ac7/fs/partitions/osf.c linux-2.4.0test1-ac7.il1/fs/partitions/osf.c
--- linux-2.4.0test1-ac7/fs/partitions/osf.c Wed Feb 16 18:42:06 2000
+++ linux-2.4.0test1-ac7.il1/fs/partitions/osf.c Sat Jun 3 13:44:18 2000
@@ -76,7 +76,7 @@
                 if (partition->p_size)
                         add_gd_partition(hd, current_minor,
                                 first_sector+partition->p_offset,
- partition->p_size);
+ partition->p_size, 0);
                 current_minor++;
         }
         printk("\n");
diff -ru linux-2.4.0test1-ac7/fs/partitions/sgi.c linux-2.4.0test1-ac7.il1/fs/partitions/sgi.c
--- linux-2.4.0test1-ac7/fs/partitions/sgi.c Sun Mar 12 22:39:39 2000
+++ linux-2.4.0test1-ac7.il1/fs/partitions/sgi.c Sat Jun 3 13:50:13 2000
@@ -77,7 +77,7 @@
                 start = be32_to_cpu(p->first_block);
                 if(!blocks)
                         continue;
- add_gd_partition(hd, current_minor, start, blocks);
+ add_gd_partition(hd, current_minor, start, blocks, 0);
                 current_minor++;
         }
         printk("\n");
diff -ru linux-2.4.0test1-ac7/fs/partitions/sun.c linux-2.4.0test1-ac7.il1/fs/partitions/sun.c
--- linux-2.4.0test1-ac7/fs/partitions/sun.c Wed Feb 16 18:42:06 2000
+++ linux-2.4.0test1-ac7.il1/fs/partitions/sun.c Sat Jun 3 13:47:34 2000
@@ -26,7 +26,14 @@
         struct buffer_head *bh;
         struct sun_disklabel {
                 unsigned char info[128]; /* Informative text string */
- unsigned char spare[292]; /* Boot information etc. */
+ unsigned char spare0[14];
+ struct sun_disklabelinfo {
+ unsigned char spare1;
+ unsigned char id;
+ unsigned char spare2;
+ unsigned char flags;
+ } infos[8];
+ unsigned char spare1[246]; /* Boot information etc. */
                 unsigned short rspeed; /* Disk rotational speed */
                 unsigned short pcylcount; /* Physical cylinder count */
                 unsigned short sparecyl; /* extra sects per cylinder */
@@ -79,7 +86,8 @@
                 st_sector = first_sector + be32_to_cpu(p->start_cylinder) * spc;
                 num_sectors = be32_to_cpu(p->num_sectors);
                 if (num_sectors)
- add_gd_partition(hd, first_part_minor, st_sector, num_sectors);
+ add_gd_partition(hd, first_part_minor, st_sector, num_sectors,
+ ptype(label->infos[i].id));
                 first_part_minor++;
         }
         printk("\n");
diff -ru linux-2.4.0test1-ac7/fs/partitions/ultrix.c linux-2.4.0test1-ac7.il1/fs/partitions/ultrix.c
--- linux-2.4.0test1-ac7/fs/partitions/ultrix.c Wed Feb 16 18:42:06 2000
+++ linux-2.4.0test1-ac7.il1/fs/partitions/ultrix.c Sat Jun 3 13:54:48 2000
@@ -48,7 +48,7 @@
                         if (label->pt_part[i].pi_nblocks)
                                 add_gd_partition(hd, minor,
                                               label->pt_part[i].pi_blkoff,
- label->pt_part[i].pi_nblocks);
+ label->pt_part[i].pi_nblocks, 0);
                 brelse(bh);
                 printk ("\n");
                 return 1;
diff -ru linux-2.4.0test1-ac7/include/linux/genhd.h linux-2.4.0test1-ac7.il1/include/linux/genhd.h
--- linux-2.4.0test1-ac7/include/linux/genhd.h Wed May 24 22:52:48 2000
+++ linux-2.4.0test1-ac7.il1/include/linux/genhd.h Sat Jun 3 15:28:01 2000
@@ -263,6 +263,19 @@
         return index;
 }
 
+/*
+ * partition types Linux cares about.
+ *
+ * currently there are 'normal' and RAID types.
+ */
+
+static inline unsigned int ptype (unsigned int raw_type)
+{
+ if(raw_type == LINUX_RAID_PARTITION)
+ return LINUX_RAID_PARTITION;
+ return 0;
+}
+
 #endif
 
 #endif

diff -ru linux-2.4.0test1-ac7/drivers/block/md.c linux-2.4.0test1-ac7.il1/drivers/block/md.c
--- linux-2.4.0test1-ac7/drivers/block/md.c Wed May 24 21:38:26 2000
+++ linux-2.4.0test1-ac7.il1/drivers/block/md.c Sat Jun 3 15:25:28 2000
@@ -325,13 +325,18 @@
                 return nomem;
         /*
          * ok, add this new device name to the list
+ *
+ * devfs builds the name backwards, so we really need to
+ * have ->name point where disk_name() says...
          */
         hd = find_gendisk (dev);
 
- if (!hd)
- sprintf (dname->name, "[dev %s]", kdevname(dev));
- else
- disk_name (hd, MINOR(dev), dname->name);
+ if (!hd) {
+ sprintf (dname->name_buf, "[dev %s]", kdevname(dev));
+ dname->name = dname->name_buf;
+ }
+ else
+ dname->name = disk_name (hd, MINOR(dev), dname->name_buf);
 
         dname->dev = dev;
         MD_INIT_LIST_HEAD(&dname->list);
diff -ru linux-2.4.0test1-ac7/include/linux/raid/md_k.h linux-2.4.0test1-ac7.il1/include/linux/raid/md_k.h
--- linux-2.4.0test1-ac7/include/linux/raid/md_k.h Fri May 12 14:36:30 2000
+++ linux-2.4.0test1-ac7.il1/include/linux/raid/md_k.h Sat Jun 3 15:22:46 2000
@@ -337,7 +337,8 @@
 typedef struct dev_name_s {
         struct md_list_head list;
         kdev_t dev;
- char name [MAX_DISKNAME_LEN];
+ char name_buf [MAX_DISKNAME_LEN];
+ char *name;
 } dev_name_t;
 
 

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Jun 07 2000 - 21:00:17 EST