Received: from list by lists.gnu.org with archive (Exim 4.71) id 1S1PU6-0001aW-KP for mharc-grub-devel@gnu.org; Sat, 25 Feb 2012 16:48:54 -0500 Received: from eggs.gnu.org ([208.118.235.92]:48088) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S1PTx-0001Zf-Aa for grub-devel@gnu.org; Sat, 25 Feb 2012 16:48:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S1PTq-0006YH-9e for grub-devel@gnu.org; Sat, 25 Feb 2012 16:48:45 -0500 Received: from che.mayfirst.org ([209.234.253.108]:35282) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S1PTq-0006YC-5C for grub-devel@gnu.org; Sat, 25 Feb 2012 16:48:38 -0500 Received: from pip.fifthhorseman.net (lair.fifthhorseman.net [108.58.6.98]) by che.mayfirst.org (Postfix) with ESMTPSA id F1B4DF970; Sat, 25 Feb 2012 16:48:34 -0500 (EST) Received: by pip.fifthhorseman.net (Postfix, from userid 1000) id BABE31188A; Sat, 25 Feb 2012 16:49:02 -0500 (EST) From: Daniel Kahn Gillmor To: Vladimir =?utf-8?Q?'=CF=86-coder=2Fphcoder'?= Serbinenko , grub-devel@gnu.org Subject: Re: grub RAID heuristics (how can we avoid "superfluous RAID member (2 found)") In-Reply-To: <4F45D1FB.2070205@gmail.com> References: <4F29DEF7.80009@fifthhorseman.net> <4F45D1FB.2070205@gmail.com> User-Agent: Notmuch/0.11.1 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu) Date: Sat, 25 Feb 2012 16:49:00 -0500 Message-ID: <87ipiuwpmb.fsf@pip.fifthhorseman.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1) X-Received-From: 209.234.253.108 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 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, 25 Feb 2012 21:48:52 -0000 --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Thu, 23 Feb 2012 06:43:23 +0100, Vladimir '=CF=86-coder/phcoder' Serbine= nko wrote: > [dkg wrote:] > > Select the smallest known block device that can completely enclose the > > RAID member. The larger block device(s) should not be considered to be > > exporting that RAID. phcoder pointed me to the attached patch for improved heuristics for this case, which applies cleanly to the current head of bzr. Applied, it removes the spurious error messages from grub-probe, as seen here compared against debian's grub-probe 1.99-14: 0 root@trash:/home/dkg/src/grub/grub# grub-probe --target=3Ddevice / error: found two disks with the index 1 for RAID md0. error: superfluous RAID member (2 found). /dev/mapper/vg_trash0-root 0 root@trash:/home/dkg/src/grub/grub# ./grub-probe --target=3Ddevice / /dev/mapper/vg_trash0-root 0 root@trash:/home/dkg/src/grub/grub#=20 I think it's worth applying. Thanks for your work on this, phcoder! --dkg --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=grub-raid-heuristics.patch Content-Transfer-Encoding: quoted-printable =3D=3D=3D modified file 'grub-core/disk/diskfilter.c' =2D-- grub-core/disk/diskfilter.c 2012-02-12 14:25:25 +0000 +++ grub-core/disk/diskfilter.c 2012-02-24 21:06:10 +0000 @@ -974,33 +974,33 @@ struct grub_diskfilter_lv *lv; /* FIXME: Check whether the update time of the superblocks are the same. */ + if (pv->disk && grub_disk_get_size (disk) >=3D pv->part_size) + return GRUB_ERR_NONE; + pv->disk =3D grub_disk_open (disk->name); + if (!pv->disk) + return grub_errno; /* This could happen to LVM on RAID, pv->disk points to the raid device, we shouldn't change it. */ =2D if (! pv->disk) =2D { =2D pv->disk =3D grub_disk_open (disk->name); =2D if (! pv->disk) =2D return grub_errno; =2D pv->part_start =3D grub_partition_get_start (disk->partition); =2D pv->part_size =3D grub_disk_get_size (disk); + pv->start_sector -=3D pv->part_start; + pv->part_start =3D grub_partition_get_start (disk->partition); + pv->part_size =3D grub_disk_get_size (disk); =20 #ifdef GRUB_UTIL =2D { =2D grub_size_t s =3D 1; =2D grub_partition_t p; =2D for (p =3D disk->partition; p; p =3D p->parent) =2D s++; =2D pv->partmaps =3D xmalloc (s * sizeof (pv->partmaps[0])); =2D s =3D 0; =2D for (p =3D disk->partition; p; p =3D p->parent) =2D pv->partmaps[s++] =3D xstrdup (p->partmap->name); =2D pv->partmaps[s++] =3D 0; =2D } + { + grub_size_t s =3D 1; + grub_partition_t p; + for (p =3D disk->partition; p; p =3D p->parent) + s++; + pv->partmaps =3D xmalloc (s * sizeof (pv->partmaps[0])); + s =3D 0; + for (p =3D disk->partition; p; p =3D p->parent) + pv->partmaps[s++] =3D xstrdup (p->partmap->name); + pv->partmaps[s++] =3D 0; + } #endif =2D if (start_sector !=3D (grub_uint64_t)-1) =2D pv->start_sector =3D start_sector; =2D pv->start_sector +=3D pv->part_start; =2D } + if (start_sector !=3D (grub_uint64_t)-1) + pv->start_sector =3D start_sector; + pv->start_sector +=3D pv->part_start; /* Add the device to the array. */ for (lv =3D array->lvs; lv; lv =3D lv->next) if (!lv->became_readable_at && lv->fullname && is_lv_readable (lv)) =3D=3D=3D modified file 'grub-core/disk/mdraid_linux.c' =2D-- grub-core/disk/mdraid_linux.c 2012-01-29 13:28:01 +0000 +++ grub-core/disk/mdraid_linux.c 2012-02-24 21:11:29 +0000 @@ -201,6 +201,11 @@ return NULL; } =20 + /* No need for explicit check that sb.size is 0 (unspecified) since + 0 >=3D non-0 is false. */ + if (((grub_disk_addr_t) grub_le_to_cpu32 (sb.size)) * 2 >=3D size) + return NULL; + /* FIXME: Check the checksum. */ =20 level =3D grub_le_to_cpu32 (sb.level); @@ -241,7 +246,8 @@ grub_snprintf (buf, sizeof (buf), "md%d", grub_le_to_cpu32 (sb.md_minor)= ); return grub_diskfilter_make_raid (16, (char *) uuid, grub_le_to_cpu32 (sb.raid_disks), buf, =2D (sb.size) ? grub_le_to_cpu32 (sb.size) * 2=20 + (sb.size) ? ((grub_disk_addr_t) + grub_le_to_cpu32 (sb.size)) * 2 : sector, grub_le_to_cpu32 (sb.chunk_size) >> 9, grub_le_to_cpu32 (sb.layout), --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQJ8BAEBCgBmBQJPSVdNXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQwRUU1QkU5NzkyODJEODBCOUY3NTQwRjFD Q0QyRUQ5NEQyMTczOUU5AAoJEMzS7ZTSFznpKG8P/3p2/zI0/7Fqrv4kCnUPYp0/ 83hEyxXc2MlmTVUJv5HbBeEPvM32s1qlvAJq+pLADQzVzVhG1oFBIslkTwPTQ4AK uPV/bbw/7RgJ1c7pHnU2PbjRqAii/FZJFO7HewIG816+FK/xY7QKOXYWnRFTyHdd b5tuGq3hayMCQxEHBgxlBt8rUrBm4MyktRFnOAugzaRka7pK0IRXP8xCnME6PJtr 7wBRz/6pHq1oGgHTA3HuxdqvxE7pho1MUxGRZEvaiIWTit6MleQ+KyS23KCWqQcO 3UE8lAxkyUsDW2vvwFSUqgys78bovDCvAcH5ApI0gN/Nr9kD0+HKNGbojFsRqfbo ComlVO9sDdGLKXUY6/sHHc1Q7t6/ePG17YiGoBSWdUDeUKfHt1Ht44awhwQiO1N0 2eUWWO/ak99cl6fo+VgwpSmJcJOpMswDYFeQJZznsVM2mq9gyuX+GFKm2bhp8pCf dWeNP4zK5hKw9enQTl+zG3PRt3AO0r22QLCEyIaAXEXR4bO25DLXIS0MSLVGO+s/ 9nc5n9faVfcR4qFgiWdqWxuXeKRudVJpveAObLCYYxCE54kWTR2ptEAC2O8g01te qDJdRCVomeJD1yvgYTirgmKgRbjGDJaJ72uqOAs+7riHMY0H3636JJyVB+0+N3+V 8YDKhNMdrSkqS/9BzqSe =YAj+ -----END PGP SIGNATURE----- --==-=-=--