From: Josef Bacik Date: Tue, 5 Mar 2024 18:52:14 +0000 (+0100) Subject: btrfs/213: make the test more reliable X-Git-Tag: v2024.03.17~26 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e990496ffc0954943987ddf845c09591db79d189;p=xfstests-dev.git btrfs/213: make the test more reliable This test will write for 8 seconds and then try to balance, but for some setups 8 seconds may be enough to fill the disk. Instead figure out what half the size of the disk is and write at most that many bytes, or for 8 seconds, whichever comes first. Then use the amount of time it took to do the write to determine how long we should allow the balance to continue before we attempt to cancel it. Additionally the macro is '_notrun' not '_not_run'. With this change this test now does the correct thing on my ARM CI VM. Reviewed-by: Anand Jain Signed-off-by: Josef Bacik Signed-off-by: Anand Jain --- diff --git a/check b/check index 71b9fbd0..c6dba89b 100755 --- a/check +++ b/check @@ -204,12 +204,6 @@ trim_test_list() rm -f $tmp.grep } - -_wallclock() -{ - date "+%s" -} - _timestamp() { local now=`date "+%T"` diff --git a/common/rc b/common/rc index 26212b15..36cad89c 100644 --- a/common/rc +++ b/common/rc @@ -6,6 +6,11 @@ BC="$(type -P bc)" || BC= +_wallclock() +{ + date "+%s" +} + _require_math() { if [ -z "$BC" ]; then diff --git a/tests/btrfs/213 b/tests/btrfs/213 index 6def4f6e..816041a0 100755 --- a/tests/btrfs/213 +++ b/tests/btrfs/213 @@ -31,23 +31,23 @@ _fixed_by_kernel_commit 1dae7e0e58b4 \ _scratch_mkfs >> $seqres.full _scratch_mount -runtime=8 +max_space=$(_get_total_space $SCRATCH_MNT) +max_space=$(( max_space / 2 )) -# Create enough IO so that we need around $runtime seconds to relocate it. -# -# Here we don't want any wrapper, as we want full control of the process. -$XFS_IO_PROG -f -c "pwrite -D -b 1M 0 1024T" "$SCRATCH_MNT/file" &> /dev/null & -write_pid=$! -sleep $runtime -kill $write_pid -wait $write_pid +# Create enough IO so that we need around 8 seconds to relocate it. +start_ts=$(_wallclock) +$TIMEOUT_PROG 8s $XFS_IO_PROG -f -c "pwrite -D -b 1M 0 $max_space" \ + "$SCRATCH_MNT/file" > /dev/null 2>&1 +stop_ts=$(_wallclock) + +runtime=$(( stop_ts - start_ts )) # Unmount and mount again the fs to clear any cached data and metadata, so that # it's less likely balance has already finished when we try to cancel it below. _scratch_cycle_mount # Now balance should take at least $runtime seconds, we can cancel it at -# $runtime/2 to ensure a success cancel. +# $runtime/4 to ensure a success cancel. _run_btrfs_balance_start -d --bg "$SCRATCH_MNT" sleep $(($runtime / 4)) # It's possible that balance has already completed. It's unlikely but often