diff options
author | LOLi <[email protected]> | 2018-10-17 20:21:07 +0200 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2018-10-17 11:21:07 -0700 |
commit | 2e55034471413fb668d0d910b2c083610b386127 (patch) | |
tree | c98742bb3f508bf0bd61f2db449621a15f60bc28 /cmd | |
parent | 49394a7708e9de4f67e4cd4fb34b59b64ec7aeb1 (diff) |
zpool: allow sharing of spare device among pools
ZFS allows, by default, sharing of spare devices among different pools;
this commit simply restores this functionality for disk devices and
adds an additional tests case to the ZFS Test Suite to prevent future
regression.
Reviewed-by: Tony Hutter <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: loli10K <[email protected]>
Closes #7999
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/zpool/zpool_vdev.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/cmd/zpool/zpool_vdev.c b/cmd/zpool/zpool_vdev.c index 37f1ca1d9..2d9c1d028 100644 --- a/cmd/zpool/zpool_vdev.c +++ b/cmd/zpool/zpool_vdev.c @@ -419,11 +419,16 @@ check_disk(const char *path, blkid_cache cache, int force, char slice_path[MAXPATHLEN]; int err = 0; int fd, i; + int flags = O_RDONLY|O_DIRECT; if (!iswholedisk) return (check_slice(path, cache, force, isspare)); - if ((fd = open(path, O_RDONLY|O_DIRECT|O_EXCL)) < 0) { + /* only spares can be shared, other devices require exclusive access */ + if (!isspare) + flags |= O_EXCL; + + if ((fd = open(path, flags)) < 0) { char *value = blkid_get_tag_value(cache, "TYPE", path); (void) fprintf(stderr, gettext("%s is in use and contains " "a %s filesystem.\n"), path, value ? value : "unknown"); @@ -547,7 +552,7 @@ is_spare(nvlist_t *config, const char *path) uint_t i, nspares; boolean_t inuse; - if ((fd = open(path, O_RDONLY)) < 0) + if ((fd = open(path, O_RDONLY|O_DIRECT)) < 0) return (B_FALSE); if (zpool_in_use(g_zfs, fd, &state, &name, &inuse) != 0 || |