aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authoralex <[email protected]>2020-04-25 10:04:34 +0800
committerGitHub <[email protected]>2020-04-24 19:04:34 -0700
commit47c9299fcc9e5fb91d0b1636bfacc03bd3e98439 (patch)
tree77fe869258d5884888eb1e10ce6acc82fd99ab89 /tests
parentaa646323dbb61a2c3224b03c17732bd19fc50758 (diff)
zfs_create: round up volume size to multiple of bs
Round up the volume size requested in `zfs create -V size` to the next higher multiple of the volblocksize. Updates the man page and adds a test to verify the new behavior. Reviewed-by: Brian Behlendorf <[email protected]> Reported-by: puffi <[email protected]> Signed-off-by: Alex John <[email protected]> Closes #8541 Closes #10196
Diffstat (limited to 'tests')
-rw-r--r--tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create.cfg8
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_002_pos.ksh12
2 files changed, 19 insertions, 1 deletions
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create.cfg b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create.cfg
index b96908ce1..9bf25327e 100644
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create.cfg
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create.cfg
@@ -54,6 +54,12 @@ export VOL_LIMIT_KEYWORD1="1TB on 32-bit"
export VOL_LIMIT_KEYWORD2="value is too large"
export VOL_LIMIT_KEYWORD3="volume size exceeds limit"
-set -A size "8k" "8K" "1m" "1M" "1mb" "1mB" "1Mb" "1MB" "1g" "1G" \
+set -A size "8k" "8K" "35K" "1m" "1M" "1mb" "1mB" "1Mb" "1MB" "1g" "1G" \
"1p" "1P" "1z" "1Z" "1gb" "1gB" "1Gb" "1GB" "1pb" "1pB" "1Pb" \
"1PB" "1zb" "1zB" "1Zb" "1ZB"
+
+# If a datasize has a volume size that is not a multiple of the blocksize,
+# explicitly check that its size has been rounded up to the nearest multiple
+# The volume with the exact size must exist in the "size" array above
+set -A explicit_size_check "35K"
+set -A expected_rounded_size "40960"
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_002_pos.ksh
index 6f36b40bf..0218e2e16 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_002_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_002_pos.ksh
@@ -31,6 +31,7 @@
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/cli_root/zfs_create/zfs_create.cfg
+. $STF_SUITE/tests/functional/cli_root/zfs_create/zfs_create_common.kshlib
#
# DESCRIPTION:
@@ -39,6 +40,8 @@
# STRATEGY:
# 1. Create a volume in the storage pool.
# 2. Verify the volume is created correctly.
+# 3. Verify that the volume created has its volsize rounded to the nearest
+# multiple of the blocksize (in this case, the default blocksize)
#
verify_runnable "global"
@@ -76,6 +79,15 @@ while (( $j < ${#size[*]} )); do
fi
((j = j + 1))
+done
+
+typeset -i j=0
+while (( $j < ${#explicit_size_check[*]} )); do
+ propertycheck ${TESTPOOL}/${TESTVOL}${explicit_size_check[j]} \
+ volsize=${expected_rounded_size[j]} || \
+ log_fail "volsize ${size[j]} was not rounded up"
+ ((j = j + 1))
done
+
log_pass "'zfs create -s -V <size> <volume>' works as expected."