Skip to content

Commit

Permalink
zts: add test for log spacemap flushall + zpool condense
Browse files Browse the repository at this point in the history
Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Signed-off-by: Rob Norris <[email protected]>
  • Loading branch information
robn committed Nov 13, 2024
1 parent 94b1364 commit 0aa7b7f
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/runfiles/common.run
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ tests = ['many_fds', 'libzfs_input']
tags = ['functional', 'libzfs']

[tests/functional/log_spacemap]
tests = ['log_spacemap_import_logs']
tests = ['log_spacemap_import_logs', 'log_spacemap_flushall']
pre =
post =
tags = ['functional', 'log_spacemap']
Expand Down
1 change: 1 addition & 0 deletions tests/zfs-tests/tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -1612,6 +1612,7 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
functional/longname/longname_002_pos.ksh \
functional/longname/longname_003_pos.ksh \
functional/longname/setup.ksh \
functional/log_spacemap/log_spacemap_flushall.ksh \
functional/log_spacemap/log_spacemap_import_logs.ksh \
functional/migration/cleanup.ksh \
functional/migration/migration_001_pos.ksh \
Expand Down
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"

0 comments on commit 0aa7b7f

Please sign in to comment.