From: Robert Millan <rmh@aybabtu.com>
To: grub-devel@gnu.org
Cc: Jeroen Dekkers <jeroen@vrijschrift.org>
Subject: [PATCH] sanity checks for RAID
Date: Thu, 7 Feb 2008 00:43:08 +0100 [thread overview]
Message-ID: <20080206234308.GA25944@thorin> (raw)
[-- Attachment #1: Type: text/plain, Size: 578 bytes --]
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.
--
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 /.)
[-- Attachment #2: sanity_checks.diff --]
[-- Type: text/x-diff, Size: 1431 bytes --]
diff -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/disk/raid.c ./disk/raid.c
--- ../grub2/disk/raid.c 2007-12-30 09:52:03.000000000 +0100
+++ ./disk/raid.c 2008-02-06 23:22:46.000000000 +0100
@@ -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)
next reply other threads:[~2008-02-06 23:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-06 23:43 Robert Millan [this message]
2008-02-09 10:53 ` [PATCH] sanity checks for RAID Robert Millan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080206234308.GA25944@thorin \
--to=rmh@aybabtu.com \
--cc=grub-devel@gnu.org \
--cc=jeroen@vrijschrift.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.