btrfs: make all btrfs tests that exercise balance use _run_btrfs_balance_start()

In btrfs-progs v4.10 we had a behaviour change where starting a balance
operation without any filters results in a delay of 10 seconds and a
warning is printed to stdout that warns that a full balance is about to
be made and that it can be a slow operation. The new flag '--full-balance'
was added in that release to avoid the 10 seconds delay and the warning
message.

Our existing helper _run_btrfs_balance_start() uses that new balance flag
if we are running a btrfs-progs version that has it, to avoid that 10
seconds wait.

Make all existing btrfs tests that trigger balance operations use the
_run_btrfs_balance_start() helper, so that we avoid wasting time and
speed up some of the tests. In particular test btrfs/014 is now about 10x
faster and tests btrfs/060 to btrfs/064 3 to 5 times faster (depending
on the fsstress random load).

Besides speeding up many tests that do balance operations it also fixes
functional problems:

1) Since btrfs-progs v4.10 the test case btrfs/014 got broken, because
   its purpose is to run balance and snapshot creation in parallel,
   and that wasn't happening anymore because all snapshots were being
   created during the 10 seconds delay of the first balance operation,
   so balance and snapshot creation was being serialized instead of
   running in parallel.

   Fixing this test to avoid the 10 seconds delay immediately
   exposes a regression that went into kernel 5.7-rc1 which is fixed
   by the following commit

   aec7db3b13a0 ("btrfs: fix setting last_trans for reloc roots")

2) Test cases btrfs/060 to btrfs/064 now spend much more time running
   fsstress, balance and other operations in parallel, there's no
   longer intervals of 10 seconds where balance is not running
   concurrently with those other operations, making the tests a lot
   more useful again.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
This commit is contained in:
Filipe Manana
2020-04-14 17:22:42 +01:00
committed by Eryu Guan
parent af3d0c0ea9
commit 8c16b061f7
15 changed files with 19 additions and 19 deletions
+1 -1
View File
@@ -245,7 +245,7 @@ _btrfs_stress_balance()
{ {
local options=$@ local options=$@
while true; do while true; do
$BTRFS_UTIL_PROG balance start $options _run_btrfs_balance_start $options >> $seqres.full
done done
} }
+2 -2
View File
@@ -113,7 +113,7 @@ _test_add()
_fail "wipefs failed" _fail "wipefs failed"
$BTRFS_UTIL_PROG device add ${devs[$i]} $SCRATCH_MNT >> $seqres.full 2>&1 || _fail "device add failed" $BTRFS_UTIL_PROG device add ${devs[$i]} $SCRATCH_MNT >> $seqres.full 2>&1 || _fail "device add failed"
done done
$BTRFS_UTIL_PROG filesystem balance $SCRATCH_MNT >> $seqres.full 2>&1 || _fail "balance failed" _run_btrfs_balance_start $SCRATCH_MNT >> $seqres.full
_scratch_unmount _scratch_unmount
} }
@@ -159,7 +159,7 @@ _test_replace()
# in some system balance fails if there is no delay (a bug) # in some system balance fails if there is no delay (a bug)
# putting sleep 10 to work around as of now # putting sleep 10 to work around as of now
# sleep 10 # sleep 10
$BTRFS_UTIL_PROG filesystem balance $SCRATCH_MNT >> $seqres.full 2>&1 || _fail "dev balance failed" _run_btrfs_balance_start $SCRATCH_MNT >> $seqres.full
# cleaup. add the removed disk # cleaup. add the removed disk
_scratch_unmount _scratch_unmount
+1 -2
View File
@@ -56,8 +56,7 @@ _check_csum_error()
} }
$XFS_IO_PROG -f -c "falloc 0 1M" -c "pwrite 16k 8k" -c "fsync" \ $XFS_IO_PROG -f -c "falloc 0 1M" -c "pwrite 16k 8k" -c "fsync" \
$SCRATCH_MNT/foo > $seqres.full 2>&1 $SCRATCH_MNT/foo > $seqres.full 2>&1
$BTRFS_UTIL_PROG filesystem balance $SCRATCH_MNT >> $seqres.full 2>&1 || \ _run_btrfs_balance_start $SCRATCH_MNT >> $seqres.full
_fail "balance failed"
_scratch_unmount _scratch_unmount
_scratch_mount _scratch_mount
$XFS_IO_PROG -c "pread 0 1M" $SCRATCH_MNT/foo >> $seqres.full 2>&1 || \ $XFS_IO_PROG -c "pread 0 1M" $SCRATCH_MNT/foo >> $seqres.full 2>&1 || \
+1 -1
View File
@@ -27,7 +27,7 @@ _balance()
{ {
for i in $(seq 20) for i in $(seq 20)
do do
$BTRFS_UTIL_PROG balance start $SCRATCH_MNT >/dev/null _run_btrfs_balance_start $SCRATCH_MNT >> $seqres.full
done done
} }
+1 -1
View File
@@ -31,7 +31,7 @@ _cleanup()
# real QA test starts here # real QA test starts here
run_test() run_test()
{ {
$BTRFS_UTIL_PROG balance start $SCRATCH_MNT >> $seqres.full & _run_btrfs_balance_start $SCRATCH_MNT >> $seqres.full &
sleep 0.5 sleep 0.5
+1 -1
View File
@@ -47,7 +47,7 @@ _require_fs_space $SCRATCH_MNT $((2 * 1024 * 1024))
# mkfs created. We could also wait for the background kthread to automatically # mkfs created. We could also wait for the background kthread to automatically
# delete the unused block group, but we do not have a way to make it run and # delete the unused block group, but we do not have a way to make it run and
# wait for it to complete, so just do a balance instead of some unreliable sleep # wait for it to complete, so just do a balance instead of some unreliable sleep
_run_btrfs_util_prog balance start -dusage=0 $SCRATCH_MNT _run_btrfs_balance_start -dusage=0 $SCRATCH_MNT >> $seqres.full
# Now unmount the filesystem, mount it again (either with or with space caches # Now unmount the filesystem, mount it again (either with or with space caches
# enabled, it does not matter to trigger the problem) and attempt to create a # enabled, it does not matter to trigger the problem) and attempt to create a
+1 -1
View File
@@ -59,7 +59,7 @@ _run_btrfs_util_prog quota enable $SCRATCH_MNT
_run_btrfs_util_prog quota rescan -w $SCRATCH_MNT _run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
# now balance data block groups to corrupt qgroup # now balance data block groups to corrupt qgroup
_run_btrfs_util_prog balance start -d $SCRATCH_MNT _run_btrfs_balance_start -d $SCRATCH_MNT >> $seqres.full
_scratch_unmount _scratch_unmount
# qgroup will be check at _check_scratch_fs() by fstest # qgroup will be check at _check_scratch_fs() by fstest
+1 -1
View File
@@ -123,7 +123,7 @@ _run_btrfs_util_prog device scan
_scratch_mount >> $seqres.full 2>&1 _scratch_mount >> $seqres.full 2>&1
echo >> $seqres.full echo >> $seqres.full
_run_btrfs_util_prog balance start ${SCRATCH_MNT} _run_btrfs_balance_start $SCRATCH_MNT >> $seqres.full
_run_btrfs_util_prog filesystem show _run_btrfs_util_prog filesystem show
_run_btrfs_util_prog filesystem df ${SCRATCH_MNT} _run_btrfs_util_prog filesystem df ${SCRATCH_MNT}
+2 -2
View File
@@ -129,8 +129,8 @@ balance_convert()
echo echo
echo "run balance" echo "run balance"
_run_btrfs_util_prog balance start --full-balance -dconvert=raid1 \ _run_btrfs_balance_start -dconvert=raid1 \
-mconvert=raid1 ${SCRATCH_MNT} -mconvert=raid1 $SCRATCH_MNT >> $seqres.full
} }
verify() verify()
+2 -2
View File
@@ -70,14 +70,14 @@ sync
# Now we have take at least 50% of the filesystem, relocate all chunks twice # Now we have take at least 50% of the filesystem, relocate all chunks twice
# so all chunks will start after 1G in logical space. # so all chunks will start after 1G in logical space.
# (Btrfs chunk allocation will not rewind to reuse lower space) # (Btrfs chunk allocation will not rewind to reuse lower space)
_run_btrfs_util_prog balance start --full-balance "$SCRATCH_MNT" _run_btrfs_balance_start $SCRATCH_MNT >> $seqres.full
# To avoid possible false ENOSPC alert on v4.15-rc1, seems to be a # To avoid possible false ENOSPC alert on v4.15-rc1, seems to be a
# reserved space related bug (maybe related to outstanding space rework?), # reserved space related bug (maybe related to outstanding space rework?),
# but that's another story. # but that's another story.
sync sync
_run_btrfs_util_prog balance start --full-balance "$SCRATCH_MNT" _run_btrfs_balance_start $SCRATCH_MNT >> $seqres.full
# Now remove half of the files to make some holes for later trim. # Now remove half of the files to make some holes for later trim.
# While still keep the chunk space fragmented, so no chunk will be freed # While still keep the chunk space fragmented, so no chunk will be freed
+1 -1
View File
@@ -68,7 +68,7 @@ sync
before_gen=$(get_super_gen) before_gen=$(get_super_gen)
$BTRFS_UTIL_PROG balance start -m "$SCRATCH_MNT" > /dev/null _run_btrfs_balance_start -m $SCRATCH_MNT >> $seqres.full
after_gen=$(get_super_gen) after_gen=$(get_super_gen)
+1 -1
View File
@@ -53,7 +53,7 @@ for ((i = 0; i < $nr_files; i++)) do
_pwrite_byte 0xcd 0 1K "$SCRATCH_MNT/subvol/file_$i" > /dev/null _pwrite_byte 0xcd 0 1K "$SCRATCH_MNT/subvol/file_$i" > /dev/null
done done
$BTRFS_UTIL_PROG balance start -m "$SCRATCH_MNT" > /dev/null _run_btrfs_balance_start -m $SCRATCH_MNT >> $seqres.full
# success, all done # success, all done
echo "Silence is golden" echo "Silence is golden"
+1 -1
View File
@@ -84,7 +84,7 @@ balance_loop()
# easier to hit problems (crashes and errors) in send. # easier to hit problems (crashes and errors) in send.
# Ignore errors from balance. We just want to test for crashes # Ignore errors from balance. We just want to test for crashes
# and deadlocks. # and deadlocks.
$BTRFS_UTIL_PROG balance start -f -m $SCRATCH_MNT &> /dev/null _run_btrfs_balance_start -f -m $SCRATCH_MNT &> /dev/null
sleep $((RANDOM % 3)) sleep $((RANDOM % 3))
done done
} }
+2 -1
View File
@@ -59,7 +59,8 @@ sync
# Balance metadata so we will have at least one transaction committed with # Balance metadata so we will have at least one transaction committed with
# valid reloc tree, and hopefully another commit with orphan reloc tree. # valid reloc tree, and hopefully another commit with orphan reloc tree.
$BTRFS_UTIL_PROG balance start -f -m $SCRATCH_MNT >> $seqres.full _run_btrfs_balance_start -f -m $SCRATCH_MNT >> $seqres.full
_log_writes_unmount _log_writes_unmount
_log_writes_remove _log_writes_remove
+1 -1
View File
@@ -64,7 +64,7 @@ run_testcase() {
# Create random filesystem with 20k write ops # Create random filesystem with 20k write ops
$FSSTRESS_PROG -d $SCRATCH_MNT -w -n 10000 $FSSTRESS_AVOID >>$seqres.full 2>&1 $FSSTRESS_PROG -d $SCRATCH_MNT -w -n 10000 $FSSTRESS_AVOID >>$seqres.full 2>&1
$BTRFS_UTIL_PROG balance start -f -dconvert=$dst_type $SCRATCH_MNT >> $seqres.full 2>&1 _run_btrfs_balance_start -f -dconvert=$dst_type $SCRATCH_MNT >> $seqres.full
[ $? -eq 0 ] || echo "$1: Failed convert" [ $? -eq 0 ] || echo "$1: Failed convert"
$BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1