diff options
author | Chunwei Chen <[email protected]> | 2017-05-24 15:11:23 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2017-06-01 06:38:04 -0700 |
commit | 2e9c8dbddfa5d53aa2f9c508e3dc1263d89466ad (patch) | |
tree | 92f98daf54dbfeaf64e2f5f8ea01d4402f4b0910 | |
parent | b568efec526d9336292b37faae951aa9cfb4484c (diff) |
Fix import finding spare/l2cache when path changes
When spare or l2cache device path changes, zpool import will not fix up
their paths like normal vdev. The issue is that when you supply a pool
name argument to zpool import, it will use it to filter out device which
doesn't have the pool name in the label. Since spare and l2cache device
never have that in the label, they'll always get filtered out.
We fix this by making sure we never filter out a spare or l2cache
device.
Reviewed by: Richard Elling <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Chunwei Chen <[email protected]>
Closes #6158
-rw-r--r-- | lib/libzfs/libzfs_import.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/libzfs/libzfs_import.c b/lib/libzfs/libzfs_import.c index 40798f42b..02264433e 100644 --- a/lib/libzfs/libzfs_import.c +++ b/lib/libzfs/libzfs_import.c @@ -1915,15 +1915,29 @@ zpool_find_import_impl(libzfs_handle_t *hdl, importargs_t *iarg) if (slice->rn_config != NULL) { nvlist_t *config = slice->rn_config; boolean_t matched = B_TRUE; + boolean_t aux = B_FALSE; int fd; - if (iarg->poolname != NULL) { + /* + * Check if it's a spare or l2cache device. If it is, + * we need to skip the name and guid check since they + * don't exist on aux device label. + */ + if (iarg->poolname != NULL || iarg->guid != 0) { + uint64_t state; + aux = nvlist_lookup_uint64(config, + ZPOOL_CONFIG_POOL_STATE, &state) == 0 && + (state == POOL_STATE_SPARE || + state == POOL_STATE_L2CACHE); + } + + if (iarg->poolname != NULL && !aux) { char *pname; matched = nvlist_lookup_string(config, ZPOOL_CONFIG_POOL_NAME, &pname) == 0 && strcmp(iarg->poolname, pname) == 0; - } else if (iarg->guid != 0) { + } else if (iarg->guid != 0 && !aux) { uint64_t this_guid; matched = nvlist_lookup_uint64(config, |