zpool upgrade with unavailable pool causes assert violation
When running zpool upgrade on a system with an unavailable pool it results in an assert violation as it tries to access the pool without checking that its unavailable.
Example output of this from FreeBSD is:
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.
The attached path fixes this, here is the combined commit log entries from FreeBSD:
Prevent zpool upgrade failing due to unavailable pools
Prior to this fix "zpool upgrade" and "zpool upgrade -a" would fail due to an assert when operating on unavailable pools.
Introduce a separate phase to list all unavailable pools when listing pools to upgrade. This avoids confusing output when displaying older and disabled feature pools. These existing phases now silently skip unavailable pools.
Introduce cb_unavail to upgrade_cbdata_t which enables the final output for zpool list to correctly detail if all pools or only all available pools where up-to-date on version / features.
Correct the type of upgrade_cbdata_t.cb_first from int -> boolean_t.
Change the pool iteration when upgrading named pools to include unavailable pools and update upgrade_one so it doesn't try to upgrade unavailable pools but warns about them. This allows the correct error to be displayed as well as upgrades with available and unavailable pools intermixed to partially complete.
Also correct some missing trailing \\n's from output in upgrade_one.Relevant links: