Fixed zdb -e regression for active cacheless pools

zdb -e for active cache-less pools fails:

$ sudo zpool create -o cachefile=none basic mirror sdk sdl
$ sudo zdb -e -b basic
zdb: can't open 'basic': No such file or directory

This is a recent regression introduce by commit c30d8de.

Reviewed-by: Richard Yao <ryao@gentoo.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Don Brady <don.brady@intel.com>
Closes #6059
This commit is contained in:
Don Brady 2017-04-24 11:31:45 -06:00 committed by Brian Behlendorf
parent 6e03ec4fa2
commit e102363a66
1 changed files with 7 additions and 2 deletions

View File

@ -1938,10 +1938,15 @@ zpool_find_import_impl(libzfs_handle_t *hdl, importargs_t *iarg)
* exclusively. This will prune all underlying * exclusively. This will prune all underlying
* multipath devices which otherwise could * multipath devices which otherwise could
* result in the vdev appearing as UNAVAIL. * result in the vdev appearing as UNAVAIL.
*
* Under zdb, this step isn't required and
* would prevent a zdb -e of active pools with
* no cachefile.
*/ */
fd = open(slice->rn_name, O_RDONLY | O_EXCL); fd = open(slice->rn_name, O_RDONLY | O_EXCL);
if (fd >= 0) { if (fd >= 0 || iarg->can_be_active) {
close(fd); if (fd >= 0)
close(fd);
add_config(hdl, &pools, add_config(hdl, &pools,
slice->rn_name, slice->rn_order, slice->rn_name, slice->rn_order,
slice->rn_num_labels, config); slice->rn_num_labels, config);