From c4545ba037f2e833d7cce04b5cded696c4296a3d Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 7 May 2026 09:12:33 -0700 Subject: [PATCH] ZTS: use 'zpool trim -w' in zpool_trim_partial.ksh Don't use trim_progress() which is racy to wait for the pool trim to complete. Instead use the wait (-w) option which is intended for this. Reviewed-by: Tino Reichardt Signed-off-by: Brian Behlendorf Closes #18496 --- .../cli_root/zpool_trim/zpool_trim_partial.ksh | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_trim/zpool_trim_partial.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_trim/zpool_trim_partial.ksh index e37f8e44c1a..a36649bc263 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_trim/zpool_trim_partial.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_trim/zpool_trim_partial.ksh @@ -73,7 +73,7 @@ log_must mkdir "$TESTDIR" log_must truncate -s $LARGESIZE "$LARGEFILE" log_must zpool create -O compression=off $TESTPOOL "$LARGEFILE" log_must mkfile $(( floor(LARGESIZE * 0.80) )) /$TESTPOOL/file -sync_all_pools +sync_pool $TESTPOOL new_size=$(du -k "$LARGEFILE" | awk '{print $1 * 1024}') log_must test $new_size -le $LARGESIZE @@ -93,12 +93,8 @@ log_must test $new_size -gt $((4 * floor(LARGESIZE * 0.70) )) # Perform a partial trim, we expect it to skip most of the new metaslabs # which have never been used and therefore do not need be trimmed. log_must set_tunable64 TRIM_METASLAB_SKIP 1 -log_must zpool trim $TESTPOOL -log_must set_tunable64 TRIM_METASLAB_SKIP 0 - -while [[ "$(trim_progress $TESTPOOL $LARGEFILE)" -lt "100" ]]; do - sleep 0.5 -done +log_must zpool trim -w $TESTPOOL +sync_pool $TESTPOOL true new_size=$(du -k "$LARGEFILE" | awk '{print $1 * 1024}') log_must test $new_size -gt $LARGESIZE @@ -106,11 +102,9 @@ log_must test $new_size -gt $LARGESIZE # Perform a full trim, all metaslabs will be trimmed the pool vdev # size will be reduced but not down to its original size due to the # space usage of the new metaslabs. -log_must zpool trim $TESTPOOL - -while [[ "$(trim_progress $TESTPOOL $LARGEFILE)" -lt "100" ]]; do - sleep 0.5 -done +log_must set_tunable64 TRIM_METASLAB_SKIP 0 +log_must zpool trim -w $TESTPOOL +sync_pool $TESTPOOL true new_size=$(du -k "$LARGEFILE" | awk '{print $1 * 1024}') log_must test $new_size -le $(( 2 * LARGESIZE))