aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosef Bacik <josef@toxicpanda.com>2024-03-05 19:52:14 +0100
committerZorro Lang <zlang@kernel.org>2024-03-11 12:50:09 +0800
commite990496ffc0954943987ddf845c09591db79d189 (patch)
tree4f63465b8a9b33796bcd3000760b4710d48c4f9b
parent46bc2d68fa746b5d133815641f6263a56ef49f1d (diff)
downloadxfstests-dev-e990496ffc0954943987ddf845c09591db79d189.tar.gz
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 <anand.jain@oracle.com> Signed-off-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Anand Jain <anand.jain@oracle.com>
-rwxr-xr-xcheck6
-rw-r--r--common/rc5
-rwxr-xr-xtests/btrfs/21320
3 files changed, 15 insertions, 16 deletions
diff --git a/check b/check
index 71b9fbd075..c6dba89b5b 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 26212b153b..36cad89cfc 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 6def4f6ef7..816041a0cc 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