[PATCH 4/8] btrfs/213: make the test more reliable

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



From: Josef Bacik <josef@xxxxxxxxxxxxxx>

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.

Signed-off-by: Josef Bacik <josef@xxxxxxxxxxxxxx>
---
 check           |  6 ------
 common/rc       |  5 +++++
 tests/btrfs/213 | 20 ++++++++++----------
 3 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/check b/check
index 71b9fbd075223f..c6dba89b5b506e 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 6cbceb7ae7c6bb..9b6dfcaaeddadb 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 6def4f6ef79acf..816041a0cc2ea0 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
-- 
2.42.1





[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux