-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
zts: add test for log spacemap flushall + zpool condense
Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Signed-off-by: Rob Norris <[email protected]>
- Loading branch information
Showing
3 changed files
with
82 additions
and
1 deletion.
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
80 changes: 80 additions & 0 deletions
80
tests/zfs-tests/tests/functional/log_spacemap/log_spacemap_flushall.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,80 @@ | ||
#! /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) 2019 by Delphix. All rights reserved. | ||
# Copyright (c) 2024, Klara, Inc. | ||
# | ||
|
||
. $STF_SUITE/include/libtest.shlib | ||
|
||
# | ||
# DESCRIPTION: | ||
|
||
# This tests the on-demand "flush all spacemap logs" feature. This is the same | ||
# process is that triggered at pool export, but instead we trigger it ahead of | ||
# time via `zpool condense`. | ||
# | ||
# This test uses the `log_spacemaps` kstat and `zdb -m` to know how much is | ||
# waiting to be flushed. All we're looking for is that the flushall function | ||
# works, not how much it's doing. | ||
|
||
# | ||
# STRATEGY: | ||
# 1. Create pool. | ||
# 2. Write things, which will add to the spacemap logs. | ||
# 3. Save the counters. | ||
# 4. Request the spacemap logs be flushed. | ||
# 5. Compare counters against previous values. | ||
# | ||
|
||
verify_runnable "global" | ||
|
||
function cleanup | ||
{ | ||
if poolexists $LOGSM_POOL; then | ||
log_must zpool destroy -f $LOGSM_POOL | ||
fi | ||
} | ||
log_onexit cleanup | ||
|
||
function get_smp_length { | ||
zdb -m $LOGSM_POOL | grep smp_length | \ | ||
awk '{ sum += $3 } END { print sum }' | ||
} | ||
|
||
LOGSM_POOL="logsm_flushall" | ||
read -r TESTDISK _ <<<"$DISKS" | ||
|
||
log_must zpool create -o cachefile=none -f -O compression=off \ | ||
$LOGSM_POOL $TESTDISK | ||
|
||
log_must file_write -o create -f /$LOGSM_POOL/f1 -b 131072 -c 32 -d R | ||
log_must file_write -o create -f /$LOGSM_POOL/f2 -b 131072 -c 32 -d R | ||
log_must file_write -o create -f /$LOGSM_POOL/f3 -b 131072 -c 32 -d R | ||
log_must file_write -o create -f /$LOGSM_POOL/f4 -b 131072 -c 32 -d R | ||
|
||
sync_all_pools | ||
|
||
typeset length_1=$(get_smp_length) | ||
|
||
log_must zpool condense -t log-spacemap -w $LOGSM_POOL | ||
|
||
typeset length_2=$(get_smp_length) | ||
|
||
log_must test $length_1 -gt $length_2 | ||
|
||
log_pass "Log spacemaps on-demand flushall works" |