forked from openzfs/zfs
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds '-u' flag for zfs set operation. With this flag, mountpoint, sharenfs and sharesmb properties can be updated without actually mounting or sharing the dataset. Previously, if dataset was unmounted, and mountpoint property was updated, dataset was not mounted after the update. This behavior is changed in previous commit. We now mount the dataset whenever mountpoint property is updated, regardless if it's mounted or not. To provide the user with option to keep the dataset unmounted and still update the mountpoint without mounting the dataset, '-u' flag can be used. While unmounted, if sharenfs or sharesmb is set to on, this leads to mounting the dataset. If sharenfs and sharesmb properties are set with '-u' flag while dataset is unmounted, this will not mount or share the dataset, but it will set the property to desired value. When dataset is mounted, and '-u' flag is used to update any of mountpoint, sharenfs and sharesmb property/properties, the property itself is updated but no action is performed. For mountpoint property, the property is updated but dataset is still mounted at previous mountpoint. For sharenfs and sharesmb, the property is set but dataset in not shared/unshared. '-u' flag would only work if any of mountpoint, sharenfs or sharesmb is found in property list. Signed-off-by: Umer Saleem <[email protected]>
- Loading branch information
1 parent
3753ce4
commit 1ea8897
Showing
10 changed files
with
150 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_nomount.ksh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/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 (c) 2023 by iXsystems, Inc. All rights reserved. | ||
# | ||
|
||
. $STF_SUITE/include/libtest.shlib | ||
. $STF_SUITE/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib | ||
|
||
verify_runnable "both" | ||
|
||
function cleanup | ||
{ | ||
log_must zfs set sharenfs=off $TESTPOOL/$TESTFS | ||
if is_linux; then | ||
log_must zfs set sharesmb=off $TESTPOOL/$TESTFS | ||
fi | ||
rm -r $newmpt | ||
} | ||
|
||
log_assert "'zfs set -u' sets the mountpoint and share properties without " \ | ||
"mounting the dataset" | ||
log_onexit cleanup | ||
|
||
oldmpt=$(get_prop mountpoint $TESTPOOL/$TESTFS) | ||
newmpt=$TEST_BASE_DIR/abc | ||
|
||
# Test while dataset is mounted | ||
log_must ismounted $TESTPOOL/$TESTFS | ||
log_must zfs set -u mountpoint=$newmpt $TESTPOOL/$TESTFS | ||
log_must check_user_prop $TESTPOOL/$TESTFS mountpoint $newmpt | ||
log_must eval [ `$mountcmd | grep $TESTPOOL/$TESTFS | awk '{print $3}'` == $oldmpt ] | ||
log_must zfs unmount $TESTPOOL/$TESTFS | ||
log_mustnot ismounted $TESTPOOL/$TESTFS | ||
log_must zfs mount $TESTPOOL/$TESTFS | ||
log_must eval [ `$mountcmd | grep $TESTPOOL/$TESTFS | awk '{print $3}'` == $newmpt ] | ||
|
||
# Test while dataset is unmounted | ||
log_must zfs set mountpoint=$oldmpt $TESTPOOL/$TESTFS | ||
log_must ismounted $TESTPOOL/$TESTFS | ||
log_must zfs unmount $TESTPOOL/$TESTFS | ||
log_must zfs set -u mountpoint=$newmpt $TESTPOOL/$TESTFS | ||
log_mustnot ismounted $TESTPOOL/$TESTFS | ||
log_must zfs set -u sharenfs=on $TESTPOOL/$TESTFS | ||
log_mustnot ismounted $TESTPOOL/$TESTFS | ||
if is_linux; then | ||
log_must zfs set -u sharesmb=on $TESTPOOL/$TESTFS | ||
log_mustnot ismounted $TESTPOOL/$TESTFS | ||
fi | ||
logmust zfs mount $TESTPOOL/$TESTFS | ||
log_must check_user_prop $TESTPOOL/$TESTFS mountpoint $newmpt | ||
log_must eval [ `$mountcmd | grep $TESTPOOL/$TESTFS | awk '{print $3}'` == $newmpt ] | ||
|
||
log_must zfs set mountpoint=$oldmpt $TESTPOOL/$TESTFS | ||
log_must ismounted $TESTPOOL/$TESTFS | ||
|
||
log_pass "'zfs set -u' functions correctly" |