Fallback to scanning OF tree if no devaliases
Lennart, try giving this patch a whirl. In the case after we scan the
aliases list and we haven't found any block devices it will now try to scan the entire tree. It kinda worked under OpenBios although I ran into another bug where it can't open a device path that it gave me for the pci ide controller. It found the other 2 drives fine.
I think this maintains the correct balance of using short pretty names if available but working if they are not available.
There is a case where it will mess up however. If you only specify an alias for one device but need another device to build a raid or lvm it will fail. Although, thinking about it, this already would happen.
As always, you can specify the either path manually.
Doug
=== modified file 'disk/ieee1275/ofdisk.c'
ieee1275/ofdisk.c +14 -2
@@ -76,6 +76,9 @@ grub_ofdisk_iterate (int (*hook) (const char *name)) { autoint dev_iterate (struct grub_ieee1275_devalias *alias); +int disks_found =0 ; +int use_path =0 ; +int result;int dev_iterate (struct grub_ieee1275_devalias *alias) {
@@ -110,11 +113,20 @@if (!grub_strcmp (alias->type,"block" ) &&grub_strncmp (alias->name,"cdrom" ,5 )) - ret =hook (alias->name); + { + disks_found++; + ret =hook (use_path ? alias->path : alias->name); + }return ret; } -return grub_devalias_iterate (dev_iterate); + result =grub_devalias_iterate (dev_iterate); +if (!disks_found) + { + use_path =1 ; + result =grub_ieee1275_devices_iterate (dev_iterate); + } +return result; } static char *
Quoted 45 lines · Doug Nazar
Lennart, try giving this patch a whirl. In the case after we scan the
aliases list and we haven't found any block devices it will now try to scan the entire tree. It kinda worked under OpenBios although I ran into another bug where it can't open a device path that it gave me for the pci ide controller. It found the other 2 drives fine.I think this maintains the correct balance of using short pretty names if available but working if they are not available.
There is a case where it will mess up however. If you only specify an alias for one device but need another device to build a raid or lvm it will fail. Although, thinking about it, this already would happen.
As always, you can specify the either path manually.
Doug
=== modified file '
disk/ieee1275/ofdisk.c'ieee1275/ofdisk.c +7
-2@@ -76,6 +76,9 @@ grub_ofdisk_iterate (int (*hook) (const char *name)) { autoint dev_iterate (struct grub_ieee1275_devalias *alias); +int disks_found =0 ; +int use_path =0 ; +int result;int dev_iterate (struct grub_ieee1275_devalias *alias) {@@ -110,11 +113,20 @@if (!grub_strcmp (alias->type,"block" ) &&grub_strncmp (alias->name,"cdrom" ,5 )) - ret =hook (alias->name); + { + disks_found++; + ret =hook (use_path ? alias->path : alias->name); + }return ret; } -return grub_devalias_iterate (dev_iterate);
ieee1275/ofdisk.c line 132
Quoted 10 lines
ieee1275/ofdisk.c +7
-0+ result =grub_devalias_iterate (dev_iterate); +if (!disks_found) + { + use_path =1 ; + result =grub_ieee1275_devices_iterate (dev_iterate); + } +return result; } static char *
I removed the nvalias's and got:
0 > boot /pci@800000020000200/pci1014,02BD@1/sas/disk@20000 | Elapsed time since release of system processors: 7 mins 55 secs Welcome to GRUB!
Detected bad memory access to address: 727461736261739d Package path = /packages/gscsi/disk
Loc-code =
Return Stack Trace
------------------
@ - c3e530
find-method - c48b9c
(poplocals) - c3c9e8
$call-method - c48c54
(poplocals) - c3c9e8
$CALL-R/W-DEV - d54a70
(EXEC) - d54d24
EXECUTE-COMMAND - d54db4
RETRY-COMMAND - d55ca4
INQUIRY - d55fd0
SCSI-DEVICE-TYPE - d5672c
catch - c3aff0
$call-method - c48c78
(poplocals) - c3c9e8
$call-parent - c48e98
SCSI-DEVICE-TYPE - d56df4
OPEN - d58200
catch - c3aff0
$call-method - c48c78
(poplocals) - c3c9e8
Detected bad memory access to address: 727461736261739d Package path = /packages/gscsi/disk
Loc-code =
Return Stack Trace
------------------
@ - c3e530
find-method - c48b9c
(poplocals) - c3c9e8
$call-method - c48c54
(poplocals) - c3c9e8
$CALL-R/W-DEV - d54a70
(EXEC) - d54d24
EXECUTE-COMMAND - d54db4
RETRY-COMMAND - d55ca4
INQUIRY - d55fd0
SCSI-DEVICE-TYPE - d5672c
catch - c3aff0
$call-method - c48c78
(poplocals) - c3c9e8
$call-parent - c48e98
SCSI-DEVICE-TYPE - d56df4
OPEN - d58200
catch - c3aff0
$call-method - c48c78
(poplocals) - c3c9e8
diskOPEN: can't find hw device
diskOPEN: can't find hw device
error: no such disk.
Entering rescue mode...
grub rescue>
Any idea what went wrong?
Signature · 1 line
Len Sorensen
Quoted 4 lines · Lennart Sorensen
I removed the nvalias's and got:
0> boot /pci@800000020000200/pci1014,02BD@1/sas/disk@20000 |
I'm guessing the ',' throws everything for a loop. Grub is probably interpreting it as a partition. Interesting little quirk. Have to think about how to handle that. Escaping is probably too intrusive. I guess substitution or abandon the idea.
How common is it not to have nvalias's? Is that usual operating procedure?
Doug
Quoted 6 lines · Doug Nazar
I'm guessing the ',' throws everything for a loop. Grub is probably interpreting it as a partition. Interesting little quirk. Have to think about how to handle that. Escaping is probably too intrusive. I guess substitution or abandon the idea.
How common is it not to have nvalias's? Is that usual operating procedure?
As far as I can tell, on an IBM it is not normally done, although you can.
I am personally fine having to do it to get the box working, which it now does. Everything else currently works (well except grub-install which is currently clueless about IBM machines, but I filled a bug with details on that).
Signature · 1 line
Len Sorensen
Quoted 7 lines · David Miller
From: Doug Nazar <[email protected]>
Date: Thu, 29 Jul 2010 11:57:50 -0400Quoted 2 lines
How common is it not to have nvalias's? Is that usual operating procedure?
FWIW, I've never seen this on a sparc64 system, ever.
So the sparc does not have devaliases by default and people don't normally use them, or the sparc (like the powermac) automatically creates useful devalises?
Signature · 1 line
Len Sorensen
Quoted 4 lines · Lennart Sorensen
I removed the nvalias's and got:
0> boot /pci@800000020000200/pci1014,02BD@1/sas/disk@20000 |
Can you add this on top? Grub already has support to escape the commas. Just needed to actually do it. I can't really test it here but it didn't break anything.
I'll let you guys decide if we should actually do this or not although I'm of the philosophy of "it should just work, damn it". :-)
Doug
=== modified file 'disk/ieee1275/ofdisk.c'
ieee1275/ofdisk.c +37 -1
@@ -72,6 +72,39 @@return p; } +static char * +escape_of_path (const char *orig_path) +{ +char *new_path, *d, c; +const char *p; +int i; + +if (!grub_strchr (orig_path,',' )) +return (char *) orig_path; + + new_path =grub_malloc (grub_strlen (orig_path) +32 ); + + p = orig_path; + d = new_path; + i =0 ; +while ((c = *p++) !='\0' ) + { +if (c ==',' ) + { +if (++i ==32 ) + { +/* oops, too many commas */ +break ; + } + *d++ ='\\' ; + } + *d++ = c; + } + +return new_path; +} + +static int grub_ofdisk_iterate (int (*hook) (const char *name)) {
@@ -114,8 +147,11 @@if (!grub_strcmp (alias->type,"block" ) &&grub_strncmp (alias->name,"cdrom" ,5 )) { +char *name_path = use_path ?escape_of_path (alias->path) : alias->name; disks_found++; - ret =hook (use_path ? alias->path : alias->name); + ret =hook (name_path); +if (use_path && name_path != alias->path) +grub_free (name_path); }return ret; }
From: Doug Nazar <[email protected]>
Date: Thu, 29 Jul 2010 11:57:50 -0400
Quoted 2 lines
How common is it not to have nvalias's? Is that usual operating procedure?
FWIW, I've never seen this on a sparc64 system, ever.
From: [email protected] (Lennart Sorensen)
Date: Thu, 29 Jul 2010 12:59:08 -0400
Quoted 12 lines · David Miller
Quoted 7 lines
From: Doug Nazar <[email protected]>
Date: Thu, 29 Jul 2010 11:57:50 -0400Quoted 2 lines
How common is it not to have nvalias's? Is that usual operating procedure?
FWIW, I've never seen this on a sparc64 system, ever.
So the sparc does not have devaliases by default and people don't normally use them, or the sparc (like the powermac) automatically creates useful devalises?
Sparc64 always has useful aliases.
Quoted 4 lines · Doug Nazar
Quoted 3 lines · Lennart Sorensen
I removed the nvalias's and got:
Quoted 8 lines
Quoted 1 line
0> boot /pci@800000020000200/pci1014,02BD@1/sas/disk@20000 |
Can you add this on top? Grub already has support to escape the commas. Just needed to actually do it. I can't really test it here but it didn't break anything.
I'll let you guys decide if we should actually do this or not although I'm of the philosophy of "it should just work, damn it". :-)
I will try to test it soon, but I just put the machine into production use, so rebooting a lot won't be popular. I will try to test it in the evening. Unfortunately I am going on vacation for a week, so it probably won't be until after that.
Thanks for trying to fix it though.
Signature · 1 line
Len Sorensen
Quoted 57 lines
=== modified file '
disk/ieee1275/ofdisk.c'ieee1275/ofdisk.c +37
-1@@ -72,6 +72,39 @@return p; } +static char * +escape_of_path (const char *orig_path) +{ +char *new_path, *d, c; +const char *p; +int i; + +if (!grub_strchr (orig_path,',' )) +return (char *) orig_path; + + new_path =grub_malloc (grub_strlen (orig_path) +32 ); + + p = orig_path; + d = new_path; + i =0 ; +while ((c = *p++) !='\0' ) + { +if (c ==',' ) + { +if (++i ==32 ) + { +/* oops, too many commas */ +break ; + } + *d++ ='\\' ; + } + *d++ = c; + } + +return new_path; +} + +static int grub_ofdisk_iterate (int (*hook) (const char *name)) {@@ -114,8 +147,11 @@if (!grub_strcmp (alias->type,"block" ) &&grub_strncmp (alias->name,"cdrom" ,5 )) { +char *name_path = use_path ?escape_of_path (alias->path) : alias->name; disks_found++; - ret =hook (use_path ? alias->path : alias->name); + ret =hook (name_path); +if (use_path && name_path != alias->path) +grub_free (name_path); }return ret; }
Quoted 7 lines · Lennart Sorensen
I will try to test it soon, but I just put the machine into production use, so rebooting a lot won't be popular. I will try to test it in the evening. Unfortunately I am going on vacation for a week, so it probably won't be until after that.
Thanks for trying to fix it though.
No problem. I was having fun..... :-)
I'm gonna try hacking on OpenBios for a bit. I should be able to get an older version working and then I can fix a few annoying things and I'll be able to inject a comma into a devpath as a test. However I don't know if that's what was in fact crashing your box.
Doug
As I already told on IRC such a behaviour isn't of a good design. A simple example is when one add a devalias and then all other disks disappear. Moreover in experimental branch I have a solution for such a
problem: we scan all the devices and then show only the simpliest form. That code just needs some testing. Could you do that? I'm sorry for not having been available for last few days and this resulted in a mountain of useless work by Doug and Lennart. I assume that the rest of this thread is a discussion of this issue and is moot given the code which is already in experimental. If it's not a case please start a new thread per issue
Quoted 23 lines · Doug Nazar
Lennart, try giving this patch a whirl. In the case after we scan the
aliases list and we haven't found any block devices it will now try to scan the entire tree. It kinda worked under OpenBios although I ran into another bug where it can't open a device path that it gave me for the pci ide controller. It found the other 2 drives fine.I think this maintains the correct balance of using short pretty names if available but working if they are not available.
There is a case where it will mess up however. If you only specify an alias for one device but need another device to build a raid or lvm it will fail. Although, thinking about it, this already would happen.
As always, you can specify the either path manually.
Doug
_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 10 lines · Vladimir 'φ-coder/phcoder' Serbinenko
As I already told on IRC such a behaviour isn't of a good design. A simple example is when one add a devalias and then all other disks disappear. Moreover in experimental branch I have a solution for such a
problem: we scan all the devices and then show only the simpliest form. That code just needs some testing. Could you do that? I'm sorry for not having been available for last few days and this resulted in a mountain of useless work by Doug and Lennart. I assume that the rest of this thread is a discussion of this issue and is moot given the code which is already in experimental. If it's not a case please start a new thread per issue
Where do I find that? I would love to test it.
I currently have the machine down because someone made a mistake that killed the box (or so they thought). Nothing actually wrong with the box fortunately, but it means I can spend a few hours testing things before getting back to normal use again.
Signature · 1 line
Len Sorensen
Quoted 13 lines · Lennart Sorensen
Quoted 11 lines · Vladimir 'φ-coder/phcoder' Serbinenko
As I already told on IRC such a behaviour isn't of a good design. A simple example is when one add a devalias and then all other disks disappear. Moreover in experimental branch I have a solution for such a
problem: we scan all the devices and then show only the simpliest form. That code just needs some testing. Could you do that? I'm sorry for not having been available for last few days and this resulted in a mountain of useless work by Doug and Lennart. I assume that the rest of this thread is a discussion of this issue and is moot given the code which is already in experimental. If it's not a case please start a new thread per issue
Quoted 3 lines
Where do I find that? I would love to test it.
BZR checkout from http://bzr.savannah.gnu.org/r/grub/branches/experimental/
I'm especially interested in testing on multi-disk config (both my OFW boxes have only one disk)
Quoted 6 lines
I currently have the machine down because someone made a mistake that killed the box (or so they thought). Nothing actually wrong with the box fortunately, but it means I can spend a few hours testing things before getting back to normal use again.
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 3 lines · Vladimir 'φ-coder/phcoder' Serbinenko
BZR checkout from http://bzr.savannah.gnu.org/r/grub/branches/experimental/
I'm especially interested in testing on multi-disk config (both my OFW boxes have only one disk)
I will see if I can get that built somehow and try it (I am running dual disk for raid1).
Signature · 1 line
Len Sorensen