ZTS: Fix test zfs_mount_006_pos

For Linux, place a file in the mount point folder so it will be
considered "busy".  Fix the while loop so it doesn't rm in
directories above the testdir.  Add Linux-specific code to test
overlay on|off.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Paul Zuchowski <pzuchowski@datto.com>
Closes #4990 
Closes #8081
This commit is contained in:
Paul Zuchowski 2018-11-07 19:54:08 -05:00 committed by Brian Behlendorf
parent d7bda38c76
commit c2bcfa71f4
2 changed files with 38 additions and 19 deletions

View File

@ -165,7 +165,6 @@ known = {
'casenorm/mixed_formd_lookup': ['FAIL', '7633'], 'casenorm/mixed_formd_lookup': ['FAIL', '7633'],
'casenorm/mixed_formd_lookup_ci': ['FAIL', '7633'], 'casenorm/mixed_formd_lookup_ci': ['FAIL', '7633'],
'casenorm/mixed_formd_delete': ['FAIL', '7633'], 'casenorm/mixed_formd_delete': ['FAIL', '7633'],
'cli_root/zfs_mount/zfs_mount_006_pos': ['SKIP', '4990'],
'cli_root/zfs_receive/zfs_receive_004_neg': ['FAIL', known_reason], 'cli_root/zfs_receive/zfs_receive_004_neg': ['FAIL', known_reason],
'cli_root/zfs_unshare/zfs_unshare_002_pos': ['SKIP', na_reason], 'cli_root/zfs_unshare/zfs_unshare_002_pos': ['SKIP', na_reason],
'cli_root/zfs_unshare/zfs_unshare_006_pos': ['SKIP', na_reason], 'cli_root/zfs_unshare/zfs_unshare_006_pos': ['SKIP', na_reason],

View File

@ -27,6 +27,7 @@
# #
# Copyright (c) 2016 by Delphix. All rights reserved. # Copyright (c) 2016 by Delphix. All rights reserved.
# Copyright (c) 2018, Datto, Inc. All rights reserved.
# #
. $STF_SUITE/include/libtest.shlib . $STF_SUITE/include/libtest.shlib
@ -35,25 +36,27 @@
# #
# DESCRIPTION: # DESCRIPTION:
# Invoke "zfs mount <filesystem>" with a filesystem # Invoke "zfs mount <filesystem>" with a filesystem
# which mountpoint be the identical or the top of an existing one, # mountpoint that is identical to an existing one.
# it will fail with a return code of 1 # 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.
# #
# STRATEGY: # STRATEGY:
# 1. Prepare an existing mounted filesystem. # 1. Prepare an existing mounted filesystem.
# 2. Setup a new filesystem and make sure that it is unmounted. # 2. Setup a new filesystem and make sure that it is unmounted.
# 3. Mount the new filesystem using the various combinations # 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=<identical path> <filesystem>
# - zfs set mountpoint=<top path> <filesystem> # - zfs set mountpoint=<top path> <filesystem>
# 4. Verify that mount failed with return code of 1. # 5. Verify that mount failed with return code of 1.
# 6. For Linux, also set overlay=on and verify the mount is
# allowed.
# #
verify_runnable "both" verify_runnable "both"
# See issue: https://github.com/zfsonlinux/zfs/issues/4990
if is_linux; then
log_unsupported "Test case needs to be updated"
fi
function cleanup function cleanup
{ {
log_must force_unmount $TESTPOOL/$TESTFS log_must force_unmount $TESTPOOL/$TESTFS
@ -72,7 +75,7 @@ function cleanup
typeset -i ret=0 typeset -i ret=0
log_assert "Verify that 'zfs $mountcmd <filesystem>'" \ log_assert "Verify that 'zfs $mountcmd <filesystem>'" \
"which mountpoint be the identical or the top of an existing one " \ "where the mountpoint is identical or on top of an existing one" \
"will fail with return code 1." "will fail with return code 1."
log_onexit cleanup log_onexit cleanup
@ -95,6 +98,12 @@ done
log_must zfs set mountpoint=$mtpt $TESTPOOL/$TESTFS log_must zfs set mountpoint=$mtpt $TESTPOOL/$TESTFS
log_must zfs $mountcmd $TESTPOOL/$TESTFS log_must zfs $mountcmd $TESTPOOL/$TESTFS
if is_linux; then
log_must zfs set overlay=off $TESTPOOL/$TESTFS
touch $mtpt/file.1
log_must ls -l $mtpt | grep file
fi
mounted $TESTPOOL/$TESTFS || \ mounted $TESTPOOL/$TESTFS || \
log_unresolved "Filesystem $TESTPOOL/$TESTFS is unmounted" log_unresolved "Filesystem $TESTPOOL/$TESTFS is unmounted"
@ -103,15 +112,26 @@ log_must zfs create $TESTPOOL/$TESTFS1
unmounted $TESTPOOL/$TESTFS1 || \ unmounted $TESTPOOL/$TESTFS1 || \
log_must force_unmount $TESTPOOL/$TESTFS1 log_must force_unmount $TESTPOOL/$TESTFS1
while [[ -n $mtpt ]] ; do while [[ $depth -gt 0 ]] ; do
(( depth == MAXDEPTH )) && \ (( depth == MAXDEPTH )) && \
log_note "Verify that 'zfs $mountcmd <filesystem>'" \ log_note "Verify that 'zfs $mountcmd <filesystem>'" \
"which mountpoint be the identical of an existing one " \ "with a mountpoint that is identical to an existing one" \
"will fail with return code 1." "will fail with return code 1."
log_must zfs set mountpoint=$mtpt $TESTPOOL/$TESTFS1 log_must zfs set mountpoint=$mtpt $TESTPOOL/$TESTFS1
log_note "zfs $mountcmd $TESTPOOL/$TESTFS1"
log_mustnot zfs $mountcmd $TESTPOOL/$TESTFS1 log_mustnot zfs $mountcmd $TESTPOOL/$TESTFS1
# For Linux, test the overlay=on feature which allows
# mounting of non-empty directory.
if is_linux; then
log_must zfs set overlay=on $TESTPOOL/$TESTFS1
log_must zfs $mountcmd $TESTPOOL/$TESTFS1
log_must force_unmount $TESTPOOL/$TESTFS1
log_must zfs set overlay=off $TESTPOOL/$TESTFS1
fi
unmounted $TESTPOOL/$TESTFS1 || \ unmounted $TESTPOOL/$TESTFS1 || \
log_fail "Filesystem $TESTPOOL/$TESTFS1 is mounted." log_fail "Filesystem $TESTPOOL/$TESTFS1 is mounted."
@ -119,11 +139,11 @@ while [[ -n $mtpt ]] ; do
(( depth == MAXDEPTH )) && \ (( depth == MAXDEPTH )) && \
log_note "Verify that 'zfs $mountcmd <filesystem>'" \ log_note "Verify that 'zfs $mountcmd <filesystem>'" \
"which mountpoint be the top of an existing one " \ "with a mountpoint on top of an existing one" \
"will fail with return code 1." "will fail with return code 1."
(( depth = depth - 1 )) (( depth = depth - 1 ))
done done
log_pass "'zfs $mountcmd <filesystem>'" \ log_pass "'zfs $mountcmd <filesystem>'" \
"which mountpoint be the identical or the top of an existing one " \ "with a mountpoint that is identical or on top of an existing one" \
"will fail with return code 1." "will fail with return code 1."