diff options
author | Sebastien Roy <[email protected]> | 2018-11-05 08:40:05 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2018-11-15 11:33:58 -0800 |
commit | a10d50f999511d304f910852c7825c70c9c9e303 (patch) | |
tree | 636446232088444d7dfab1b7a2dc7ca541ee1f9e /tests | |
parent | af2e8411dacbc694b1aaf9074e68a9d12270e74c (diff) |
OpenZFS 8115 - parallel zfs mount
Porting Notes:
* Use thread pools (tpool) API instead of introducing taskq interfaces
to libzfs.
* Use pthread_mutext for locks as mutex_t isn't available.
* Ignore alternative libshare initialization since OpenZFS-7955 is
not present on zfsonlinux.
Authored by: Sebastien Roy <[email protected]>
Reviewed by: Matthew Ahrens <[email protected]>
Reviewed by: Pavel Zakharov <[email protected]>
Reviewed by: Brad Lewis <[email protected]>
Reviewed by: George Wilson <[email protected]>
Reviewed by: Paul Dagnelie <[email protected]>
Reviewed by: Prashanth Sreenivasa <[email protected]>
Authored by: Brian Behlendorf <[email protected]>
Approved by: Matt Ahrens <[email protected]>
Ported-by: Don Brady <[email protected]>
OpenZFS-issue: https://www.illumos.org/issues/8115
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/a3f0e2b569
Closes #8092
Diffstat (limited to 'tests')
5 files changed, 265 insertions, 7 deletions
diff --git a/tests/runfiles/linux.run b/tests/runfiles/linux.run index e5826dd7a..225e9bc8b 100644 --- a/tests/runfiles/linux.run +++ b/tests/runfiles/linux.run @@ -181,7 +181,7 @@ tests = ['zfs_mount_001_pos', 'zfs_mount_002_pos', 'zfs_mount_003_pos', 'zfs_mount_007_pos', 'zfs_mount_008_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_remount', - 'zfs_multi_mount'] + 'zfs_multi_mount', 'zfs_mount_all_fail', 'zfs_mount_all_mountpoints'] tags = ['functional', 'cli_root', 'zfs_mount'] [tests/functional/cli_root/zfs_program] diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_mount/Makefile.am b/tests/zfs-tests/tests/functional/cli_root/zfs_mount/Makefile.am index 05cbd8a77..b2de98934 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_mount/Makefile.am +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_mount/Makefile.am @@ -14,8 +14,10 @@ dist_pkgdata_SCRIPTS = \ zfs_mount_010_neg.ksh \ zfs_mount_011_neg.ksh \ zfs_mount_012_neg.ksh \ - zfs_mount_encrypted.ksh \ zfs_mount_all_001_pos.ksh \ + zfs_mount_all_fail.ksh \ + zfs_mount_all_mountpoints.ksh \ + zfs_mount_encrypted.ksh \ zfs_mount_remount.ksh \ zfs_multi_mount.ksh diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount.kshlib b/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount.kshlib index 2a7cf6ef7..2afb9a547 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount.kshlib @@ -25,7 +25,7 @@ # # -# Copyright (c) 2016 by Delphix. All rights reserved. +# Copyright (c) 2017 by Delphix. All rights reserved. # . $STF_SUITE/include/libtest.shlib @@ -84,14 +84,12 @@ function setup_filesystem #disklist #pool #fs #mntpoint #type #vdev fi case "$type" in - 'ctr') log_must zfs create $pool/$fs - log_must zfs set mountpoint=$mntpoint $pool/$fs + 'ctr') log_must zfs create -o mountpoint=$mntpoint $pool/$fs ;; 'vol') log_must zfs create -V $VOLSIZE $pool/$fs block_device_wait ;; - *) log_must zfs create $pool/$fs - log_must zfs set mountpoint=$mntpoint $pool/$fs + *) log_must zfs create -o mountpoint=$mntpoint $pool/$fs ;; esac diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_all_fail.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_all_fail.ksh new file mode 100755 index 000000000..d7fcd20af --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_all_fail.ksh @@ -0,0 +1,96 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# +# CDDL HEADER END +# + +# +# Copyright (c) 2017 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_root/zfs_mount/zfs_mount.kshlib + +# DESCRIPTION: +# Verify that if 'zfs mount -a' fails to mount one filesystem, +# the command fails with a non-zero error code, but all other +# filesystems are mounted. +# +# STRATEGY: +# 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 +# 5. Verify that all other filesystems were mounted +# + +verify_runnable "both" + +typeset -a filesystems +typeset path=${TEST_BASE_DIR%%/}/testroot$$/$TESTPOOL +typeset fscount=10 + +function setup_all +{ + # Create $fscount filesystems at the top level of $path + for ((i=0; i<$fscount; i++)); do + setup_filesystem "$DISKS" "$TESTPOOL" $i "$path/$i" ctr + done + + zfs list -r $TESTPOOL + + return 0 +} + +function cleanup_all +{ + export __ZFS_POOL_RESTRICT="$TESTPOOL" + log_must zfs $unmountall + unset __ZFS_POOL_RESTRICT + + [[ -d ${TEST_BASE_DIR%%/}/testroot$$ ]] && \ + rm -rf ${TEST_BASE_DIR%%/}/testroot$$ +} + +log_onexit cleanup_all + +log_must setup_all + +# +# Unmount all of the above so that we can create the stray file +# in one of the mountpoint directories. +# +export __ZFS_POOL_RESTRICT="$TESTPOOL" +log_must zfs $unmountall +unset __ZFS_POOL_RESTRICT + +# All of our filesystems should be unmounted at this point +for ((i=0; i<$fscount; i++)); do + log_mustnot mounted "$TESTPOOL/$i" +done + +# Create a stray file in one filesystem's mountpoint +touch $path/0/strayfile + +# Verify that zfs mount -a fails +export __ZFS_POOL_RESTRICT="$TESTPOOL" +log_mustnot zfs $mountall +unset __ZFS_POOL_RESTRICT + +# All filesystems except for "0" should be mounted +log_mustnot mounted "$TESTPOOL/0" +for ((i=1; i<$fscount; i++)); do + log_must mounted "$TESTPOOL/$i" +done + +log_pass "'zfs $mountall' failed as expected." diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_all_mountpoints.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_all_mountpoints.ksh new file mode 100755 index 000000000..3e6a24bbc --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_all_mountpoints.ksh @@ -0,0 +1,162 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# +# CDDL HEADER END +# + +# +# Copyright (c) 2017 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_root/zfs_mount/zfs_mount.kshlib + +# DESCRIPTION: +# Verify that 'zfs mount -a' succeeds given a set of filesystems +# whose mountpoints have a parent/child relationship which is +# counter to the filesystem parent/child relationship. +# +# STRATEGY: +# 1. Create zfs filesystems within the given pool. +# 2. Unmount all the filesystems. +# 3. Verify that 'zfs mount -a' command succeed, +# and all available ZFS filesystems are mounted. +# 4. Verify that 'zfs mount' is identical with 'df -F zfs' +# + +verify_runnable "both" + +typeset -a filesystems + +function setup_all +{ + typeset path=${TEST_BASE_DIR%%/}/testroot$$/$TESTPOOL + typeset fscount=10 + + # + # Generate an array of filesystem names that represent a deep + # hierarchy as such: + # + # 0 + # 0/1 + # 0/1/2 + # 0/1/2/3 + # 0/1/2/3/4 + # ... + # + fs=0 + for ((i=0; i<$fscount; i++)); do + if [[ $i -gt 0 ]]; then + fs=$fs/$i + fi + filesystems+=($fs) + done + + # Create all of the above filesystems + for ((i=0; i<$fscount; i++)); do + fs=${filesystems[$i]} + setup_filesystem "$DISKS" "$TESTPOOL" "$fs" "$path/$i" ctr + done + + zfs list -r $TESTPOOL + + # + # Unmount all of the above so that we can setup our convoluted + # mount paths. + # + export __ZFS_POOL_RESTRICT="$TESTPOOL" + log_must zfs $unmountall + unset __ZFS_POOL_RESTRICT + + # + # Configure the mount paths so that each mountpoint is contained + # in a child filesystem. We should end up with something like the + # following structure (modulo the number of filesystems): + # + # NAME MOUNTPOINT + # testpool /testpool + # testpool/0 /testroot25416/testpool/0/1/2/3/4/5/6 + # testpool/0/1 /testroot25416/testpool/0/1/2/3/4/5 + # testpool/0/1/2 /testroot25416/testpool/0/1/2/3/4 + # testpool/0/1/2/3 /testroot25416/testpool/0/1/2/3 + # testpool/0/1/2/3/4 /testroot25416/testpool/0/1/2 + # testpool/0/1/2/3/4/5 /testroot25416/testpool/0/1 + # testpool/0/1/2/3/4/5/6 /testroot25416/testpool/0 + # + for ((i=0; i<$fscount; i++)); do + fs=$TESTPOOL/${filesystems[$(($fscount - $i - 1))]} + mnt=$path/${filesystems[$i]} + zfs set mountpoint=$mnt $fs + done + + zfs list -r $TESTPOOL + + return 0 +} + +function cleanup_all +{ + export __ZFS_POOL_RESTRICT="$TESTPOOL" + log_must zfs $unmountall + unset __ZFS_POOL_RESTRICT + + for fs in ${filesystems[@]}; do + cleanup_filesystem "$TESTPOOL" "$fs" + done + [[ -d ${TEST_BASE_DIR%%/}/testroot$$ ]] && \ + rm -rf ${TEST_BASE_DIR%%/}/testroot$$ +} + +# +# This function takes a single true/false argument. If true it will verify that +# all file systems are mounted. If false it will verify that they are not +# mounted. +# +function verify_all +{ + if $1; then + logfunc=log_must + else + logfunc=log_mustnot + fi + + for fs in ${filesystems[@]}; do + $logfunc mounted "$TESTPOOL/$fs" + done + + return 0 +} + +log_onexit cleanup_all + +log_must setup_all + +export __ZFS_POOL_RESTRICT="$TESTPOOL" +log_must zfs $unmountall +unset __ZFS_POOL_RESTRICT + +verify_all false + +export __ZFS_POOL_RESTRICT="$TESTPOOL" +log_must zfs $mountall +unset __ZFS_POOL_RESTRICT + +verify_all true + +log_note "Verify that 'zfs $mountcmd' will display " \ + "all ZFS filesystems currently mounted." + +verify_mount_display + +log_pass "'zfs $mountall' succeeds as root, " \ + "and all available ZFS filesystems are mounted." |