diff options
author | George Wilson <[email protected]> | 2020-08-11 14:55:04 -0600 |
---|---|---|
committer | GitHub <[email protected]> | 2020-08-11 13:55:04 -0700 |
commit | 53c9d1d9b5ff19d3095f9dcbb806582d9c0b977f (patch) | |
tree | 45e23eead2953b19d3ccf60159402d8623d09f4d | |
parent | 6f763d408530c5dd22e4e8616235871524e55529 (diff) |
'zfs share -a' should handle 'canmount=noauto'
The 'zfs share -a' currently skips any filesystems which
have 'canmount=noauto' set. This behavior is unexpected since the
one would expect 'zfs share -a' to share any mounted filesystem
that has the 'sharenfs' property already set.
This changes the behavior of 'zfs share -a' to allow the sharing
of 'canmount=noauto' datasets if they are mounted.
Reviewed-by: Matt Ahrens <[email protected]>
Reviewed-by: Don Brady <[email protected]>
Reviewed-by: Prakash Surya <[email protected]>
Signed-off-by: George Wilson <[email protected]>
External-issue: DLPX-71313
Closes #10688
-rw-r--r-- | cmd/zfs/zfs_main.c | 10 | ||||
-rwxr-xr-x | tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_002_pos.ksh | 13 |
2 files changed, 21 insertions, 2 deletions
diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index c6a29095e..2878f03a3 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -6627,7 +6627,15 @@ share_mount_one(zfs_handle_t *zhp, int op, int flags, char *protocol, zfs_get_name(zhp)); return (1); } else if (canmount == ZFS_CANMOUNT_NOAUTO && !explicit) { - return (0); + /* + * When performing a 'zfs mount -a', we skip any mounts for + * datasets that have 'noauto' set. Sharing a dataset with + * 'noauto' set is only allowed if it's mounted. + */ + if (op == OP_MOUNT) + return (0); + if (op == OP_SHARE && !zfs_is_mounted(zhp, NULL)) + return (0); } /* diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_002_pos.ksh index 3b8b88e36..1aeee44e0 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_002_pos.ksh @@ -41,8 +41,10 @@ # STRATEGY: # 1. Setup a pool and create fs, volume, snapshot clone within it. # 2. Set canmount=noauto for each dataset and check the return value -# and check if it still can be mounted by mount -a. +# and check if it still can be mounted by mount -a or shared by +# share -a # 3. mount each dataset(except volume) to see if it can be mounted. +# 4. verify that a mounted dataset can be shared by share -a. # verify_runnable "both" @@ -100,6 +102,7 @@ log_onexit cleanup set -A old_mnt set -A old_canmount +set -A old_sharenfs typeset tmpmnt=/tmpmount$$ typeset ds @@ -113,6 +116,7 @@ while (( i < ${#dataset_pos[*]} )); do ds=${dataset_pos[i]} old_mnt[i]=$(get_prop mountpoint $ds) old_canmount[i]=$(get_prop canmount $ds) + old_sharenfs[i]=$(get_prop sharenfs $ds) (( i = i + 1 )) done @@ -121,6 +125,7 @@ while (( i < ${#dataset_pos[*]} )) ; do dataset=${dataset_pos[i]} set_n_check_prop "noauto" "canmount" "$dataset" log_must zfs set mountpoint=$tmpmnt $dataset + log_must zfs set sharenfs=on $dataset if ismounted $dataset; then zfs unmount -a > /dev/null 2>&1 log_must mounted $dataset @@ -128,6 +133,8 @@ while (( i < ${#dataset_pos[*]} )) ; do log_must unmounted $dataset log_must zfs mount -a log_must unmounted $dataset + log_must zfs share -a + log_mustnot is_exported $tmpmnt else log_must zfs mount -a log_must unmounted $dataset @@ -137,6 +144,10 @@ while (( i < ${#dataset_pos[*]} )) ; do log_must zfs mount $dataset log_must mounted $dataset + log_must zfs share -a + log_must is_exported $tmpmnt + + log_must zfs set sharenfs="${old_sharenfs[i]}" $dataset log_must zfs set canmount="${old_canmount[i]}" $dataset log_must zfs set mountpoint="${old_mnt[i]}" $dataset (( i = i + 1 )) |