mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-23 02:44:41 +03:00
Add zstd support to zfs
This PR adds two new compression types, based on ZStandard: - zstd: A basic ZStandard compression algorithm Available compression. Levels for zstd are zstd-1 through zstd-19, where the compression increases with every level, but speed decreases. - zstd-fast: A faster version of the ZStandard compression algorithm zstd-fast is basically a "negative" level of zstd. The compression decreases with every level, but speed increases. Available compression levels for zstd-fast: - zstd-fast-1 through zstd-fast-10 - zstd-fast-20 through zstd-fast-100 (in increments of 10) - zstd-fast-500 and zstd-fast-1000 For more information check the man page. Implementation details: Rather than treat each level of zstd as a different algorithm (as was done historically with gzip), the block pointer `enum zio_compress` value is simply zstd for all levels, including zstd-fast, since they all use the same decompression function. The compress= property (a 64bit unsigned integer) uses the lower 7 bits to store the compression algorithm (matching the number of bits used in a block pointer, as the 8th bit was borrowed for embedded block pointers). The upper bits are used to store the compression level. It is necessary to be able to determine what compression level was used when later reading a block back, so the concept used in LZ4, where the first 32bits of the on-disk value are the size of the compressed data (since the allocation is rounded up to the nearest ashift), was extended, and we store the version of ZSTD and the level as well as the compressed size. This value is returned when decompressing a block, so that if the block needs to be recompressed (L2ARC, nop-write, etc), that the same parameters will be used to result in the matching checksum. All of the internal ZFS code ( `arc_buf_hdr_t`, `objset_t`, `zio_prop_t`, etc.) uses the separated _compress and _complevel variables. Only the properties ZAP contains the combined/bit-shifted value. The combined value is split when the compression_changed_cb() callback is called, and sets both objset members (os_compress and os_complevel). The userspace tools all use the combined/bit-shifted value. Additional notes: zdb can now also decode the ZSTD compression header (flag -Z) and inspect the size, version and compression level saved in that header. For each record, if it is ZSTD compressed, the parameters of the decoded compression header get printed. ZSTD is included with all current tests and new tests are added as-needed. Per-dataset feature flags now get activated when the property is set. If a compression algorithm requires a feature flag, zfs activates the feature when the property is set, rather than waiting for the first block to be born. This is currently only used by zstd but can be extended as needed. Portions-Sponsored-By: The FreeBSD Foundation Co-authored-by: Allan Jude <allanjude@freebsd.org> Co-authored-by: Brian Behlendorf <behlendorf1@llnl.gov> Co-authored-by: Sebastian Gottschall <s.gottschall@dd-wrt.com> Co-authored-by: Kjeld Schouten-Lebbing <kjeld@schouten-lebbing.nl> Co-authored-by: Michael Niewöhner <foss@mniewoehner.de> Signed-off-by: Allan Jude <allan@klarasystems.com> Signed-off-by: Allan Jude <allanjude@freebsd.org> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Sebastian Gottschall <s.gottschall@dd-wrt.com> Signed-off-by: Kjeld Schouten-Lebbing <kjeld@schouten-lebbing.nl> Signed-off-by: Michael Niewöhner <foss@mniewoehner.de> Closes #6247 Closes #9024 Closes #10277 Closes #10278
This commit is contained in:
committed by
Brian Behlendorf
parent
dc544aba15
commit
10b3c7f5e4
@@ -107,7 +107,7 @@ tests = ['zdb_002_pos', 'zdb_003_pos', 'zdb_004_pos', 'zdb_005_pos',
|
||||
'zdb_006_pos', 'zdb_args_neg', 'zdb_args_pos',
|
||||
'zdb_block_size_histogram', 'zdb_checksum', 'zdb_decompress',
|
||||
'zdb_display_block', 'zdb_object_range_neg', 'zdb_object_range_pos',
|
||||
'zdb_objset_id']
|
||||
'zdb_objset_id', 'zdb_decompress_zstd']
|
||||
pre =
|
||||
post =
|
||||
tags = ['functional', 'cli_root', 'zdb']
|
||||
@@ -216,7 +216,7 @@ tests = ['zfs_receive_001_pos', 'zfs_receive_002_pos', 'zfs_receive_003_pos',
|
||||
'zfs_receive_016_pos', 'receive-o-x_props_override',
|
||||
'zfs_receive_from_encrypted', 'zfs_receive_to_encrypted',
|
||||
'zfs_receive_raw', 'zfs_receive_raw_incremental', 'zfs_receive_-e',
|
||||
'zfs_receive_raw_-d']
|
||||
'zfs_receive_raw_-d', 'zfs_receive_from_zstd']
|
||||
tags = ['functional', 'cli_root', 'zfs_receive']
|
||||
|
||||
[tests/functional/cli_root/zfs_rename]
|
||||
@@ -253,7 +253,8 @@ tests = ['cache_001_pos', 'cache_002_neg', 'canmount_001_pos',
|
||||
'user_property_001_pos', 'user_property_003_neg', 'readonly_001_pos',
|
||||
'user_property_004_pos', 'version_001_neg', 'zfs_set_001_neg',
|
||||
'zfs_set_002_neg', 'zfs_set_003_neg', 'property_alias_001_pos',
|
||||
'mountpoint_003_pos', 'ro_props_001_pos', 'zfs_set_keylocation']
|
||||
'mountpoint_003_pos', 'ro_props_001_pos', 'zfs_set_keylocation',
|
||||
'zfs_set_feature_activation']
|
||||
tags = ['functional', 'cli_root', 'zfs_set']
|
||||
|
||||
[tests/functional/cli_root/zfs_share]
|
||||
@@ -537,7 +538,8 @@ tags = ['functional', 'cli_user', 'zpool_status']
|
||||
|
||||
[tests/functional/compression]
|
||||
tests = ['compress_001_pos', 'compress_002_pos', 'compress_003_pos',
|
||||
'l2arc_compressed_arc', 'l2arc_compressed_arc_disabled']
|
||||
'l2arc_compressed_arc', 'l2arc_compressed_arc_disabled',
|
||||
'l2arc_encrypted', 'l2arc_encrypted_no_compressed_arc']
|
||||
tags = ['functional', 'compression']
|
||||
|
||||
[tests/functional/cp_files]
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
typeset -a compress_prop_vals=('off' 'lzjb' 'lz4' 'gzip' 'zle')
|
||||
typeset -a compress_prop_vals=('off' 'lzjb' 'lz4' 'gzip' 'zle' 'zstd')
|
||||
typeset -a checksum_prop_vals=('on' 'off' 'fletcher2' 'fletcher4' 'sha256'
|
||||
'noparity' 'sha512' 'skein')
|
||||
if ! is_freebsd; then
|
||||
|
||||
@@ -10,6 +10,7 @@ dist_pkgdata_SCRIPTS = \
|
||||
zdb_block_size_histogram.ksh \
|
||||
zdb_checksum.ksh \
|
||||
zdb_decompress.ksh \
|
||||
zdb_decompress_zstd.ksh \
|
||||
zdb_object_range_neg.ksh \
|
||||
zdb_object_range_pos.ksh \
|
||||
zdb_display_block.ksh \
|
||||
|
||||
@@ -58,7 +58,7 @@ set -A args "create" "add" "destroy" "import fakepool" \
|
||||
"setvprop" "blah blah" "-%" "--?" "-*" "-=" \
|
||||
"-a" "-f" "-g" "-j" "-n" "-o" "-p" "-p /tmp" "-r" \
|
||||
"-t" "-w" "-z" "-E" "-H" "-I" "-J" "-K" \
|
||||
"-N" "-Q" "-R" "-T" "-W" "-Z"
|
||||
"-N" "-Q" "-R" "-T" "-W"
|
||||
|
||||
log_assert "Execute zdb using invalid parameters."
|
||||
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
#!/bin/ksh
|
||||
|
||||
#
|
||||
# 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 (c) 2020 The FreeBSD Foundation [1]
|
||||
#
|
||||
# [1] Portions of this software were developed by Allan Jude
|
||||
# under sponsorship from the FreeBSD Foundation.
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
#
|
||||
# Description:
|
||||
# zdb -Z pool <objid> will display the ZSTD compression header
|
||||
# This will contain the actual length of the compressed data, as well as
|
||||
# the version of ZSTD used to compress the block, and the compression level
|
||||
#
|
||||
# Strategy:
|
||||
# 1. Create a pool, set compression to zstd-<random level>
|
||||
# 2. Write some identifiable data to a file
|
||||
# 3. Run zdb -Zddddddbbbbbb against the file
|
||||
# 4. Record the DVA, lsize, and psize, and ZSTD header of L0 block 0
|
||||
# 5. Check that the ZSTD length is less than psize
|
||||
# 6. Check that the ZSTD level matches the level we requested
|
||||
# 7. Run zdb -R with :dr flags and confirm the size and content match
|
||||
#
|
||||
|
||||
function cleanup
|
||||
{
|
||||
datasetexists $TESTPOOL && destroy_pool $TESTPOOL
|
||||
}
|
||||
|
||||
log_assert "Verify zdb -Z (read ZSTD header) works as expected"
|
||||
log_onexit cleanup
|
||||
src_data="$STF_SUITE/tests/functional/cli_root/zfs_receive/zstd_test_data.txt"
|
||||
init_data=$TESTDIR/file1
|
||||
write_count=128
|
||||
blksize=131072
|
||||
verify_runnable "global"
|
||||
verify_disk_count "$DISKS" 2
|
||||
random_level=$((RANDOM%19 + 1))
|
||||
|
||||
default_mirror_setup_noexit $DISKS
|
||||
log_must zfs set recordsize=$blksize $TESTPOOL/$TESTFS
|
||||
log_must zfs set compression=zstd-$random_level $TESTPOOL/$TESTFS
|
||||
|
||||
# write the 1k of text 128 times
|
||||
for i in {1..$write_count}
|
||||
do
|
||||
cat $src_data >> $init_data
|
||||
done
|
||||
|
||||
sync_pool $TESTPOOL true
|
||||
|
||||
# get object number of file
|
||||
listing=$(ls -i $init_data)
|
||||
set -A array $listing
|
||||
obj=${array[0]}
|
||||
log_note "file $init_data has object number $obj"
|
||||
|
||||
output=$(zdb -Zddddddbbbbbb $TESTPOOL/$TESTFS $obj 2> /dev/null \
|
||||
|grep -m 1 "L0 DVA" |head -n1)
|
||||
dva=$(sed -Ene 's/^.+DVA\[0\]=<([^>]+)>.*$/\1/p' <<< "$output")
|
||||
log_note "block 0 of $init_data has a DVA of $dva"
|
||||
|
||||
# use the length reported by zdb -ddddddbbbbbb
|
||||
size_str=$(sed -Ene 's/^.+ size=([^ ]+) .*$/\1/p' <<< "$output")
|
||||
# convert sizes to decimal
|
||||
lsize=$(echo $size_str |awk '{split($0,array,"/")} END{print array[1]}')
|
||||
lsize_orig=$lsize
|
||||
lsize=${lsize%?}
|
||||
lsize_bytes=$((16#$lsize))
|
||||
psize=$(echo $size_str |awk '{split($0,array,"/")} END{print array[2]}')
|
||||
psize_orig=$psize
|
||||
psize=${psize%?}
|
||||
psize_bytes=$((16#$psize))
|
||||
log_note "block size $size_str"
|
||||
|
||||
# Get the ZSTD header reported by zdb -Z
|
||||
zstd_str=$(sed -Ene 's/^.+ ZSTD:size=([^:]+):version=([^:]+):level=([^:]+):.*$/\1:\2:\3/p' <<< "$output")
|
||||
zstd_size=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[1]}')
|
||||
log_note "ZSTD compressed size $zstd_size"
|
||||
(( $psize_bytes < $zstd_size )) && log_fail \
|
||||
"zdb -Z failed: physical block size was less than header content length ($psize_bytes < $zstd_size)"
|
||||
|
||||
zstd_version=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[2]}')
|
||||
log_note "ZSTD version $zstd_version"
|
||||
|
||||
zstd_level=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[3]}')
|
||||
log_note "ZSTD level $zstd_level"
|
||||
(( $zstd_level != $random_level )) && log_fail \
|
||||
"zdb -Z failed: compression level did not match header level ($zstd_level < $random_level)"
|
||||
|
||||
vdev=$(echo "$dva" |awk '{split($0,array,":")} END{print array[1]}')
|
||||
offset=$(echo "$dva" |awk '{split($0,array,":")} END{print array[2]}')
|
||||
# Check the first 1024 bytes
|
||||
output=$(ZDB_NO_ZLE="true" zdb -R $TESTPOOL $vdev:$offset:$size_str:dr 2> /dev/null)
|
||||
outsize=$(wc -c <<< "$output")
|
||||
(( $outsize != $blksize )) && log_fail \
|
||||
"zdb -Z failed to decompress the data to the expected length ($outsize != $lsize_bytes)"
|
||||
cmp $init_data - <<< "$output"
|
||||
(( $? != 0 )) && log_fail "zdb -R :dr failed to decompress the data properly"
|
||||
|
||||
log_pass "zdb -Z flag (ZSTD compression header) works as expected"
|
||||
@@ -20,8 +20,12 @@ dist_pkgdata_SCRIPTS = \
|
||||
zfs_receive_016_pos.ksh \
|
||||
receive-o-x_props_override.ksh \
|
||||
zfs_receive_from_encrypted.ksh \
|
||||
zfs_receive_from_zstd.ksh \
|
||||
zfs_receive_to_encrypted.ksh \
|
||||
zfs_receive_raw.ksh \
|
||||
zfs_receive_raw_incremental.ksh \
|
||||
zfs_receive_raw_-d.ksh \
|
||||
zfs_receive_-e.ksh
|
||||
|
||||
dist_pkgdata_DATA = \
|
||||
zstd_test_data.txt
|
||||
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
#!/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) 2020 The FreeBSD Foundation [1]
|
||||
#
|
||||
# [1] Portions of this software were developed by Allan Jude
|
||||
# under sponsorship from the FreeBSD Foundation.
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# ZFS should receive a ZSTD compressed block and be able to determine the level
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Create a ZSTD compressed dataset (random level)
|
||||
# 2. Create and checksum a file on the compressed dataset
|
||||
# 3. Snapshot the compressed dataset
|
||||
# 4. Attempt to receive the snapshot into a new dataset
|
||||
# 5. Verify the checksum of the file is the same as the original
|
||||
# 6. Verify the compression level is correctly stored
|
||||
#
|
||||
|
||||
verify_runnable "both"
|
||||
|
||||
function cleanup
|
||||
{
|
||||
datasetexists $TESTPOOL/$TESTFS1 && \
|
||||
log_must zfs destroy -r $TESTPOOL/$TESTFS1
|
||||
|
||||
datasetexists $TESTPOOL/$TESTFS2 && \
|
||||
log_must zfs destroy -r $TESTPOOL/$TESTFS2
|
||||
}
|
||||
|
||||
log_onexit cleanup
|
||||
|
||||
log_assert "ZFS should track compression level when receiving a ZSTD stream"
|
||||
|
||||
typeset src_data="$STF_SUITE/tests/functional/cli_root/zfs_receive/zstd_test_data.txt"
|
||||
typeset snap="$TESTPOOL/$TESTFS1@snap"
|
||||
|
||||
random_level=$((RANDOM%19 + 1))
|
||||
log_note "Randomly selected ZSTD level: $random_level"
|
||||
|
||||
log_must zfs create -o compress=zstd-$random_level $TESTPOOL/$TESTFS1
|
||||
# Make a 5kb compressible file
|
||||
log_must cat $src_data $src_data $src_data $src_data $src_data \
|
||||
> /$TESTPOOL/$TESTFS1/$TESTFILE0
|
||||
typeset checksum=$(md5digest /$TESTPOOL/$TESTFS1/$TESTFILE0)
|
||||
|
||||
log_must zfs snapshot $snap
|
||||
|
||||
# get object number of file
|
||||
listing=$(ls -i /$TESTPOOL/$TESTFS1/$TESTFILE0)
|
||||
set -A array $listing
|
||||
obj=${array[0]}
|
||||
log_note "file /$TESTPOOL/$TESTFS1/$TESTFILE0 has object number $obj"
|
||||
|
||||
output=$(zdb -Zddddddbbbbbb $TESTPOOL/$TESTFS1 $obj 2> /dev/null \
|
||||
|grep -m 1 "L0 DVA" |head -n1)
|
||||
dva=$(sed -Ene 's/^.+DVA\[0\]=<([^>]+)>.*$/\1/p' <<< "$output")
|
||||
log_note "block 0 of /$TESTPOOL/$TESTFS1/$TESTFILE0 has a DVA of $dva"
|
||||
|
||||
zstd_str=$(sed -Ene 's/^.+ ZSTD:size=([^:]+):version=([^:]+):level=([^:]+):.*$/\1:\2:\3/p' <<< "$output")
|
||||
zstd_size1=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[1]}')
|
||||
zstd_version1=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[2]}')
|
||||
zstd_level1=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[3]}')
|
||||
log_note "ZSTD src: size=$zstd_size1 version=$zstd_version1 level=$zstd_level1"
|
||||
|
||||
log_note "Verify ZFS can receive the ZSTD compressed stream"
|
||||
log_must eval "zfs send -ec $snap | zfs receive $TESTPOOL/$TESTFS2"
|
||||
|
||||
typeset cksum1=$(md5digest /$TESTPOOL/$TESTFS2/$TESTFILE0)
|
||||
[[ "$cksum1" == "$checksum" ]] || \
|
||||
log_fail "Checksums differ ($cksum1 != $checksum)"
|
||||
|
||||
# get object number of file
|
||||
listing=$(ls -i /$TESTPOOL/$TESTFS2/$TESTFILE0)
|
||||
set -A array $listing
|
||||
obj=${array[0]}
|
||||
log_note "file /$TESTPOOL/$TESTFS2/$TESTFILE0 has object number $obj"
|
||||
|
||||
output=$(zdb -Zddddddbbbbbb $TESTPOOL/$TESTFS2 $obj 2> /dev/null \
|
||||
|grep -m 1 "L0 DVA" |head -n1)
|
||||
dva=$(sed -Ene 's/^.+DVA\[0\]=<([^>]+)>.*$/\1/p' <<< "$output")
|
||||
log_note "block 0 of /$TESTPOOL/$TESTFS2/$TESTFILE0 has a DVA of $dva"
|
||||
|
||||
zstd_str=$(sed -Ene 's/^.+ ZSTD:size=([^:]+):version=([^:]+):level=([^:]+):.*$/\1:\2:\3/p' <<< "$output")
|
||||
zstd_size2=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[1]}')
|
||||
(( $zstd_size2 != $zstd_size1 )) && log_fail \
|
||||
"ZFS recv failed: compressed size differs ($zstd_size2 != $zstd_size1)"
|
||||
zstd_version2=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[2]}')
|
||||
zstd_level2=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[3]}')
|
||||
log_note "ZSTD dest: size=$zstd_size2 version=$zstd_version2 level=$zstd_level2"
|
||||
(( $zstd_level2 != $zstd_level1 )) && log_fail \
|
||||
"ZFS recv failed: compression level did not match header level ($zstd_level2 != $zstd_level1)"
|
||||
|
||||
log_pass "ZFS can receive a ZSTD stream and determine the compression level"
|
||||
@@ -0,0 +1 @@
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim..
|
||||
@@ -28,7 +28,8 @@ dist_pkgdata_SCRIPTS = \
|
||||
zfs_set_001_neg.ksh \
|
||||
zfs_set_002_neg.ksh \
|
||||
zfs_set_003_neg.ksh \
|
||||
zfs_set_keylocation.ksh
|
||||
zfs_set_keylocation.ksh \
|
||||
zfs_set_feature_activation.ksh
|
||||
|
||||
dist_pkgdata_DATA = \
|
||||
zfs_set_common.kshlib
|
||||
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
#!/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 http://www.opensolaris.org/os/licensing.
|
||||
# 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) 2020 The FreeBSD Foundation [1]
|
||||
#
|
||||
# [1] Portions of this software were developed by Allan Jude
|
||||
# under sponsorship from the FreeBSD Foundation.
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Setting the compression property to any of the zstd levels should activate
|
||||
# the zstd feature flag. Destroying the last dataset using the zstd feature flag
|
||||
# should revert the feature to the 'enabled' state.
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Create pool, then create a file system within it.
|
||||
# 2. Check that the zstd feature flag is 'enabled'.
|
||||
# 3. Setting the compression property to zstd.
|
||||
# 4. Check that the zstd feature flag is now 'active'.
|
||||
# 5. Destroy the dataset
|
||||
# 6. Confirm that the feature flag reverts to the 'enabled' state.
|
||||
#
|
||||
|
||||
verify_runnable "both"
|
||||
|
||||
log_assert "Setting compression=zstd should activate the"\
|
||||
"org.freebsd:zstd_compress feature flag, and destroying the last"\
|
||||
"dataset using that property, should revert the feature flag to"\
|
||||
"the enabled state."
|
||||
|
||||
export VDEV_ZSTD="$TEST_BASE_DIR/vdev-zstd"
|
||||
|
||||
function cleanup
|
||||
{
|
||||
if poolexists $TESTPOOL-zstd ; then
|
||||
destroy_pool $TESTPOOL-zstd
|
||||
fi
|
||||
|
||||
rm $VDEV_ZSTD
|
||||
}
|
||||
log_onexit cleanup
|
||||
|
||||
log_must truncate -s $SPA_MINDEVSIZE $VDEV_ZSTD
|
||||
log_must zpool create $TESTPOOL-zstd $VDEV_ZSTD
|
||||
|
||||
featureval="$(get_pool_prop feature@zstd_compress $TESTPOOL-zstd)"
|
||||
|
||||
[[ "$featureval" == "disabled" ]] && \
|
||||
log_unsupported "ZSTD feature flag unsupposed"
|
||||
|
||||
[[ "$featureval" == "active" ]] && \
|
||||
log_unsupported "ZSTD feature already active before test"
|
||||
|
||||
random_level=$((RANDOM%19 + 1))
|
||||
log_note "Randomly selected ZSTD level: $random_level"
|
||||
|
||||
log_must zfs create -o compress=zstd-$random_level $TESTPOOL-zstd/$TESTFS-zstd
|
||||
|
||||
featureval="$(get_pool_prop feature@zstd_compress $TESTPOOL-zstd)"
|
||||
|
||||
log_note "After zfs set, feature flag value is: $featureval"
|
||||
|
||||
[[ "$featureval" == "active" ]] ||
|
||||
log_fail "ZSTD feature flag not activated"
|
||||
|
||||
log_must zfs destroy $TESTPOOL-zstd/$TESTFS-zstd
|
||||
|
||||
featureval="$(get_pool_prop feature@zstd_compress $TESTPOOL-zstd)"
|
||||
|
||||
log_note "After zfs destroy, feature flag value is: $featureval"
|
||||
|
||||
[[ "$featureval" == "enabled" ]] ||
|
||||
log_fail "ZSTD feature flag not deactivated"
|
||||
|
||||
log_pass "Setting compression=zstd activated the feature flag, and"\
|
||||
"destroying the dataset deactivated it."
|
||||
@@ -93,6 +93,7 @@ if is_linux || is_freebsd; then
|
||||
"feature@resilver_defer"
|
||||
"feature@bookmark_v2"
|
||||
"feature@livelist"
|
||||
"feature@zstd_compress"
|
||||
)
|
||||
fi
|
||||
|
||||
|
||||
@@ -7,7 +7,9 @@ dist_pkgdata_SCRIPTS = \
|
||||
compress_003_pos.ksh \
|
||||
compress_004_pos.ksh \
|
||||
l2arc_compressed_arc.ksh \
|
||||
l2arc_compressed_arc_disabled.ksh
|
||||
l2arc_compressed_arc_disabled.ksh \
|
||||
l2arc_encrypted.ksh \
|
||||
l2arc_encrypted_no_compressed_arc.ksh
|
||||
|
||||
dist_pkgdata_DATA = \
|
||||
compress.cfg
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
#!/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) 2020 The FreeBSD Foundation [1]
|
||||
#
|
||||
# [1] Portions of this software were developed by Allan Jude
|
||||
# under sponsorship from the FreeBSD Foundation.
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
export SIZE=1G
|
||||
export VDIR=$TESTDIR/disk.persist_l2arc
|
||||
export VDEV="$VDIR/a"
|
||||
export VDEV_CACHE="$VDIR/b"
|
||||
export PASSPHRASE="password"
|
||||
|
||||
# fio options
|
||||
export DIRECTORY=/$TESTPOOL-l2arc/encrypted
|
||||
export NUMJOBS=4
|
||||
export RUNTIME=30
|
||||
export PERF_RANDSEED=1234
|
||||
export PERF_COMPPERCENT=66
|
||||
export PERF_COMPCHUNK=0
|
||||
export BLOCKSIZE=128K
|
||||
export SYNC_TYPE=0
|
||||
export DIRECT=1
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# System with compressed_arc disabled succeeds at reading from L2ARC
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Enable compressed_arc.
|
||||
# 2. Create pool with a cache device, encryption, and compression enabled.
|
||||
# 3. Read the number of L2ARC checksum failures.
|
||||
# 4. Create a random file in that pool and random read for 30 sec.
|
||||
# 5. Read the number of L2ARC checksum failures.
|
||||
#
|
||||
|
||||
verify_runnable "global"
|
||||
|
||||
log_assert "L2ARC with encryption enabled succeeds."
|
||||
|
||||
origin_carc_setting=$(get_tunable COMPRESSED_ARC_ENABLED)
|
||||
|
||||
function cleanup
|
||||
{
|
||||
if poolexists $TESTPOOL-l2arc ; then
|
||||
destroy_pool $TESTPOOL-l2arc
|
||||
fi
|
||||
|
||||
log_must set_tunable64 COMPRESSED_ARC_ENABLED $origin_carc_setting
|
||||
}
|
||||
log_onexit cleanup
|
||||
|
||||
# Enable Compressed ARC so that in-ARC and on-disk will match
|
||||
log_must set_tunable64 COMPRESSED_ARC_ENABLED 1
|
||||
|
||||
log_must rm -rf $VDIR
|
||||
log_must mkdir -p $VDIR
|
||||
log_must mkfile $SIZE $VDEV
|
||||
|
||||
typeset fill_mb=800
|
||||
typeset cache_sz=$(( floor($fill_mb / 2) ))
|
||||
export FILE_SIZE=$(( floor($fill_mb / $NUMJOBS) ))M
|
||||
|
||||
log_must truncate -s ${cache_sz}M $VDEV_CACHE
|
||||
|
||||
log_must zpool create -O compression=zstd -f $TESTPOOL-l2arc $VDEV cache $VDEV_CACHE
|
||||
|
||||
log_must eval "echo $PASSPHRASE | zfs create -o compression=zstd " \
|
||||
"-o encryption=on -o keyformat=passphrase -o keylocation=prompt " \
|
||||
"$TESTPOOL-l2arc/encrypted"
|
||||
|
||||
l2_cksum_bad_start=$(get_arcstat l2_cksum_bad)
|
||||
|
||||
log_must fio $FIO_SCRIPTS/mkfiles.fio
|
||||
log_must fio $FIO_SCRIPTS/random_reads.fio
|
||||
|
||||
l2_cksum_bad_end=$(get_arcstat l2_cksum_bad)
|
||||
|
||||
log_note "L2ARC Failed Checksums before: $l2_cksum_bad_start After:"\
|
||||
"$l2_cksum_bad_end"
|
||||
log_must test $(( $l2_cksum_bad_end - $l2_cksum_bad_start )) -eq 0
|
||||
|
||||
log_must zpool destroy -f $TESTPOOL-l2arc
|
||||
|
||||
log_pass "L2ARC with encryption and compressed_arc enabled does not result in"\
|
||||
"checksum errors."
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
#!/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) 2020 The FreeBSD Foundation [1]
|
||||
#
|
||||
# [1] Portions of this software were developed by Allan Jude
|
||||
# under sponsorship from the FreeBSD Foundation.
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
export SIZE=1G
|
||||
export VDIR=$TESTDIR/disk.persist_l2arc
|
||||
export VDEV="$VDIR/a"
|
||||
export VDEV_CACHE="$VDIR/b"
|
||||
export PASSPHRASE="password"
|
||||
|
||||
# fio options
|
||||
export DIRECTORY=/$TESTPOOL-l2arc/encrypted
|
||||
export NUMJOBS=4
|
||||
export RUNTIME=30
|
||||
export PERF_RANDSEED=1234
|
||||
export PERF_COMPPERCENT=66
|
||||
export PERF_COMPCHUNK=0
|
||||
export BLOCKSIZE=128K
|
||||
export SYNC_TYPE=0
|
||||
export DIRECT=1
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# System with compressed_arc disabled succeeds at reading from L2ARC
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Disable compressed_arc.
|
||||
# 2. Create pool with a cache device, encryption, and compression enabled.
|
||||
# 3. Read the number of L2ARC checksum failures.
|
||||
# 4. Create a random file in that pool and random read for 30 sec.
|
||||
# 5. Read the number of L2ARC checksum failures.
|
||||
#
|
||||
|
||||
verify_runnable "global"
|
||||
|
||||
log_assert "L2ARC with compressed_arc disabled succeeds."
|
||||
|
||||
origin_carc_setting=$(get_tunable COMPRESSED_ARC_ENABLED)
|
||||
|
||||
function cleanup
|
||||
{
|
||||
if poolexists $TESTPOOL-l2arc ; then
|
||||
destroy_pool $TESTPOOL-l2arc
|
||||
fi
|
||||
|
||||
log_must set_tunable64 COMPRESSED_ARC_ENABLED $origin_carc_setting
|
||||
}
|
||||
log_onexit cleanup
|
||||
|
||||
log_must rm -rf $VDIR
|
||||
log_must mkdir -p $VDIR
|
||||
log_must mkfile $SIZE $VDEV
|
||||
|
||||
# Disable Compressed ARC so that in-ARC and on-disk will not match
|
||||
log_must set_tunable64 COMPRESSED_ARC_ENABLED 0
|
||||
|
||||
typeset fill_mb=800
|
||||
typeset cache_sz=$(( floor($fill_mb / 2) ))
|
||||
export FILE_SIZE=$(( floor($fill_mb / $NUMJOBS) ))M
|
||||
|
||||
log_must truncate -s ${cache_sz}M $VDEV_CACHE
|
||||
|
||||
log_must zpool create -O compression=zstd -f $TESTPOOL-l2arc $VDEV cache $VDEV_CACHE
|
||||
|
||||
log_must eval "echo $PASSPHRASE | zfs create -o compression=zstd " \
|
||||
"-o encryption=on -o keyformat=passphrase -o keylocation=prompt " \
|
||||
"$TESTPOOL-l2arc/encrypted"
|
||||
|
||||
l2_cksum_bad_start=$(get_arcstat l2_cksum_bad)
|
||||
|
||||
log_must fio $FIO_SCRIPTS/mkfiles.fio
|
||||
log_must fio $FIO_SCRIPTS/random_reads.fio
|
||||
|
||||
l2_cksum_bad_end=$(get_arcstat l2_cksum_bad)
|
||||
|
||||
log_note "L2ARC Failed Checksums before: $l2_cksum_bad_start After:"\
|
||||
"$l2_cksum_bad_end"
|
||||
log_must test $(( $l2_cksum_bad_end - $l2_cksum_bad_start )) -eq 0
|
||||
|
||||
log_must zpool destroy -f $TESTPOOL-l2arc
|
||||
|
||||
log_pass "L2ARC with encryption enabled and compressed_arc disabled does not"\
|
||||
"result in checksum errors."
|
||||
@@ -86,7 +86,9 @@ props=(
|
||||
canmount off canmount on
|
||||
xattr on xattr off
|
||||
compression gzip compression gzip-$((RANDOM%9 + 1))
|
||||
copies $((RANDOM%3 + 1))
|
||||
compression zstd compression zstd-$((RANDOM%9 + 1))
|
||||
compression zstd-fast copies $((RANDOM%3 + 1))
|
||||
compression zstd-fast-$((RANDOM%9 + 1))
|
||||
)
|
||||
elif is_freebsd; then
|
||||
# property value property value
|
||||
@@ -111,7 +113,9 @@ props=(
|
||||
aclinherit secure aclinherit passthrough
|
||||
canmount off canmount on
|
||||
compression gzip compression gzip-$((RANDOM%9 + 1))
|
||||
copies $((RANDOM%3 + 1))
|
||||
compression zstd compression zstd-$((RANDOM%9 + 1))
|
||||
compression zstd-fast copies $((RANDOM%3 + 1))
|
||||
compression zstd-fast-$((RANDOM%9 + 1))
|
||||
)
|
||||
else
|
||||
# property value property value
|
||||
|
||||
Reference in New Issue
Block a user