Updated/added documentation & tests for the changes to `zfs mount -a`

zfs-mount.8:
- Updated usage and documentation for the changes to `zfs mount`

common.run:
- Added `zfs_mount_all_002_pos`

Makefile.am:
- Added `functional/cli_root/zfs_mount/zfs_mount_all_002_pos.ksh`

zfs_mount_009_neg.ksh:
- Corrected comment spacing.
- Removed negative check for `-a filesystem`.
- Added negative check for mounting multiple specified filesystems.

zfs_mount_011_neg.ksh:
- Removed negative check for `-a filesystem` and `-A`.

zfs_mount_all_001_pos.ksh:
- Corrected comment spacing.

zfs_mount_all_002_pos.ksh:
- Checks that only the specified filesystem and its children are
  mounted.

Signed-off-by: QORTEC <lowell.bv@gmail.com>
This commit is contained in:
QORTEC 2023-10-10 17:54:19 -04:00
parent a1295cd96a
commit e07de81c28
7 changed files with 228 additions and 13 deletions

View File

@ -43,7 +43,7 @@
.Cm mount
.Op Fl Oflv
.Op Fl o Ar options
.Fl a Ns | Ns Ar filesystem
.Fl a Oo filesystem Oc | Oo Fl A Oc Ar filesystem
.Nm zfs
.Cm unmount
.Op Fl fu
@ -61,7 +61,7 @@ Displays all ZFS file systems currently mounted.
.Cm mount
.Op Fl Oflv
.Op Fl o Ar options
.Fl a Ns | Ns Ar filesystem
.Fl a Oo filesystem Oc | Oo Fl A Oc Ar filesystem
.Xc
Mount ZFS filesystem on a path described by its
.Sy mountpoint
@ -80,9 +80,13 @@ Allows mounting in non-empty
See
.Xr mount 8
for more information.
.It Fl a
Mount all available ZFS file systems.
Invoked automatically as part of the boot process if configured.
.It Fl a Op filesystem
Mount the specified filesystem and its children, provided they are available.
If no filesystem is specified, then all available ZFS file systems are mounted;
may be invoked automatically as part of the boot process if configured.
.It Fl A Ar filesystem
Mount the specified filesystem and its children, provided they are available.
Note: datasets with the `canmount=noauto` property will also be mounted.
.It Ar filesystem
Mount the specified filesystem.
.It Fl o Ar options

View File

@ -212,9 +212,9 @@ 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_pos', 'zfs_mount_all_001_pos', 'zfs_mount_encrypted',
'zfs_mount_remount', 'zfs_mount_all_fail', 'zfs_mount_all_mountpoints',
'zfs_mount_test_race']
'zfs_mount_012_pos', 'zfs_mount_all_001_pos', 'zfs_mount_all_002_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']
[tests/functional/cli_root/zfs_program]

View File

@ -739,6 +739,7 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
functional/cli_root/zfs_mount/zfs_mount_013_pos.ksh \
functional/cli_root/zfs_mount/zfs_mount_014_neg.ksh \
functional/cli_root/zfs_mount/zfs_mount_all_001_pos.ksh \
functional/cli_root/zfs_mount/zfs_mount_all_002_pos.ksh \
functional/cli_root/zfs_mount/zfs_mount_all_fail.ksh \
functional/cli_root/zfs_mount/zfs_mount_all_mountpoints.ksh \
functional/cli_root/zfs_mount/zfs_mount_encrypted.ksh \

View File

@ -36,7 +36,7 @@
# DESCRIPTION:
# Try each 'zfs mount' with inapplicable scenarios to make sure
# it returns an error. include:
# * '-a', but also with a specific filesystem.
# * Multiple filesystems specified
#
# STRATEGY:
# 1. Create an array of parameters
@ -53,7 +53,8 @@ for fs in $multifs ; do
datasets="$datasets $TESTPOOL/$fs"
done
set -A args "$mountall $TESTPOOL/$TESTFS"
set -A args "$mountall $datasets" \
"$mountcmd $datasets"
function setup_all
{

View File

@ -57,7 +57,7 @@ log_assert "zfs mount fails with bad parameters"
log_onexit cleanup
fs=$TESTPOOL/$TESTFS
set -A badargs "A" "-A" "-" "-x" "-?" "=" "-o *" "-a"
set -A badargs "A" "-" "-x" "-?" "=" "-o *"
for arg in "${badargs[@]}"; do
log_mustnot eval "zfs mount $arg $fs >/dev/null 2>&1"

View File

@ -40,8 +40,8 @@
# 2. Create zfs filesystems within the given pools.
# 3. Unmount all the filesystems.
# 4. Verify that 'zfs mount -a' command succeed,
# and all available ZFS filesystems are mounted.
# 5. Verify that 'zfs mount' is identical with 'df -F zfs'
# and all available ZFS filesystems are mounted.
# 5. Verify that 'zfs mount' is identical with 'df -F zfs'
#
verify_runnable "both"

View File

@ -0,0 +1,209 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or https://opensource.org/licenses/CDDL-1.0.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2016 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 filesystem' succeeds as root.
#
# STRATEGY:
# 1. Create a group of pools with specified vdev.
# 2. Create zfs filesystems within the given pools.
# 3. Unmount all the filesystems.
# 4. Verify that 'zfs mount -a filesystem' command succeed,
# and the related available ZFS filesystems are mounted,
# and the unrelated ZFS filesystems remain unmounted
# 5. Verify that 'zfs mount' is identical with 'df -F zfs'
#
verify_runnable "both"
set -A fs "$TESTFS" "$TESTFS1"
set -A ctr "" "$TESTCTR" "$TESTCTR/$TESTCTR1" "$TESTCTR1"
set -A vol "$TESTVOL" "$TESTVOL1"
# Test the mounted state of root dataset (testpool/testctr)
typeset mnt=$TESTCTR
function setup_all
{
typeset -i i=0
typeset -i j=0
typeset path
while (( i < ${#ctr[*]} )); do
path=${TEST_BASE_DIR%%/}/testroot$$/$TESTPOOL
if [[ -n ${ctr[i]} ]]; then
path=$path/${ctr[i]}
setup_filesystem "$DISKS" "$TESTPOOL" \
"${ctr[i]}" "$path" \
"ctr"
fi
if is_global_zone ; then
j=0
while (( j < ${#vol[*]} )); do
setup_filesystem "$DISKS" "$TESTPOOL" \
"${ctr[i]}/${vol[j]}" \
"$path/${vol[j]}" \
"vol"
((j = j + 1))
done
fi
j=0
while (( j < ${#fs[*]} )); do
setup_filesystem "$DISKS" "$TESTPOOL" \
"${ctr[i]}/${fs[j]}" \
"$path/${fs[j]}"
((j = j + 1))
done
((i = i + 1))
done
return 0
}
function cleanup_all
{
typeset -i i=0
typeset -i j=0
typeset path
((i = ${#ctr[*]} - 1))
while (( i >= 0 )); do
if is_global_zone ; then
j=0
while (( j < ${#vol[*]} )); do
cleanup_filesystem "$TESTPOOL" \
"${ctr[i]}/${vol[j]}"
((j = j + 1))
done
fi
j=0
while (( j < ${#fs[*]} )); do
cleanup_filesystem "$TESTPOOL" \
"${ctr[i]}/${fs[j]}"
((j = j + 1))
done
[[ -n ${ctr[i]} ]] && \
cleanup_filesystem "$TESTPOOL" "${ctr[i]}"
((i = i - 1))
done
[[ -d ${TEST_BASE_DIR%%/}/testroot$$ ]] && \
rm -rf ${TEST_BASE_DIR%%/}/testroot$$
}
#
# This function takes a single true/false argument:
# - true: it verifies that the $mnt file system is mounted.
# - false: it verifies that the $mnt file system is unmounted.
#
# In both scenarios, it ensures that the file systems in fs remain unmounted.
#
function verify_related
{
typeset -i i=0
typeset -i j=0
typeset path
typeset logfunc
while (( i < ${#ctr[*]} )); do
if $1 && { [[ ${ctr[i]} == $mnt ]] || [[ ${ctr[i]} == $mnt/* ]] }; then
logfunc=log_must
else
logfunc=log_mustnot
fi
path=$TESTPOOL
[[ -n ${ctr[i]} ]] && \
path=$path/${ctr[i]}
if is_global_zone ; then
j=0
while (( j < ${#vol[*]} )); do
log_mustnot mounted "$path/${vol[j]}"
((j = j + 1))
done
fi
j=0
while (( j < ${#fs[*]} )); do
$logfunc mounted "$path/${fs[j]}"
((j = j + 1))
done
$logfunc mounted "$path"
((i = i + 1))
done
return 0
}
log_assert "Verify that 'zfs $mountall $TESTPOOL/$mnt' succeeds as root, " \
"and all the related available ZFS filesystems are mounted."
log_onexit cleanup_all
log_must setup_all
export __ZFS_POOL_RESTRICT="$TESTPOOL"
log_must zfs $unmountall
unset __ZFS_POOL_RESTRICT
verify_related false
export __ZFS_POOL_RESTRICT="$TESTPOOL"
log_must zfs $mountall $TESTPOOL/$mnt
unset __ZFS_POOL_RESTRICT
verify_related true
log_note "Verify that 'zfs $mountcmd' will display " \
"all available ZFS filesystems related to '$TESTPOOL/$mnt' are mounted."
verify_mount_display
log_pass "'zfs $mountall $TESTPOOL/$mnt' succeeds as root, " \
"and all the related available ZFS filesystems are mounted."