From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1OTTPe-0003S9-Gt for mharc-grub-devel@gnu.org; Tue, 29 Jun 2010 01:31:14 -0400 Received: from [140.186.70.92] (port=60550 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OTTPa-0003RH-Kt for grub-devel@gnu.org; Tue, 29 Jun 2010 01:31:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OTTPZ-0000Za-2q for grub-devel@gnu.org; Tue, 29 Jun 2010 01:31:10 -0400 Received: from mail-bw0-f41.google.com ([209.85.214.41]:58918) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OTTPY-0000ZL-LS for grub-devel@gnu.org; Tue, 29 Jun 2010 01:31:09 -0400 Received: by bwz9 with SMTP id 9so1185257bwz.0 for ; Mon, 28 Jun 2010 22:31:07 -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:cc:subject:references:in-reply-to :x-enigmail-version:content-type; bh=rVrD4dtbEObH5cjwUF+Kw6Eu0MFrXjyENcQVH//s5sE=; b=foJOG2UXwwEfSCssRALsTsQXyrzsA2IVyKKaNkOESoZ6dxHO498OT7InPBbCjRK4ow 8sZ7JJnQwz8R89DyonCV6akiNGfOg7Sdvq5BPSXBXpkbHlgpDo73o2PpyRLU4K+WUzoq 22P1z/2lmmC+/VxZjo4kc8ZHCqG2QWLA55wKc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:x-enigmail-version:content-type; b=o1Izo0XauajX3OovV5juaNCHhHG5XVWtgUFEW64PEzzsgm1t+wKU/8TIDlh27YMgZu fTGsJu2phK8x+8BYYBsBJn+PQ+zqsqjsUuHcU5+1tRtGAFyu7MpziC58yPNOq79surSp cYBorlbZonUfqpIzUzBSTy6UEFxHN8TJR3ksU= Received: by 10.204.136.71 with SMTP id q7mr3405551bkt.111.1277789467595; Mon, 28 Jun 2010 22:31:07 -0700 (PDT) Received: from debian.bg45.phnet (214-60.203-62.cust.bluewin.ch [62.203.60.214]) by mx.google.com with ESMTPS id br11sm1153909bkb.7.2010.06.28.22.31.05 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 28 Jun 2010 22:31:06 -0700 (PDT) Message-ID: <4C298511.10304@gmail.com> Date: Tue, 29 Jun 2010 07:30:57 +0200 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100515 Icedove/3.0.4 MIME-Version: 1.0 To: The development of GNU GRUB References: <20100506224911.GA3030@rangda.stickybit.se> <20100509214225.GA3504@rangda.stickybit.se> <20100602224132.GA4799@rangda.stickybit.se> <20100603184103.GA3108@rangda.stickybit.se> In-Reply-To: <20100603184103.GA3108@rangda.stickybit.se> X-Enigmail-Version: 1.0.1 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="------------enig1D612303495222DED89A8272" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: 574863@bugs.debian.org, sean finney Subject: Re: [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: Tue, 29 Jun 2010 05:31:12 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig1D612303495222DED89A8272 Content-Type: multipart/mixed; boundary="------------040306000301070502060901" This is a multi-part message in MIME format. --------------040306000301070502060901 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 06/03/2010 08:41 PM, sean finney wrote: > 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 match= es > with the style of the surrounding code. > > i have also tested this now on my primary testing system and haven't > noticed any problems. > > =20 I've cleaned up your patch using my more generic string parsing functions. Could you test attached patch? > sean > > On Thu, Jun 03, 2010 at 12:41:32AM +0200, sean finney wrote: > =20 >> okay, I think the attached patch should fix the problem. >> >> 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 an= d >> the critical aspect of the bug is fixed anyway. >> >> >> sean >> =20 > =20 >> Author: Sean Finney >> Description: Fix for lvm2 parsing failures with snapshot logical volum= es >> >> 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 >> --- 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 > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel > =20 --=20 Regards Vladimir '=CF=86-coder/phcoder' Serbinenko --------------040306000301070502060901 Content-Type: text/x-diff; name="lvm.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="lvm.diff" =3D=3D=3D modified file 'disk/lvm.c' --- disk/lvm.c 2010-04-27 15:25:12 +0000 +++ disk/lvm.c 2010-06-29 05:27:15 +0000 @@ -46,6 +46,52 @@ grub_lvm_getvalue (char **p, char *str) } =20 static int +grub_lvm_checkvalue (char **p, char *str, char *tmpl) +{ + int tmpllen =3D grub_strlen (tmpl); + *p =3D grub_strstr (*p, str); + if (! *p) + return 0; + *p +=3D grub_strlen (str); + if (**p !=3D '"') + return 0; + return (grub_memcmp (*p + 1, tmpl, tmpllen) =3D=3D 0 && (*p)[tmpllen += 1] =3D=3D '"'); +} + +static int +grub_lvm_check_flag (char *p, char *str, char *flag) +{ + int len_str =3D grub_strlen (str), len_flag =3D grub_strlen (flag); + while (1) + { + char *q; + p =3D grub_strstr (p, str); + if (! p) + return 0; + p +=3D len_str; + if (grub_memcmp (p, " =3D [", sizeof (" =3D [") - 1) !=3D 0) + continue; + q =3D p + sizeof (" =3D [") - 1; + while (1) + { + while (grub_isspace (*q)) + q++; + if (*q !=3D '"') + return 0; + q++; + if (grub_memcmp (q, flag, len_flag) =3D=3D 0 && q[len_flag] =3D=3D '"= ') + return 1; + while (*q !=3D '"') + q++; + q++; + if (*q =3D=3D ']') + return 0; + q++; + } + } +} + +static int grub_lvm_iterate (int (*hook) (const char *name)) { struct grub_lvm_vg *vg; @@ -421,6 +467,7 @@ grub_lvm_scan_device (const char *name) while (1) { int s; + int skip_lv =3D 0; struct grub_lvm_lv *lv; struct grub_lvm_segment *seg; =20 @@ -445,6 +492,12 @@ grub_lvm_scan_device (const char *name) =20 lv->size =3D 0; =20 + if (!grub_lvm_check_flag (p, "status", "VISIBLE")) + { + skip_lv =3D 1; + goto lv_parsed; + } + lv->segment_count =3D grub_lvm_getvalue (&p, "segment_count =3D "= ); if (p =3D=3D NULL) goto lvs_fail; @@ -465,6 +518,14 @@ grub_lvm_scan_device (const char *name) seg->extent_count =3D grub_lvm_getvalue (&p, "extent_count =3D "); if (p =3D=3D NULL) goto lvs_segment_fail; + + if (grub_lvm_checkvalue (&p, "type =3D ", "snapshot")) + { + /* Found a snapshot, give up and move on. */ + skip_lv =3D 1; + break; + } + seg->stripe_count =3D grub_lvm_getvalue (&p, "stripe_count =3D "); if (p =3D=3D NULL) goto lvs_segment_fail; @@ -531,12 +592,20 @@ grub_lvm_scan_device (const char *name) goto fail4; } =20 + lv_parsed: if (p !=3D NULL) p =3D grub_strchr (p, '}'); if (p =3D=3D NULL) goto lvs_fail; p +=3D 3; =20 + if (skip_lv) + { + grub_free (lv->name); + grub_free (lv); + continue; + } + lv->number =3D lv_count++; lv->vg =3D vg; lv->next =3D vg->lvs; --------------040306000301070502060901-- --------------enig1D612303495222DED89A8272 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iF4EAREKAAYFAkwphRgACgkQNak7dOguQglD4AD+IjLznuB6HQET/T/jHfaYXLHR hmlo9nXdYUGNEYUd01QBAI/DvL8+eYdeii3CJkf2NJpIBfXyPi0vJxzLuSL/cLYf =CkGH -----END PGP SIGNATURE----- --------------enig1D612303495222DED89A8272--