Change default to overlay=on

Filesystems allow overlay mounts by default on FreeBSD and Linux.

Respect the native convention by switching the default to overlay=on,
while retaining the option to turn the property off for compatibility
with other operating systems' conventions.

Update documentation and tests accordingly.

Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #10030
This commit is contained in:
Ryan Moeller 2020-03-06 12:28:19 -05:00 committed by GitHub
parent 788398c562
commit f5f6fb03b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 53 additions and 64 deletions

View File

@ -474,8 +474,8 @@ zfs_mount_at(zfs_handle_t *zhp, const char *options, int flags,
}
/*
* Overlay mounts are disabled by default but may be enabled
* via the 'overlay' property or the 'zfs mount -O' option.
* Overlay mounts are enabled by default but may be disabled
* via the 'overlay' property. The -O flag remains for compatibility.
*/
if (!(flags & MS_OVERLAY)) {
if (zfs_prop_get(zhp, ZFS_PROP_OVERLAY, overlay,
@ -489,7 +489,7 @@ zfs_mount_at(zfs_handle_t *zhp, const char *options, int flags,
/*
* Determine if the mountpoint is empty. If so, refuse to perform the
* mount. We don't perform this check if 'remount' is
* specified or if overlay option(-O) is given
* specified or if overlay option (-O) is given
*/
if ((flags & MS_OVERLAY) == 0 && !remount &&
!dir_is_empty(mountpoint)) {

View File

@ -1157,14 +1157,16 @@ See
for more information on
.Sy nbmand
mounts. This property is not used on Linux.
.It Sy overlay Ns = Ns Sy off Ns | Ns Sy on
.It Sy overlay Ns = Ns Sy on Ns | Ns Sy off
Allow mounting on a busy directory or a directory which already contains
files or directories. This is the default mount behavior for Linux file systems.
For consistency with OpenZFS on other platforms overlay mounts are
.Sy off
by default. Set to
files or directories.
This is the default mount behavior for Linux and FreeBSD file systems.
On these platforms the property is
.Sy on
to enable overlay mounts.
by default.
Set to
.Sy off
to disable overlay mounts for consistency with OpenZFS on other platforms.
.It Sy primarycache Ns = Ns Sy all Ns | Ns Sy none Ns | Ns Sy metadata
Controls what is cached in the primary cache
.Pq ARC .

View File

@ -406,7 +406,7 @@ zfs_prop_init(void)
zprop_register_index(ZFS_PROP_NBMAND, "nbmand", 0, PROP_INHERIT,
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "NBMAND",
boolean_table);
zprop_register_index(ZFS_PROP_OVERLAY, "overlay", 0, PROP_INHERIT,
zprop_register_index(ZFS_PROP_OVERLAY, "overlay", 1, PROP_INHERIT,
ZFS_TYPE_FILESYSTEM, "on | off", "OVERLAY", boolean_table);
/* default index properties */

View File

@ -181,7 +181,7 @@ tags = ['functional', 'cli_root', 'zfs_load-key']
tests = ['zfs_mount_001_pos', 'zfs_mount_002_pos', 'zfs_mount_003_pos',
'zfs_mount_004_pos', 'zfs_mount_005_pos', 'zfs_mount_007_pos',
'zfs_mount_009_neg', 'zfs_mount_010_neg', 'zfs_mount_011_neg',
'zfs_mount_012_neg', 'zfs_mount_all_001_pos', 'zfs_mount_encrypted',
'zfs_mount_012_pos', 'zfs_mount_all_001_pos', 'zfs_mount_encrypted',
'zfs_mount_remount', 'zfs_mount_all_fail', 'zfs_mount_all_mountpoints',
'zfs_mount_test_race']
tags = ['functional', 'cli_root', 'zfs_mount']

View File

@ -13,7 +13,7 @@ dist_pkgdata_SCRIPTS = \
zfs_mount_009_neg.ksh \
zfs_mount_010_neg.ksh \
zfs_mount_011_neg.ksh \
zfs_mount_012_neg.ksh \
zfs_mount_012_pos.ksh \
zfs_mount_all_001_pos.ksh \
zfs_mount_all_fail.ksh \
zfs_mount_all_mountpoints.ksh \

View File

@ -35,22 +35,20 @@
#
# DESCRIPTION:
# Invoke "zfs mount <filesystem>" with a filesystem
# mountpoint that is identical to an existing one.
# It will fail with a return code of 1. For Linux,
# place a file in the directory to ensure the failure.
# Also for Linux, test overlay=off (default) in which case
# the mount will fail, and overlay=on, where the mount
# will succeed.
# Invoke "zfs mount <filesystem>" with a filesystem mountpoint that is
# identical to an existing one. It will fail with a return code of 1
# when overlay=off. Place a file in the directory to ensure the failure.
# Also test overlay=on (default) in which case the mount will not fail.
#
# STRATEGY:
# 1. Prepare an existing mounted filesystem.
# 2. Setup a new filesystem and make sure that it is unmounted.
# 3. For Linux, place a file in the mount point folder.
# 4. Mount the new filesystem using the various combinations
# - zfs set mountpoint=<identical path> <filesystem>
# - zfs set mountpoint=<top path> <filesystem>
# 5. Verify that mount failed with return code of 1.
# 2. Setup a new filesystem with overlay=off and make sure that it is
# unmounted.
# 3. Place a file in the mount point folder.
# 4. Mount the new filesystem using the various combinations
# - zfs set mountpoint=<identical path> <filesystem>
# - zfs set mountpoint=<top path> <filesystem>
# 5. Verify that mount failed with return code of 1.
# 6. For Linux, also set overlay=on and verify the mount is
# allowed.
#
@ -76,7 +74,7 @@ typeset -i ret=0
log_assert "Verify that 'zfs $mountcmd <filesystem>'" \
"where the mountpoint is identical or on top of an existing one" \
"will fail with return code 1."
"will fail with return code 1 when overlay=off."
log_onexit cleanup
@ -98,8 +96,8 @@ done
log_must zfs set mountpoint=$mtpt $TESTPOOL/$TESTFS
log_must zfs $mountcmd $TESTPOOL/$TESTFS
if is_linux; then
log_must zfs set overlay=off $TESTPOOL/$TESTFS
log_must zfs set overlay=off $TESTPOOL/$TESTFS
if ! is_illumos; then
touch $mtpt/file.1
log_must ls -l $mtpt | grep file
fi
@ -107,7 +105,7 @@ fi
mounted $TESTPOOL/$TESTFS || \
log_unresolved "Filesystem $TESTPOOL/$TESTFS is unmounted"
log_must zfs create $TESTPOOL/$TESTFS1
log_must zfs create -o overlay=off $TESTPOOL/$TESTFS1
unmounted $TESTPOOL/$TESTFS1 || \
log_must force_unmount $TESTPOOL/$TESTFS1
@ -123,9 +121,9 @@ while [[ $depth -gt 0 ]] ; do
log_mustnot zfs $mountcmd $TESTPOOL/$TESTFS1
# For Linux, test the overlay=on feature which allows
# mounting of non-empty directory.
if is_linux; then
if ! is_illumos; then
# Test the overlay=on feature which allows
# mounting of non-empty directory.
log_must zfs set overlay=on $TESTPOOL/$TESTFS1
log_must zfs $mountcmd $TESTPOOL/$TESTFS1
log_must force_unmount $TESTPOOL/$TESTFS1

View File

@ -73,7 +73,8 @@ log_must mkfile 1M $testfile $testfile1
log_must zfs unmount $fs1
log_must zfs set mountpoint=$mntpnt $fs1
log_mustnot zfs mount $fs1
log_must zfs mount $fs1
log_must zfs unmount $fs1
log_must zfs mount -O $fs1
# Create new file in override mountpoint

View File

@ -18,9 +18,6 @@
#
# DESCRIPTION:
# Linux:
# Verify that zfs mount fails with a non-empty directory
# FreeSD:
# Verify that zfs mount succeeds with a non-empty directory
#
@ -34,18 +31,12 @@
# 6. Unmount the dataset
# 7. Create a file in the directory created in step 2
# 8. Attempt to mount the dataset
# 9. Verify the mount fails
# 9. Verify the mount succeeds
#
verify_runnable "both"
if is_linux; then
behaves="fails"
else
behaves="succeeds"
fi
log_assert "zfs mount $behaves with non-empty directory"
log_assert "zfs mount succeeds with non-empty directory"
fs=$TESTPOOL/$TESTFS
@ -55,12 +46,8 @@ log_must zfs set mountpoint=$TESTDIR $fs
log_must zfs mount $fs
log_must zfs umount $fs
log_must touch $TESTDIR/testfile.$$
if is_linux; then
log_mustnot zfs mount $fs
else
log_must zfs mount $fs
log_must zfs umount $fs
fi
log_must zfs mount $fs
log_must zfs umount $fs
log_must rm -rf $TESTDIR
log_pass "zfs mount $behaves with non-empty directory as expected."
log_pass "zfs mount succeeds with non-empty directory as expected."

View File

@ -30,8 +30,8 @@
# 1. Create zfs filesystems
# 2. Unmount a leaf filesystem
# 3. Create a file in the above filesystem's mountpoint
# 4. Verify that 'zfs mount -a' fails to mount the above if on Linux
# or succeeds if on FreeBSD
# 4. Verify that 'zfs mount -a' succeeds if overlay=on and
# fails to mount the above if overlay=off
# 5. Verify that all other filesystems were mounted
#
@ -83,17 +83,18 @@ done
# Create a stray file in one filesystem's mountpoint
touch $path/0/strayfile
# Verify that zfs mount -a fails on Linux or succeeds on FreeBSD
export __ZFS_POOL_RESTRICT="$TESTPOOL"
if is_linux; then
log_mustnot zfs $mountall
log_mustnot mounted "$TESTPOOL/0"
typeset behaved="failed"
else
log_must zfs $mountall
log_must mounted "$TESTPOOL/0"
typeset behaved="succeeded"
fi
# Verify that zfs mount -a succeeds with overlay=on (default)
log_must zfs $mountall
log_must mounted "$TESTPOOL/0"
log_must zfs $unmountall
# Verify that zfs mount -a succeeds with overlay=off
log_must zfs set overlay=off "$TESTPOOL/0"
log_mustnot zfs $mountall
log_mustnot mounted "$TESTPOOL/0"
unset __ZFS_POOL_RESTRICT
# All other filesystems should be mounted
@ -101,4 +102,4 @@ for ((i=1; i<$fscount; i++)); do
log_must mounted "$TESTPOOL/$i"
done
log_pass "'zfs $mountall' $behaved as expected."
log_pass "'zfs $mountall' behaves as expected."