Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Sep 2013 14:51:08 GMT
From:      Fabian Keil <fk@fabiankeil.de>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   bin/182248: [zfs][patch] 'zpool upgrade' abort()s when checking features for a faulted pool
Message-ID:  <201309201451.r8KEp8cX077265@oldred.freebsd.org>
Resent-Message-ID: <201309201500.r8KF00gF076711@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         182248
>Category:       bin
>Synopsis:       [zfs][patch] 'zpool upgrade' abort()s when checking features for a faulted pool
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Sep 20 15:00:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     Fabian Keil
>Release:        HEAD
>Organization:
>Environment:
FreeBSD r500.local 10.0-ALPHA2 FreeBSD 10.0-ALPHA2 #599 r255627+28ad33b: Tue Sep 17 22:44:20 CEST 2013     fk@r500.local:/usr/obj/usr/src/sys/ZOEY  amd64

>Description:
'zpool upgrade' abort()s when checking features for a faulted pool whose metadata isn't available.
>How-To-Repeat:
Import pool, unplug vdev to get an UNAVAILable pool, reboot system to lose cached metadata resulting in a FAULTED pool, run "zpool upgrade":

fk@r500 ~ $zpool list qualipso
NAME       SIZE  ALLOC   FREE    CAP  DEDUP  HEALTH  ALTROOT
qualipso      -      -      -      -      -  FAULTED  -
fk@r500 ~ $gdb76 --args zpool upgrade
[...]
(gdb) r
Starting program: /sbin/zpool upgrade
[New LWP 100908]
This system supports ZFS pool feature flags.

All pools are formatted using feature flags.

Assertion failed: (nvlist_lookup_nvlist(config, "feature_stats", &features) == 0), file /usr/src/cddl/lib/libzfs/../../../cddl/contrib/opensolaris/lib/libzfs/common/libzfs_config.c, line 250.
[New Thread 802c06400 (LWP 100908)]

Program received signal SIGABRT, Aborted.
[Switching to Thread 802c06400 (LWP 100908)]
kill () at kill.S:3
3	RSYSCALL(kill)
(gdb) where
#0  kill () at kill.S:3
#1  0x00000008019e33e6 in __raise (s=6) at /usr/src/lib/libc/gen/raise.c:45
#2  0x00000008019e2169 in abort () at /usr/src/lib/libc/stdlib/abort.c:65
#3  0x0000000801690140 in __assert (expr=<optimized out>, file=<optimized out>, line=<optimized out>) at /usr/src/cddl/lib/libzfs/../../../cddl/compat/opensolaris/include/assert.h:56
#4  0x000000080168fe95 in zpool_get_features (zhp=<optimized out>) at /usr/src/cddl/lib/libzfs/../../../cddl/contrib/opensolaris/lib/libzfs/common/libzfs_config.c:249
#5  0x000000000040bc4a in upgrade_list_disabled_cb (zhp=0x802c6eb40, arg=0x7fffffffc4f8) at /usr/src/cddl/sbin/zpool/../../../cddl/contrib/opensolaris/cmd/zpool/zpool_main.c:4681
#6  0x00000008016901dd in zpool_iter (hdl=0x802c1a200, func=0x40bc00 <upgrade_list_disabled_cb>, data=0x7fffffffc4f8)
    at /usr/src/cddl/lib/libzfs/../../../cddl/contrib/opensolaris/lib/libzfs/common/libzfs_config.c:415
#7  0x000000000040aeaa in zpool_do_upgrade (argc=<optimized out>, argv=0x7fffffffd8a0) at /usr/src/cddl/sbin/zpool/../../../cddl/contrib/opensolaris/cmd/zpool/zpool_main.c:4956
#8  0x00000000004074d1 in main (argc=<optimized out>, argv=<optimized out>) at /usr/src/cddl/sbin/zpool/../../../cddl/contrib/opensolaris/cmd/zpool/zpool_main.c:5360
´(gdb) f 5
#5  0x000000000040bc4a in upgrade_list_disabled_cb (zhp=0x802c6eb40, arg=0x7fffffffc4f8) at /usr/src/cddl/sbin/zpool/../../../cddl/contrib/opensolaris/cmd/zpool/zpool_main.c:4681
4681			nvlist_t *enabled = zpool_get_features(zhp);
(gdb) p *zhp
$1 = {zpool_hdl = 0x802c1a200, zpool_next = 0x0, zpool_name = "qualipso", '\000' <repeats 247 times>, zpool_state = 6, zpool_config_size = 1740, zpool_config = 0x802c5b140, zpool_old_config = 0x802c5b120, 
  zpool_props = 0x0, zpool_start_block = 0}

I doubt that it matters, but I'm using zogftw, which means geli and glabel are involved, too, and there is only a single vdev.
>Fix:
The attached patch prevents the core dumps for me, it could be argued that not complaining about the FAULTED pool isn't ideal, though:

fk@r500 ~ $zpool list qualipso
NAME       SIZE  ALLOC   FREE    CAP  DEDUP  HEALTH  ALTROOT
qualipso      -      -      -      -      -  FAULTED  -
fk@r500 ~ $zpool upgrade
This system supports ZFS pool feature flags.

All pools are formatted using feature flags.

Every feature flags pool has all supported features enabled.


Patch attached with submission follows:

>From 055667eac6d16bbdef719ec26ffeaff97b85ab09 Mon Sep 17 00:00:00 2001
From: Fabian Keil <fk@fabiankeil.de>
Date: Mon, 8 Apr 2013 18:40:36 +0200
Subject: [PATCH] Skip unavailable pools in upgrade_list_*_cb()

zpool_get_features() isn't supposed to be used on
unavailable pools:

fk@r500 ~ $zpool upgrade
This system supports ZFS pool feature flags.

All pools are formatted using feature flags.

Assertion failed: (nvlist_lookup_nvlist(config, "feature_stats", &features) == 0), file /usr/src/cddl/lib/libzfs/../../../cddl/contrib/opensolaris/lib/libzfs/common/libzfs_config.c, line 250.
Abort trap (core dumped)
---
 cddl/contrib/opensolaris/cmd/zpool/zpool_main.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c b/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
index 0dcf11b..98a179e 100644
--- a/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
+++ b/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
@@ -4638,6 +4638,10 @@ upgrade_list_older_cb(zpool_handle_t *zhp, void *arg)
 	nvlist_t *config;
 	uint64_t version;
 
+	if (zpool_get_state(zhp) == POOL_STATE_UNAVAIL) {
+		return (0);
+	}
+
 	config = zpool_get_config(zhp, NULL);
 	verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION,
 	    &version) == 0);
@@ -4671,6 +4675,10 @@ upgrade_list_disabled_cb(zpool_handle_t *zhp, void *arg)
 	nvlist_t *config;
 	uint64_t version;
 
+	if (zpool_get_state(zhp) == POOL_STATE_UNAVAIL) {
+		return (0);
+	}
+
 	config = zpool_get_config(zhp, NULL);
 	verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION,
 	    &version) == 0);
-- 
1.8.4



>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201309201451.r8KEp8cX077265>