From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1OKFNc-0001aH-Lr for mharc-grub-devel@gnu.org; Thu, 03 Jun 2010 14:43:00 -0400 Received: from [140.186.70.92] (port=44308 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OKFLp-000823-F1 for grub-devel@gnu.org; Thu, 03 Jun 2010 14:41:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OKFLn-00078R-PX for grub-devel@gnu.org; Thu, 03 Jun 2010 14:41:09 -0400 Received: from cobija.connexer.com ([66.93.22.232]:40240) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OKFLn-000787-HW for grub-devel@gnu.org; Thu, 03 Jun 2010 14:41:07 -0400 Received: from rangda.stickybit.se (h-234-204.A189.priv.bahnhof.se [81.170.234.204]) by cobija.connexer.com (Postfix) with ESMTPA id 4D0E330001; Thu, 3 Jun 2010 14:41:05 -0400 (EDT) Received: by rangda.stickybit.se (Postfix, from userid 1000) id 8A1DC10533; Thu, 3 Jun 2010 20:41:03 +0200 (CEST) Date: Thu, 3 Jun 2010 20:41:03 +0200 From: sean finney To: 574863@bugs.debian.org Message-ID: <20100603184103.GA3108@rangda.stickybit.se> References: <20100506224911.GA3030@rangda.stickybit.se> <20100509214225.GA3504@rangda.stickybit.se> <20100602224132.GA4799@rangda.stickybit.se> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="XF85m9dhOBO43t/C" Content-Disposition: inline In-Reply-To: <20100602224132.GA4799@rangda.stickybit.se> User-Agent: Mutt/1.5.20 (2009-06-14) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1) X-Mailman-Approved-At: Thu, 03 Jun 2010 14:42:59 -0400 Cc: grub-devel@gnu.org Subject: [PATCH] Updated fix for Debian Bug#574863: boot failure with lvm2 and snapshot volumes 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: Thu, 03 Jun 2010 18:41:12 -0000 --XF85m9dhOBO43t/C Content-Type: multipart/mixed; boundary="CE+1k2dSO48ffgeK" Content-Disposition: inline --CE+1k2dSO48ffgeK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable and here is a slightly updated patch. there is no functional change in the code, i have only reformatted the whitespace etc so that the code matches with the style of the surrounding code. i have also tested this now on my primary testing system and haven't noticed any problems. sean On Thu, Jun 03, 2010 at 12:41:32AM +0200, sean finney wrote: > okay, I think the attached patch should fix the problem. >=20 > I haven't tested it thoroughly, though my system does boot. It seems > there may be a seperate issue with os-prober that results in some junk > entries being added to grub.conf if the snapshot volumes happen to be > root filesystems, but that probably needs to be taken up seperately and > the critical aspect of the bug is fixed anyway. >=20 >=20 > sean > Author: Sean Finney > Description: Fix for lvm2 parsing failures with snapshot logical volumes >=20 > This patch prevents the lvm2 parsing code from prematurely aborting > when encountering LV and segment metadata related to snapshot volumes. > Instead, the parser will now skip over these as if it never saw them, > which is probably the safest thing to do without a major injection of > lvm2 support code. >=20 > Bug-Debian: #574863 > --- disk/lvm.c 2010-04-27 15:25:12 +0000 > +++ disk/lvm.c 2010-06-02 22:12:58 +0000 > @@ -420,9 +420,11 @@ > /* And add all the lvs to the volume group. */ > while (1) > { > - int s; > + int s, skip_lv =3D 0, status_visible =3D 0; > struct grub_lvm_lv *lv; > struct grub_lvm_segment *seg; > + char *status =3D NULL, *status_end =3D NULL; > + grub_size_t status_len =3D 0; > =20 > while (grub_isspace (*p)) > p++; > @@ -431,6 +433,8 @@ > break; > =20 > lv =3D grub_malloc (sizeof (*lv)); > + skip_lv =3D 0; /*Flag to skip snapshots */ > + status_visible =3D 0; /*Flag to skip non-visible LV's */ > =20 > q =3D p; > while (*q !=3D ' ') > @@ -445,6 +449,25 @@ > =20 > lv->size =3D 0; > =20 > + /* read LV status and ignore ones not listed as "VISIBLE" */ > + p =3D grub_strstr (p, "status =3D "); > + if (p =3D=3D NULL) > + goto lvs_fail; > + status_end =3D grub_strchr(p, ']'); > + if (status_end =3D=3D NULL) > + goto lvs_fail; > + status_len =3D (status_end - p) + 1; > + status =3D grub_malloc(status_len + 1); > + if (status =3D=3D NULL) > + goto lvs_fail; > + grub_memcpy(status, p, status_len); > + status[status_len] =3D '\0'; > + if (grub_strstr(status, "VISIBLE") !=3D NULL) > + status_visible =3D 1; > + grub_free(status); > + if (!status_visible) > + goto lv_parsed; /* don't bother parsing this one */ > + > lv->segment_count =3D grub_lvm_getvalue (&p, "segment_count =3D "= ); > if (p =3D=3D NULL) > goto lvs_fail; > @@ -465,6 +488,18 @@ > seg->extent_count =3D grub_lvm_getvalue (&p, "extent_count =3D "); > if (p =3D=3D NULL) > goto lvs_segment_fail; > + > + /* Skip LV's that have snapshot segments */ > + p =3D grub_strstr (p, "type =3D "); > + if (p =3D=3D NULL) > + goto lvs_segment_fail; > + p +=3D sizeof("type =3D ") - 1; > + if (!grub_strncmp(p, "\"snapshot\"", 10)) { > + /* Found a snapshot, give up and move on */ > + skip_lv=3D1; > + break; > + } > + > seg->stripe_count =3D grub_lvm_getvalue (&p, "stripe_count =3D "); > if (p =3D=3D NULL) > goto lvs_segment_fail; > @@ -531,12 +566,19 @@ > goto fail4; > } > =20 > + lv_parsed: /* all done with parsing this LV, seek to the end */ > if (p !=3D NULL) > p =3D grub_strchr (p, '}'); > if (p =3D=3D NULL) > goto lvs_fail; > p +=3D 3; > =20 > + if (skip_lv || ! status_visible) { > + grub_free (lv->name); > + grub_free (lv); > + continue; > + } > + > lv->number =3D lv_count++; > lv->vg =3D vg; > lv->next =3D vg->lvs; >=20 --=20 --CE+1k2dSO48ffgeK Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="574863.patch.4.diff" Content-Transfer-Encoding: quoted-printable Author: Sean Finney Description: Fix for lvm2 parsing failures with snapshot logical volumes Forwarded: yes This patch prevents the lvm2 parsing code from prematurely aborting when encountering LV and segment metadata related to snapshot volumes. Instead, the parser will now skip over these as if it never saw them, which is probably the safest thing to do without a major injection of lvm2 support code. Bug-Debian: #574863 --- a/disk/lvm.c 2010-04-27 15:25:12 +0000 +++ b/disk/lvm.c 2010-06-03 16:06:33 +0000 @@ -420,9 +420,11 @@ /* And add all the lvs to the volume group. */ while (1) { - int s; + int s, skip_lv =3D 0, status_visible =3D 0; struct grub_lvm_lv *lv; struct grub_lvm_segment *seg; + char *status =3D NULL, *status_end =3D NULL; + grub_size_t status_len =3D 0; =20 while (grub_isspace (*p)) p++; @@ -431,6 +433,8 @@ break; =20 lv =3D grub_malloc (sizeof (*lv)); + skip_lv =3D 0; /*Flag to skip snapshots */ + status_visible =3D 0; /*Flag to skip non-visible LV's */ =20 q =3D p; while (*q !=3D ' ') @@ -445,6 +449,25 @@ =20 lv->size =3D 0; =20 + /* read LV status and ignore ones not listed as "VISIBLE" */ + p =3D grub_strstr (p, "status =3D "); + if (p =3D=3D NULL) + goto lvs_fail; + status_end =3D grub_strchr (p, ']'); + if (status_end =3D=3D NULL) + goto lvs_fail; + status_len =3D (status_end - p) + 1; + status =3D grub_malloc (status_len + 1); + if (status =3D=3D NULL) + goto lvs_fail; + grub_memcpy (status, p, status_len); + status[status_len] =3D '\0'; + if (grub_strstr (status, "VISIBLE") !=3D NULL) + status_visible =3D 1; + grub_free (status); + if (!status_visible) + goto lv_parsed; /* don't bother parsing this one */ + lv->segment_count =3D grub_lvm_getvalue (&p, "segment_count =3D "); if (p =3D=3D NULL) goto lvs_fail; @@ -465,6 +488,19 @@ seg->extent_count =3D grub_lvm_getvalue (&p, "extent_count =3D "); if (p =3D=3D NULL) goto lvs_segment_fail; + + /* Skip LV's that have snapshot segments */ + p =3D grub_strstr (p, "type =3D "); + if (p =3D=3D NULL) + goto lvs_segment_fail; + p +=3D sizeof ("type =3D ") - 1; + if (!grub_strncmp (p, "\"snapshot\"", 10)) + { + /* Found a snapshot, give up and move on */ + skip_lv=3D1; + break; + } + seg->stripe_count =3D grub_lvm_getvalue (&p, "stripe_count =3D "); if (p =3D=3D NULL) goto lvs_segment_fail; @@ -531,12 +567,20 @@ goto fail4; } =20 + lv_parsed: /* all done with parsing this LV, seek to the end */ if (p !=3D NULL) p =3D grub_strchr (p, '}'); if (p =3D=3D NULL) goto lvs_fail; p +=3D 3; =20 + if (skip_lv || ! status_visible) + { + grub_free (lv->name); + grub_free (lv); + continue; + } + lv->number =3D lv_count++; lv->vg =3D vg; lv->next =3D vg->lvs; --CE+1k2dSO48ffgeK-- --XF85m9dhOBO43t/C Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iD8DBQFMB/c/ynjLPm522B0RAs1uAJ9F3nbJ56mrVyEmO4vR0NcXLeny3QCdFYi+ mjM6HB9HJvk+M2Za7y1wKDw= =zXeJ -----END PGP SIGNATURE----- --XF85m9dhOBO43t/C--