Bug 182248

Summary: [zfs][patch] 'zpool upgrade' abort()s when checking features for a faulted pool
Product: Base System Reporter: Fabian Keil <fk>
Component: binAssignee: Steven Hartland <smh>
Status: Closed FIXED    
Severity: Affects Many People CC: smh
Priority: Normal    
Version: unspecified   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.txt none

Description Fabian Keil 2013-09-20 16:00:00 UTC
'zpool upgrade' abort()s when checking features for a faulted pool whose metadata isn't available.

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:
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.
Comment 1 Steven Hartland freebsd_committer 2014-12-25 02:20:36 UTC
This is fixed by:
https://svnweb.freebsd.org/changeset/base/276194
Comment 2 Steven Hartland freebsd_committer 2014-12-26 01:18:08 UTC
Additional enhancements to the processing of zpool upgrades committed under:
https://svnweb.freebsd.org/changeset/base/276226