Skip to contentSkip to conversation

add support for dmraid devices

PATCH In review Felix Zielcke 2 participants 4 messages Jun 17, 2009 – Jul 8, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 add support for dmraid devices

Here's a patch which let grub-probe work with /dev/mapper/nvidia_ dmraid devices. The other ones that dmraid supports are for now just not anymore treated as LVM but hostdisk.c doestn't yet support them.

The find_partition_by_uuid is needed, because on my dmraid the HDIO_GETGEO ioctl returns just zeros for all fields. So there is no way to get the start of the partition which the normal find_partition needs. Currently it uses the output of blkid to get the UUID of the device and then compares it with all grub devices like search --fs-uuid does.

BSD partitions aren't currently supported, but Vladimir wants to change them so they're numbers instead of letters which would make it easier for me.

Signature · 1 line
Felix Zielcke

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

* util/getroot.c (grub_util_is_dmraid): New function. (grub_util_get_dev_abstraction): Use it to not treat dmraid devices as LVM.
* util/hostdisc.c: Include <grub/file.h>. (convert_system_partition_to_system_disk): Add support for nvidia dmraid devices. (grub_util_biosdisk_get_grub_dev): Use new nested function find_partition_by_uuid in the case that the HD_GETGEO ioctl returns 0 for the sectors counti, to get the value of dos_part.

util/getroot.c +26 -1
index b50979d..0777a67 100644
@@ -396,13 +396,38 @@ grub_guess_root_device (const char *dir)
 
   return os_dev;
 }
+int
+grub_util_is_dmraid (const char *os_dev)
+{
+  if (! strncmp (os_dev, "/dev/mapper/nvidia_", 19))
+    return 1;
+  else if (! strncmp (os_dev, "/dev/mapper/isw_", 16))
+    return 1; 12
+  else if (! strncmp (os_dev, "/dev/mapper/hpt37x_", 19))
+    return 1;
+  else if (! strncmp (os_dev, "/dev/mapper/hpt45x_", 19))
+    return 1;
+  else if (! strncmp (os_dev, "/dev/mapper/via_", 16))
+    return 1;
+  else if (! strncmp (os_dev, "/dev/mapper/lsi_", 16))
+    return 1;
+  else if (! strncmp (os_dev, "/dev/mapper/pdc_", 16))
+    return 1;
+  else if (! strncmp (os_dev, "/dev/mapper/jmicron_", 20))
+    return 1;
+  else if (! strncmp (os_dev, "/dev/mapper/asr_", 16))
+    return 1;
+  else if (! strncmp (os_dev, "/dev/mapper/sil_", 16))
+    return 1;
 
+  return 0;
+}
 int
 grub_util_get_dev_abstraction (const char *os_dev UNUSED)
 {
 #ifdef __linux__
   /* Check for LVM.  */
-  if (!strncmp (os_dev, "/dev/mapper/", 12))
+  if (!strncmp (os_dev, "/dev/mapper/", 12) && ! grub_util_is_dmraid (os_dev))
     return GRUB_DEV_ABSTRACTION_LVM;
 
   /* Check for RAID.  */
util/hostdisk.c +90 -11

136 lines not on this page · raw message

#1 lore raw
Quoted 1 line · Felix Zielcke

add support for dmraid devices

That's good. I have a system with a PDC RAID, and although I only have one drive connected, GRUB2 won't install on it. I'm looking forward to testing your patch on that hardware.

Unfortunately, your patch doesn't compile as is. That hanging "12" in grub_util_is_dmraid() is not needed. Also please avoid adding trailing whitespace. STGit warns about it. "hostdisc" should be spelled "hostdisk".

What is "cediideh"? Actually, on the system I mentioned, root is mounted on /dev/mapper/pdc_dieaihahp2. If "cediideh" is supposed to represent all weird names 8 characters long, let's use numbers "12345678".

Even after fixing the compile error, I'm getting a warning:

util/hostdisk.c: In function 'grub_util_biosdisk_get_grub_dev':
util/hostdisk.c:916: warning: 'disk' may be used uninitialized in this function
util/hostdisk.c:916: note: 'disk' was declared here

Your patch removed the code where 'disk' is initialized:
disk = grub_disk_open (name);

Yet grub_disk_close() is still there. Removing it fixes the warning, but I'd like you to recheck the patch. Apparently the 'disk' variable was used for different purposes throughout the function. While at that, it would be great to avoid variable shadowing too and keep variables in the innermost possible scope.

Finally, the test results, apparently negative:

[root@mx grub2.git]# mount
/dev/mapper/pdc_dieaihahp2 on / type ext4 (rw)
/proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620) /dev/mapper/pdc_dieaihahp1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
debugfs on /sys/kernel/debug type debugfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) [root@mx grub2.git]# grub-install /dev/mapper/pdc_dieaihah --recheck
grub-probe: error: Cannot find a GRUB drive
for /dev/mapper/pdc_dieaihahp1. Check your device.map.

Auto-detection of a filesystem module failed.
Please specify the module with the option `--modules' explicitly. [root@mx grub2.git]# cat /boot/grub/device.map
(fd0) /dev/fd0
(hd0) /dev/sda
[root@mx grub2.git]#

I think we need a list of possible dmraid names. There we could go through the list in a loop. That applies to grub_util_is_dmraid() and other places in the code.

Signature · 2 lines
Regards,
Pavel Roskin
#2 lore raw

Am Mittwoch, den 17.06.2009, 18:44 -0400 schrieb Pavel Roskin:

Quoted 11 lines · Felix Zielcke
Quoted 1 line

add support for dmraid devices

That's good. I have a system with a PDC RAID, and although I only have one drive connected, GRUB2 won't install on it. I'm looking forward to testing your patch on that hardware.

Unfortunately, your patch doesn't compile as is. That hanging "12" in grub_util_is_dmraid() is not needed. Also please avoid adding trailing whitespace. STGit warns about it. "hostdisc" should be spelled "hostdisk".

Ah right sorry. Fixed.

Quoted 4 lines

What is "cediideh"? Actually, on the system I mentioned, root is mounted on /dev/mapper/pdc_dieaihahp2. If "cediideh" is supposed to represent all weird names 8 characters long, let's use numbers "12345678".

cediideh is how my nvidia dmraid device is called. I changed it now to abcdefgh.

Quoted 7 lines

Even after fixing the compile error, I'm getting a warning:

util/hostdisk.c: In function 'grub_util_biosdisk_get_grub_dev':
util/hostdisk.c:916: warning: 'disk' may be used uninitialized in this function
util/hostdisk.c:916: note: 'disk' was declared here

Quoted 8 lines

Your patch removed the code where 'disk' is initialized:
disk = grub_disk_open (name);

Yet grub_disk_close() is still there. Removing it fixes the warning, but I'd like you to recheck the patch. Apparently the 'disk' variable was used for different purposes throughout the function. While at that, it would be great to avoid variable shadowing too and keep variables in the innermost possible scope.

I don't get any warning at all with the Debian gcc 4.3.3. Anyway I fixed it now.

Quoted 2 lines

Finally, the test results, apparently negative:

Here's a new one which adds full support for pdc devices.

Quoted 4 lines

I think we need a list of possible dmraid names. There we could go through the list in a loop. That applies to grub_util_is_dmraid() and other places in the code.

I don't think it would be that useful, because hostdisk.c grub_util_biosdisk_get_grub_dev and device_is_wholedisk just can't use this list directly.

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

* util/getroot.c (grub_util_is_dmraid): New function. (grub_util_get_dev_abstraction): Use it to not treat dmraid devices as LVM.
* util/hostdisk.c: Include <grub/file.h>. (convert_system_partition_to_system_disk): Add support for nvidia and pdc dmraid devices. (device_is_wholedisk): Add support for pdc dmraid devices. (grub_util_biosdisk_get_grub_dev): Use new nested function find_partition_by_uuid in the case that the HD_GETGEO ioctl returns 0 for the sectors count, to get the value of dos_part.

util/getroot.c +26 -1
index b50979d..a8f1bb6 100644
@@ -396,13 +396,38 @@ grub_guess_root_device (const char *dir)
 
   return os_dev;
 }
+int
+grub_util_is_dmraid (const char *os_dev)
+{
+  if (! strncmp (os_dev, "/dev/mapper/nvidia_", 19))
+    return 1;
+  else if (! strncmp (os_dev, "/dev/mapper/isw_", 16))
+    return 1;
+  else if (! strncmp (os_dev, "/dev/mapper/hpt37x_", 19))
+    return 1;
+  else if (! strncmp (os_dev, "/dev/mapper/hpt45x_", 19))
+    return 1;
+  else if (! strncmp (os_dev, "/dev/mapper/via_", 16))
+    return 1;
+  else if (! strncmp (os_dev, "/dev/mapper/lsi_", 16))
+    return 1;
+  else if (! strncmp (os_dev, "/dev/mapper/pdc_", 16))
+    return 1;
+  else if (! strncmp (os_dev, "/dev/mapper/jmicron_", 20))
+    return 1;
+  else if (! strncmp (os_dev, "/dev/mapper/asr_", 16))
+    return 1;
+  else if (! strncmp (os_dev, "/dev/mapper/sil_", 16))
+    return 1;
 
+  return 0;
+}
 int
 grub_util_get_dev_abstraction (const char *os_dev UNUSED)
 {
 #ifdef __linux__
   /* Check for LVM.  */
-  if (!strncmp (os_dev, "/dev/mapper/", 12))
+  if (!strncmp (os_dev, "/dev/mapper/", 12) && ! grub_util_is_dmraid (os_dev))
     return GRUB_DEV_ABSTRACTION_LVM;
 
   /* Check for RAID.  */
util/hostdisk.c +105 -18

165 lines not on this page · raw message

#3 lore raw

Am Sonntag, den 05.07.2009, 16:55 +0200 schrieb Felix Zielcke:

Quoted 9 lines

Here's a new one which adds full support for pdc devices.

Quoted 4 lines

I think we need a list of possible dmraid names. There we could go through the list in a loop. That applies to grub_util_is_dmraid() and other places in the code.

I don't think it would be that useful, because hostdisk.c grub_util_biosdisk_get_grub_dev and device_is_wholedisk just can't use this list directly.

Ah I should have just looked at your mail and not at dmraid's code. This one should actually work for you and it also adds support for these intel isw devices.

Signature · 1 line
Felix Zielcke

2009-07-08 Felix Zielcke <[email protected]>

* util/getroot.c (grub_util_is_dmraid): New function. (grub_util_get_dev_abstraction): Use it to not treat dmraid devices as LVM.
* util/hostdisk.c: Include <grub/file.h>. (convert_system_partition_to_system_disk): Add support for nvidia, pdc and isw dmraid devices. (device_is_wholedisk): Add support for isw dmraid devices. (grub_util_biosdisk_get_grub_dev): Use new nested function find_partition_by_uuid in the case that the HD_GETGEO ioctl returns 0 for the sectors count, to get the value of dos_part.

util/getroot.c +26 -1
index b50979d..a8f1bb6 100644
@@ -396,13 +396,38 @@ grub_guess_root_device (const char *dir)
 
   return os_dev;
 }
+int
+grub_util_is_dmraid (const char *os_dev)
+{
+  if (! strncmp (os_dev, "/dev/mapper/nvidia_", 19))
+    return 1;
+  else if (! strncmp (os_dev, "/dev/mapper/isw_", 16))
+    return 1;
+  else if (! strncmp (os_dev, "/dev/mapper/hpt37x_", 19))
+    return 1;
+  else if (! strncmp (os_dev, "/dev/mapper/hpt45x_", 19))
+    return 1;
+  else if (! strncmp (os_dev, "/dev/mapper/via_", 16))
+    return 1;
+  else if (! strncmp (os_dev, "/dev/mapper/lsi_", 16))
+    return 1;
+  else if (! strncmp (os_dev, "/dev/mapper/pdc_", 16))
+    return 1;
+  else if (! strncmp (os_dev, "/dev/mapper/jmicron_", 20))
+    return 1;
+  else if (! strncmp (os_dev, "/dev/mapper/asr_", 16))
+    return 1;
+  else if (! strncmp (os_dev, "/dev/mapper/sil_", 16))
+    return 1;
 
+  return 0;
+}
 int
 grub_util_get_dev_abstraction (const char *os_dev UNUSED)
 {
 #ifdef __linux__
   /* Check for LVM.  */
-  if (!strncmp (os_dev, "/dev/mapper/", 12))
+  if (!strncmp (os_dev, "/dev/mapper/", 12) && ! grub_util_is_dmraid (os_dev))
     return GRUB_DEV_ABSTRACTION_LVM;
 
   /* Check for RAID.  */
util/hostdisk.c +108 -18

168 lines not on this page · raw message