mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-26 19:19:32 +03:00
'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 <matt@delphix.com> Reviewed-by: Don Brady <don.brady@delphix.com> Reviewed-by: Prakash Surya <prakash.surya@delphix.com> Signed-off-by: George Wilson <gwilson@delphix.com> External-issue: DLPX-71313 Closes #10688
This commit is contained in:
parent
6f763d4085
commit
53c9d1d9b5
@ -6627,6 +6627,14 @@ share_mount_one(zfs_handle_t *zhp, int op, int flags, char *protocol,
|
|||||||
zfs_get_name(zhp));
|
zfs_get_name(zhp));
|
||||||
return (1);
|
return (1);
|
||||||
} else if (canmount == ZFS_CANMOUNT_NOAUTO && !explicit) {
|
} else if (canmount == ZFS_CANMOUNT_NOAUTO && !explicit) {
|
||||||
|
/*
|
||||||
|
* 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);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,8 +41,10 @@
|
|||||||
# STRATEGY:
|
# STRATEGY:
|
||||||
# 1. Setup a pool and create fs, volume, snapshot clone within it.
|
# 1. Setup a pool and create fs, volume, snapshot clone within it.
|
||||||
# 2. Set canmount=noauto for each dataset and check the return value
|
# 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.
|
# 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"
|
verify_runnable "both"
|
||||||
@ -100,6 +102,7 @@ log_onexit cleanup
|
|||||||
|
|
||||||
set -A old_mnt
|
set -A old_mnt
|
||||||
set -A old_canmount
|
set -A old_canmount
|
||||||
|
set -A old_sharenfs
|
||||||
typeset tmpmnt=/tmpmount$$
|
typeset tmpmnt=/tmpmount$$
|
||||||
typeset ds
|
typeset ds
|
||||||
|
|
||||||
@ -113,6 +116,7 @@ while (( i < ${#dataset_pos[*]} )); do
|
|||||||
ds=${dataset_pos[i]}
|
ds=${dataset_pos[i]}
|
||||||
old_mnt[i]=$(get_prop mountpoint $ds)
|
old_mnt[i]=$(get_prop mountpoint $ds)
|
||||||
old_canmount[i]=$(get_prop canmount $ds)
|
old_canmount[i]=$(get_prop canmount $ds)
|
||||||
|
old_sharenfs[i]=$(get_prop sharenfs $ds)
|
||||||
(( i = i + 1 ))
|
(( i = i + 1 ))
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -121,6 +125,7 @@ while (( i < ${#dataset_pos[*]} )) ; do
|
|||||||
dataset=${dataset_pos[i]}
|
dataset=${dataset_pos[i]}
|
||||||
set_n_check_prop "noauto" "canmount" "$dataset"
|
set_n_check_prop "noauto" "canmount" "$dataset"
|
||||||
log_must zfs set mountpoint=$tmpmnt $dataset
|
log_must zfs set mountpoint=$tmpmnt $dataset
|
||||||
|
log_must zfs set sharenfs=on $dataset
|
||||||
if ismounted $dataset; then
|
if ismounted $dataset; then
|
||||||
zfs unmount -a > /dev/null 2>&1
|
zfs unmount -a > /dev/null 2>&1
|
||||||
log_must mounted $dataset
|
log_must mounted $dataset
|
||||||
@ -128,6 +133,8 @@ while (( i < ${#dataset_pos[*]} )) ; do
|
|||||||
log_must unmounted $dataset
|
log_must unmounted $dataset
|
||||||
log_must zfs mount -a
|
log_must zfs mount -a
|
||||||
log_must unmounted $dataset
|
log_must unmounted $dataset
|
||||||
|
log_must zfs share -a
|
||||||
|
log_mustnot is_exported $tmpmnt
|
||||||
else
|
else
|
||||||
log_must zfs mount -a
|
log_must zfs mount -a
|
||||||
log_must unmounted $dataset
|
log_must unmounted $dataset
|
||||||
@ -137,6 +144,10 @@ while (( i < ${#dataset_pos[*]} )) ; do
|
|||||||
|
|
||||||
log_must zfs mount $dataset
|
log_must zfs mount $dataset
|
||||||
log_must mounted $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 canmount="${old_canmount[i]}" $dataset
|
||||||
log_must zfs set mountpoint="${old_mnt[i]}" $dataset
|
log_must zfs set mountpoint="${old_mnt[i]}" $dataset
|
||||||
(( i = i + 1 ))
|
(( i = i + 1 ))
|
||||||
|
Loading…
Reference in New Issue
Block a user