sanity checks for RAID
PATCH 1/1 sanity checks for RAID
A pair of sanity checks for RAID. Jeroen, I'd appreciate if you could have a quick look.
The second case I haven't run into, but the first I have (in a single-disk RAID0 I setup for testing).
I wonder if I'm fixing the symptoms of a bug rather than the bug, but I really don't see what could be wrong in our superblock read routine, plus even if there's a bug somewhere else this check makes sense to me as a general safeguard.
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call… if you are unable to speak? (as seen on /.)
disk/raid.c renamed from grub2/disk/raid.c +22 -0
@@ -493,6 +493,28 @@ grub_raid_scan_device (const char *name)/* Add the device to the array. */ array->device[sb.this_disk.number].name =grub_strdup (name); array->device[sb.this_disk.number].disk =grub_disk_open (name); + +if (array->disk_size != array->device[sb.this_disk.number]->total_sectors) + { +if (array->total_devs ==1 ) + { +grub_dprintf ("raid" ,"Array contains only one disk, but its size (0x%llx) " +"doesn't match with size indicated by superblock (0x%llx). " +"Assuming superblock is wrong.\n" , + array->device[sb.this_disk.number]->total_sectors, array->disk_size); + array->disk_size = array->device[sb.this_disk.number]->total_sectors; + } +else if (array->level ==1 ) + { +grub_dprintf ("raid" ,"Array is RAID level 1, but the size of disk %d (0x%llx) " +"doesn't match with size indicated by superblock (0x%llx). " +"Assuming superblock is wrong.\n" , + sb.this_disk.number, + array->device[sb.this_disk.number]->total_sectors, array->disk_size); + array->disk_size = array->device[sb.this_disk.number]->total_sectors; + } + } +if (! array->device[sb.this_disk.number].name || ! array->device[sb.this_disk.number].disk)
Quoted 19 lines · Robert Millan
diff -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp
../grub2/disk/raid.c./disk/raid.cdisk/raid.c renamed from grub2/disk/raid.c +12
-0@@ -493,6 +493,28 @@ grub_raid_scan_device (const char *name)/* Add the device to the array. */ array->device[sb.this_disk.number].name =grub_strdup (name); array->device[sb.this_disk.number].disk =grub_disk_open (name); + +if (array->disk_size != array->device[sb.this_disk.number]->total_sectors) + { +if (array->total_devs ==1 ) + { +grub_dprintf ("raid" ,"Array contains only one disk, but its size (0x%llx) " +"doesn't match with size indicated by superblock (0x%llx). " +"Assuming superblock is wrong.\n" , + array->device[sb.this_disk.number]->total_sectors, array->disk_size); + array->disk_size = array->device[sb.this_disk.number]->total_sectors; + } +else if (array->level ==1 )
disk/raid.c grub_raid_scan_device (const char *name) · line 517
Quoted 10 lines
disk/raid.c renamed from grub2/disk/raid.c +10
-0+ { +grub_dprintf ("raid" ,"Array is RAID level 1, but the size of disk %d (0x%llx) " +"doesn't match with size indicated by superblock (0x%llx). " +"Assuming superblock is wrong.\n" , + sb.this_disk.number, + array->device[sb.this_disk.number]->total_sectors, array->disk_size); + array->disk_size = array->device[sb.this_disk.number]->total_sectors; + } + } +
Committed.
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call… if you are unable to speak? (as seen on /.)