Skip to contentSkip to conversation

mdadm 1.x metadata support

PATCH New Colin Watson 1 participant 1 message Jul 18, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mdadm 1.x metadata support

This patch is based on a branch from Felix, which I brought up to date, improved, and tested. The full ChangeLog.raid file from the branch follows, although I would consolidate this into a single ChangeLog entry on commit.

The branch is available here:

http://bzr.savannah.gnu.org/r/grub/people/cjwatson/raid/

With this, I can use grub-install and grub-mkconfig on a system with mdadm 1.1 metadata (Debian's current default for RAID) and the resulting system booted without problems (well, there's something wrong in the initramfs, but that isn't GRUB's problem!).

2010-07-18 Colin Watson <[email protected]>

* disk/dmraid_nvidia.c (grub_dmraid_nv_detect): Add start_sector parameter. Set its pointer target to 0.
* disk/mdraid_linux.c (grub_mdraid_detect): Add start_sector parameter. Set its pointer target to 0 for 0.9 metadata, or to the `data_offset' value from the superblock for 1.x metadata.
* disk/raid.c (grub_raid_read): Offset reads by the start sector of data on the device.
(insert_array): Record the start sector of data on the device. (grub_raid_register): Pass start_sector parameters to grub_raid_list->detect and insert_array.
* include/grub/raid.h (struct grub_raid_array): Add start_sector member.
(struct grub_raid): Add start_sector parameter to `detect'.

2010-07-18 Colin Watson <[email protected]>

* disk/raid.c (insert_array): Use md/%s to name mdadm 1.x devices, removing the homehost if present.
* kern/emu/getroot.c (get_mdadm_name) [__linux__]: New function. (grub_util_get_grub_dev): Use md/%s to name mdadm 1.x devices, removing the homehost if present. (grub_util_get_grub_dev) [__linux__]: Get the array name from mdadm if possible.
* util/i386/pc/grub-setup.c (main): Handle md/* devices.

2009-12-15 Peter Henn <[email protected]>

* disk/mdraid_linux.c (grub_mdraid_detect): Fix calculation of 1.x chunk size and disk size, which are already given as sector counts as distinct from the 0.90 units. Fetch the correct device number from the role table instead of using the table index.

2009-11-16 Felix Zielcke <[email protected]>

	* disk/mdraid_linux.c (grub_mdraid_detect): Remove a wrong call
	of free().

2009-11-16 Felix Zielcke <[email protected]>

* disk/mdraid_linux.c (grub_mdraid_detect): Fix the unsupported RAID version error with metadata 1.x.

2009-11-06 Felix Zielcke <[email protected]>

* disk/dmraid_nvidia.c (grub_dmraid_nv_detect): Set array->name to NULL.
* disk/mdraid_linux.c (grub_raid_super_1x): New structure. (WriteMostly1): New macro.
Set array->name to NULL for metadata format 0.90. Add support for metadata 1.x. Fix some comments.
* disk/raid.c (): Add support for name based RAID arrays. Fix a few comments.
* util/getroot.c (grub_util_get_grub_dev): Add support for /dev/md/name style devices.

=== modified file 'disk/dmraid_nvidia.c'

dmraid_nvidia.c +5 -1
@@ -89,7 +89,8 @@ struct grub_nv_super
 } __attribute__ ((packed));
 
 static grub_err_t
-grub_dmraid_nv_detect (grub_disk_t disk, struct grub_raid_array *array)
+grub_dmraid_nv_detect (grub_disk_t disk, struct grub_raid_array *array,
+                       grub_disk_addr_t *start_sector)
 {
   grub_disk_addr_t sector;
   struct grub_nv_super sb;
@@ -132,6 +133,7 @@ grub_dmraid_nv_detect (grub_disk_t disk,
                          "unsupported RAID level: %d", sb.array.raid_level);
     }
 
+  array->name = NULL;
   array->number = 0;
   array->total_devs = sb.array.total_volumes;
   array->chunk_size = sb.array.stripe_block_size;
@@ -144,6 +146,8 @@ grub_dmraid_nv_detect (grub_disk_t disk,
   grub_memcpy (array->uuid, (char *) &sb.array.signature,
                sizeof (sb.array.signature));
 
+  *start_sector = 0;
+
   return 0;
 }
 

=== modified file 'disk/mdraid_linux.c'

mdraid_linux.c +190 -10

248 lines not on this page · raw message

=== modified file 'disk/raid.c'

raid.c +50 -38

156 lines not on this page · raw message

=== modified file 'include/grub/raid.h'

grub/raid.h +4 -1
@@ -51,6 +51,8 @@ struct grub_raid_array
   char *name;              /* That will be "md<number>". */
   unsigned int nr_devs;    /* The number of devices we've found so far. */
   grub_disk_t device[GRUB_RAID_MAX_DEVICES];  /* Array of total_devs devices. */
+  grub_disk_addr_t start_sector[GRUB_RAID_MAX_DEVICES];
+			   /* Start of each device, in 512 byte sectors. */
   struct grub_raid_array *next;
 };
 
@@ -58,7 +60,8 @@ struct grub_raid
 {
   const char *name;
 
-  grub_err_t (*detect) (grub_disk_t disk, struct grub_raid_array *array);
+  grub_err_t (*detect) (grub_disk_t disk, struct grub_raid_array *array,
+                        grub_disk_addr_t *start_sector);
 
   struct grub_raid *next;
 };

=== modified file 'kern/emu/getroot.c'

emu/getroot.c +112 -1

137 lines not on this page · raw message

=== modified file 'util/i386/pc/grub-setup.c'

i386/pc/grub-setup.c +2 -2
@@ -812,14 +812,14 @@ main (int argc, char *argv[])
     must_embed = 1;
 
   if (root_dev[0] == 'm' && root_dev[1] == 'd'
-      && root_dev[2] >= '0' && root_dev[2] <= '9')
+      && ((root_dev[2] >= '0' && root_dev[2] <= '9') || root_dev[2] == '/'))
     {
       /* FIXME: we can avoid this on RAID1.  */
       must_embed = 1;
     }
 
   if (dest_dev[0] == 'm' && dest_dev[1] == 'd'
-      && dest_dev[2] >= '0' && dest_dev[2] <= '9')
+      && ((dest_dev[2] >= '0' && dest_dev[2] <= '9') || dest_dev[2] == '/'))
     {
       char **devicelist;
       int i;
Signature · 1 line
Colin Watson                                       [[email protected]]