forked from openzfs/zfs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a new test to confirm that the ZSTD feature flag is activated
When the compression property on a dataset is set to zstd, the feature flag is not changed from 'enabled' to 'active' until the first block is born. If the pool is exported after `zfs set` but before a block is written then imported on a system with an older version of ZFS that does not understand ZSTD, it will cause the userland utilities to panic. Signed-off-by: Allan Jude <allanjude@freebsd.org>
- Loading branch information
Showing
2 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
Empty file modified
0
tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress_zstd.ksh
100644 → 100755
Empty file.
83 changes: 83 additions & 0 deletions
83
tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_feature_activation.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,83 @@ | ||
#!/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." | ||
|
||
featureval="$(get_pool_prop feature@zstd_compress $TESTPOOL)" | ||
|
||
[[ "$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/$TESTFS-zstd | ||
|
||
featureval="$(get_pool_prop feature@zstd_compress $TESTPOOL)" | ||
|
||
log_note "After zfs set, feature flag value is: $featureval" | ||
|
||
[[ "$featureval" == "active" ]] || | ||
log_fail "ZSTD feature flag not activated" | ||
|
||
log_must zfs destroy $TESTPOOL/$TESTFS-zstd | ||
|
||
featureval="$(get_pool_prop feature@zstd_compress $TESTPOOL)" | ||
|
||
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." |