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 <seb@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com>
Reviewed by: Brad Lewis <brad.lewis@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: Prashanth Sreenivasa <pks@delphix.com>
Authored by: Brian Behlendorf <behlendorf1@llnl.gov>
Approved by: Matt Ahrens <mahrens@delphix.com>
Ported-by: Don Brady <don.brady@delphix.com>

OpenZFS-issue: https://www.illumos.org/issues/8115
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/a3f0e2b569
Closes #8092
This commit is contained in:
Sebastien Roy
2018-11-05 08:40:05 -07:00
committed by Brian Behlendorf
parent af2e8411da
commit a10d50f999
10 changed files with 718 additions and 141 deletions
+1 -1
View File
@@ -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]
@@ -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
@@ -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
@@ -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."
@@ -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."