diff options
author | loli10K <[email protected]> | 2020-11-16 18:10:29 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-11-16 09:10:29 -0800 |
commit | 4072f465bc3630bbab50afccfd6c7baf41afcc4c (patch) | |
tree | 3eabc85191eb9d0fb9dd788fe1e1305596d2a728 /tests | |
parent | 2c210f68189c6f781be050bfdc890cd6dc231fea (diff) |
Fix 'zfs userspace' for received datasets in encrypted root
For encrypted receives, where user accounting is initially disabled on
creation, both 'zfs userspace' and 'zfs groupspace' fails with
EOPNOTSUPP: this is because dmu_objset_id_quota_upgrade_cb() forgets to
set OBJSET_FLAG_USERACCOUNTING_COMPLETE on the objset flags after a
successful dmu_objset_space_upgrade().
Reviewed-by: Brian Behlendorf <[email protected]>
Co-authored-by: Brian Behlendorf <[email protected]>
Signed-off-by: loli10K <[email protected]>
Closes #9501
Closes #9596
Diffstat (limited to 'tests')
-rw-r--r-- | tests/runfiles/common.run | 2 | ||||
-rw-r--r-- | tests/zfs-tests/tests/functional/userquota/Makefile.am | 3 | ||||
-rwxr-xr-x | tests/zfs-tests/tests/functional/userquota/userspace_encrypted.ksh | 85 |
3 files changed, 88 insertions, 2 deletions
diff --git a/tests/runfiles/common.run b/tests/runfiles/common.run index c91da0a45..280537fe5 100644 --- a/tests/runfiles/common.run +++ b/tests/runfiles/common.run @@ -857,7 +857,7 @@ tests = [ 'userquota_004_pos', 'userquota_005_neg', 'userquota_006_pos', 'userquota_007_pos', 'userquota_008_pos', 'userquota_009_pos', 'userquota_010_pos', 'userquota_011_pos', 'userquota_012_neg', - 'userspace_001_pos', 'userspace_002_pos'] + 'userspace_001_pos', 'userspace_002_pos', 'userspace_encrypted'] tags = ['functional', 'userquota'] [tests/functional/vdev_zaps] diff --git a/tests/zfs-tests/tests/functional/userquota/Makefile.am b/tests/zfs-tests/tests/functional/userquota/Makefile.am index 8f0287bc1..9100e4ada 100644 --- a/tests/zfs-tests/tests/functional/userquota/Makefile.am +++ b/tests/zfs-tests/tests/functional/userquota/Makefile.am @@ -20,7 +20,8 @@ dist_pkgdata_SCRIPTS = \ userquota_013_pos.ksh \ userspace_001_pos.ksh \ userspace_002_pos.ksh \ - userspace_003_pos.ksh + userspace_003_pos.ksh \ + userspace_encrypted.ksh dist_pkgdata_DATA = \ userquota.cfg \ diff --git a/tests/zfs-tests/tests/functional/userquota/userspace_encrypted.ksh b/tests/zfs-tests/tests/functional/userquota/userspace_encrypted.ksh new file mode 100755 index 000000000..429b16e04 --- /dev/null +++ b/tests/zfs-tests/tests/functional/userquota/userspace_encrypted.ksh @@ -0,0 +1,85 @@ +#!/bin/ksh -p +# +# 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. +# + +# +# Copyright 2019, loli10K <[email protected]>. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/userquota/userquota_common.kshlib + +# +# DESCRIPTION: +# 'zfs userspace' and 'zfs groupspace' can be used on encrypted datasets +# +# +# STRATEGY: +# 1. Create both un-encrypted and encrypted datasets +# 2. Receive un-encrypted dataset in encrypted hierarchy +# 3. Verify encrypted datasets support 'zfs userspace' and 'zfs groupspace' +# + +function cleanup +{ + destroy_pool $POOLNAME + rm -f $FILEDEV +} + +function log_must_unsupported +{ + log_must_retry "unsupported" 3 "$@" + (( $? != 0 )) && log_fail +} + +log_onexit cleanup + +FILEDEV="$TEST_BASE_DIR/userspace_encrypted" +POOLNAME="testpool$$" +typeset -a POOL_OPTS=('' # all pool features enabled + '-d' # all pool features disabled + '-d -o feature@userobj_accounting=enabled' # only userobj_accounting enabled + '-d -o feature@project_quota=enabled') # only project_quota enabled +DATASET_ENCROOT="$POOLNAME/encroot" +DATASET_SENDFS="$POOLNAME/sendfs" + +log_assert "'zfs user/groupspace' should work on encrypted datasets" + +for opts in "${POOL_OPTS[@]}"; do + # Setup + truncate -s $SPA_MINDEVSIZE $FILEDEV + log_must zpool create $opts -o feature@encryption=enabled $POOLNAME \ + $FILEDEV + + # 1. Create both un-encrypted and encrypted datasets + log_must zfs create $DATASET_SENDFS + log_must eval "echo 'password' | zfs create -o encryption=on" \ + "-o keyformat=passphrase -o keylocation=prompt " \ + "$DATASET_ENCROOT" + log_must zfs create $DATASET_ENCROOT/fs + + # 2. Receive un-encrypted dataset in encrypted hierarchy + log_must zfs snap $DATASET_SENDFS@snap + log_must eval "zfs send $DATASET_SENDFS@snap | zfs recv " \ + "$DATASET_ENCROOT/recvfs" + + # 3. Verify encrypted datasets support 'zfs userspace' and + # 'zfs groupspace' + log_must zfs userspace $DATASET_ENCROOT/fs + log_must zfs groupspace $DATASET_ENCROOT/fs + log_must_unsupported zfs userspace $DATASET_ENCROOT/recvfs + log_must_unsupported zfs groupspace $DATASET_ENCROOT/recvfs + + # Cleanup + cleanup +done + +log_pass "'zfs user/groupspace' works on encrypted datasets" |