From owner-freebsd-bugs@FreeBSD.ORG Thu Oct 2 07:50:03 2008 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 66CBE106569E for ; Thu, 2 Oct 2008 07:50:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 54CB28FC26 for ; Thu, 2 Oct 2008 07:50:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m927o3KZ095406 for ; Thu, 2 Oct 2008 07:50:03 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m927o3Gt095405; Thu, 2 Oct 2008 07:50:03 GMT (envelope-from gnats) Date: Thu, 2 Oct 2008 07:50:03 GMT Message-Id: <200810020750.m927o3Gt095405@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Jaakko Heinonen Cc: Subject: Re: kern/119868: [zfs] 7.0 kernel panic during boot with ZFS and WD1600JS X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Jaakko Heinonen List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Oct 2008 07:50:03 -0000 The following reply was made to PR kern/119868; it has been noted by GNATS. From: Jaakko Heinonen To: Harald Hanche-Olsen Cc: bug-followup@FreeBSD.org, johan@giantfoo.org, marcel@FreeBSD.org Subject: Re: kern/119868: [zfs] 7.0 kernel panic during boot with ZFS and WD1600JS Date: Thu, 2 Oct 2008 10:39:52 +0300 Hi, On 2008-09-30, Harald Hanche-Olsen wrote: > For the curious: I intended to do > > #; gpt create -f da2 > #; gpt add -t 6a898cc3-1dd2-11b2-99a6-080020736631 da2 > #; zpool create poolname da2p1 > > but apparently, I created the pool on da2 instead, partially > overwriting the GPT. This PR is a duplicate of kern/127115. The bug is not in zfs code but in the gpart GPT code. It's possible that a corrupted GPT partition table causes a panic in g_part_gpt_read(). These conditions must be true after reading the tables in g_part_gpt_read() to cause the panic: table->state[GPT_ELT_PRIHDR] == GPT_STATE_OK pritbl == NULL table->state[GPT_ELT_SECTBL] == GPT_STATE_OK The panic happens at line 661 in g_part_gpt.c (r183533) when tbl is NULL. Here is a proposed fix: %%% Index: sys/geom/part/g_part_gpt.c =================================================================== --- sys/geom/part/g_part_gpt.c (revision 183533) +++ sys/geom/part/g_part_gpt.c (working copy) @@ -631,7 +631,7 @@ g_part_gpt_read(struct g_part_table *bas table->state[GPT_ELT_PRIHDR] = GPT_STATE_INVALID; } - if (table->state[GPT_ELT_PRIHDR] != GPT_STATE_OK) { + if (table->state[GPT_ELT_PRITBL] != GPT_STATE_OK) { printf("GEOM: %s: the primary GPT table is corrupt or " "invalid.\n", pp->name); printf("GEOM: %s: using the secondary instead -- recovery " @@ -641,7 +641,7 @@ g_part_gpt_read(struct g_part_table *bas if (pritbl != NULL) g_free(pritbl); } else { - if (table->state[GPT_ELT_SECHDR] != GPT_STATE_OK) { + if (table->state[GPT_ELT_SECTBL] != GPT_STATE_OK) { printf("GEOM: %s: the secondary GPT table is corrupt " "or invalid.\n", pp->name); printf("GEOM: %s: using the primary only -- recovery " %%% The patch applied this is that I get with the corrupted GPT table: GEOM: ad0: the primary GPT table is corrupt or invalid. GEOM: ad0: using the secondary instead -- recovery strongly advised. -- Jaakko