HomeFreeBSD

Make `zpool import -d|-c` behave consistently

Description

Make zpool import -d|-c behave consistently

When importing pools with zpool import -aN there is inconsistent
behavior between '-d /dev/disk/by-id' (or another path) and
'-c /etc/zfs/zpool.cache'.

The difference in behavior is caused by zpool_find_import_cached()
returning an empty nvlist_t when there are no pools to import but
zpool_find_import_impl() returns NULL for the same situation. The
behavior of zpool_find_import_cached() is arguably more correct
because it allows returning NULL to be used for an error case and
not an empty set.

This change resolves the issue by updating get_configs() such that
it returns an empty set instead of NULL when no config is found.
The updated behavior will now always return 0 for this case.

$ zpool import -aN; echo $?
no pools available to import
0

$ zpool import -aN -d /var/tmp/; echo $?
no pools available to import
0

$ zpool import -aN -c /etc/zfs/zpool.cache; echo $?
no pools available to import
0

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #2080

Details

Provenance
Brian Behlendorf <behlendorf1@llnl.gov>Authored on Oct 30 2014, 8:17 PM
Parents
rGa485efc4cd75: Merge branch 'arc_summary_draft_v2'
Branches
Unknown
Tags
Unknown

Event Timeline

Brian Behlendorf <behlendorf1@llnl.gov> committed rG6466b61db6b4: Make `zpool import -d|-c` behave consistently (authored by Brian Behlendorf <behlendorf1@llnl.gov>).Jan 28 2015, 7:12 PM