From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Od1hn-0006G9-Ie for mharc-grub-devel@gnu.org; Sun, 25 Jul 2010 09:57:27 -0400 Received: from [140.186.70.92] (port=54849 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OcbsJ-0002g8-CJ for grub-devel@gnu.org; Sat, 24 Jul 2010 06:22:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OcbsH-0003Ca-33 for grub-devel@gnu.org; Sat, 24 Jul 2010 06:22:34 -0400 Received: from mail-qy0-f169.google.com ([209.85.216.169]:53388) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OcbsH-0003CQ-07 for grub-devel@gnu.org; Sat, 24 Jul 2010 06:22:33 -0400 Received: by qyk9 with SMTP id 9so869609qyk.0 for ; Sat, 24 Jul 2010 03:22:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:content-type; bh=/ROCcOcUA/JB/ebdRyUhkTN/L3dmzbk+6iSUYfKp79U=; b=BVfJwNtS2zndyeNL7ireGO5uZzMYAitt9zhg7ZQCJB6qT4g//Aq6f5a+bMH7aQQBwC 8UTFqOHNH5CUkNeSofvBFBRj+LB7ImU4wwcY4XWHuRebesb++WB+WCv9qLwOPt+DS52i cdN9S4+Lpm8VNC1MK4hVijgkFR69EKGa1UXyw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type; b=DyCa0CqS1EwhcEQTnE0nfzsXnPMqeEKdgIHnGF84fLEtxDNmamR0IbabNmtwgFRyA+ eKrf+rnR8/M073gSC+tsqTHiDLqJV1q2CcPkOweEmQdD5yyeIIAwKqy9CFdHYZzai+1S RBBgVcGuxQm02xjPgfHHxSXYdzKfSqrgoxZ/0= Received: by 10.224.45.22 with SMTP id c22mr3682038qaf.379.1279966952318; Sat, 24 Jul 2010 03:22:32 -0700 (PDT) Received: from [192.168.21.179] (bas1-toronto05-1177663517.dsl.bell.ca [70.49.184.29]) by mx.google.com with ESMTPS id q30sm1427654qcq.36.2010.07.24.03.22.31 (version=SSLv3 cipher=RC4-MD5); Sat, 24 Jul 2010 03:22:31 -0700 (PDT) Message-ID: <4C4ABECA.2030008@gmail.com> Date: Sat, 24 Jul 2010 06:22:02 -0400 From: Doug Nazar User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.7) Gecko/20100713 Thunderbird/3.1.1 MIME-Version: 1.0 To: grub-devel@gnu.org, Colin Watson , Felix Zielcke , Peter Henn Content-Type: multipart/mixed; boundary="------------020903020105080605030109" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Mailman-Approved-At: Sun, 25 Jul 2010 09:57:23 -0400 Cc: Subject: Couple more fixes for Linux raid metadata 1.x support X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 Jul 2010 10:22:37 -0000 This is a multi-part message in MIME format. --------------020903020105080605030109 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit While doing some in-depth testing came across a few more issues. The second one really threw me for a loop. The LVM wouldn't come up because it couldn't find some of the raid arrays but when I hexdumped the raid arrays it showed the correct uuid. Applies on top of previous patch. - Ignore spare and faulty drives - Set a dynamic array->number. It's used for the disk->id and is important for the cache subsystem that it be unique. --------------020903020105080605030109 Content-Type: text/plain; name="grub-update-raid-metadata-1x-support-2.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="grub-update-raid-metadata-1x-support-2.diff" === modified file 'disk/mdraid_linux.c' --- disk/mdraid_linux.c 2010-07-23 05:25:00 +0000 +++ disk/mdraid_linux.c 2010-07-24 05:53:53 +0000 @@ -363,6 +363,19 @@ return grub_error (GRUB_ERR_OUT_OF_RANGE, "csum invalid"); } + if (grub_le_to_cpu32 (real_sb->dev_number) < + grub_le_to_cpu32 (real_sb->max_dev)) + array->index = grub_le_to_cpu16 + (real_sb->dev_roles[grub_le_to_cpu32 (real_sb->dev_number)]); + else + array->index = 0xffff; /* disk will be later not used! */ + + if (array->index == 0xffff || array->index == 0xfffe) + { + grub_free (real_sb); + return grub_error (GRUB_ERR_OUT_OF_RANGE, "spare or faulty drive"); + } + array->name = grub_strdup (real_sb->set_name); if (! array->name) { @@ -375,14 +388,11 @@ array->layout = grub_le_to_cpu32 (real_sb->layout); array->total_devs = grub_le_to_cpu32 (real_sb->raid_disks); array->disk_size = grub_le_to_cpu64 (real_sb->size); + if (!array->disk_size) + /* Level 0 doesn't seem to set sb->size */ + array->disk_size = grub_le_to_cpu64 (real_sb->data_size); array->chunk_size = grub_le_to_cpu32 (real_sb->chunksize); array->freshness = grub_le_to_cpu32(real_sb->events); - if (grub_le_to_cpu32 (real_sb->dev_number) < - grub_le_to_cpu32 (real_sb->max_dev)) - array->index = grub_le_to_cpu16 - (real_sb->dev_roles[grub_le_to_cpu32 (real_sb->dev_number)]); - else - array->index = 0xffff; /* disk will be later not used! */ array->uuid_len = 16; array->uuid = grub_malloc (16); if (!array->uuid) === modified file 'disk/raid.c' --- disk/raid.c 2010-07-23 05:25:00 +0000 +++ disk/raid.c 2010-07-24 09:57:05 +0000 @@ -555,25 +555,28 @@ grub_memset (&array->device, 0, sizeof (array->device)); grub_memset (&array->start_sector, 0, sizeof (array->start_sector)); + /* mdraid 1.x superblocks don't have a number but we need a unique id + for the cache system. Start numbering down from the top. */ if (array->name) - goto skip_duplicate_check; + array->number = -1; + /* Check whether we don't have multiple arrays with the same number. */ for (p = array_list; p != NULL; p = p->next) { - if (! p->name && p->number == array->number) + if (p->number == array->number) break; } if (p) { /* The number is already in use, so we need to find a new one. */ - int i = 0; + int i = array->name ? -2 : 0; while (1) { for (p = array_list; p != NULL; p = p->next) { - if (! p->name && p->number == i) + if (p->number == i) break; } @@ -584,10 +587,10 @@ break; } - i++; + i += array->name ? -1 : 1; } } - skip_duplicate_check: + /* mdraid 1.x superblocks have only a name stored not a number. Use it directly as GRUB device. */ if (! array->name) --------------020903020105080605030109--