fstests/btrfs: fixes for tests btrfs/06[0-9] and btrfs/07[0-4]
cover fstests/btrfs: fixes for tests btrfs/06[0-9] and btrfs/07[0-4]
From: Filipe Manana <[email protected]>
Killing any of the tests cases btrfs/06[0-9] and btrfs/07[0-4] often leaves some background processes running around that prevent unmounting the scratch filesystems or running fstests again. When that happens it requires manually finding which processes are still using the scratch filesystem and then kill them. These patches address that issue. Details in the change logs.
Filipe Manana (10):
btrfs: add helper to kill background process running _btrfs_stress_balance btrfs/028: use the helper _btrfs_kill_stress_balance_pid
btrfs/028: removed redundant sync and scratch filesystem unmount
btrfs: add helper to kill background process running _btrfs_stress_scrub
btrfs: add helper to kill background process running _btrfs_stress_defrag
btrfs: add helper to kill background process running _btrfs_stress_remount_compress
btrfs: add helper to kill background process running _btrfs_stress_replace
btrfs: add helper to stop background process running _btrfs_stress_subvolume
btrfs: remove stop file early at _btrfs_stress_subvolume btrfs/06[0-9]..07[0-4]: kill all background tasks when test is killed/interrupted
common/btrfs | 84 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/028 | 16 +++------- tests/btrfs/060 | 33 +++++++++++++------ tests/btrfs/061 | 30 ++++++++++++------ tests/btrfs/062 | 30 ++++++++++++------ tests/btrfs/063 | 30 ++++++++++++------ tests/btrfs/064 | 30 ++++++++++++------ tests/btrfs/065 | 33 +++++++++++++------ tests/btrfs/066 | 33 +++++++++++++------ tests/btrfs/067 | 33 +++++++++++++------ tests/btrfs/068 | 33 +++++++++++++------ tests/btrfs/069 | 31 ++++++++++++------ tests/btrfs/070 | 31 ++++++++++++------ tests/btrfs/071 | 31 ++++++++++++------ tests/btrfs/072 | 31 ++++++++++++------ tests/btrfs/073 | 30 ++++++++++++------ tests/btrfs/074 | 30 ++++++++++++------ tests/btrfs/255 | 8 ++--- 18 files changed, 417 insertions(+), 160 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/10 btrfs: add helper to kill background process running _btrfs_stress_balance
From: Filipe Manana <[email protected]>
Killing a background process running _btrfs_stress_balance() is not as simple as sending a signal to the process and waiting for it to die. Therefore we have the following logic to terminate such process:
kill $pid
wait $pid
# Wait for the balance operation to finish. while ps aux | grep "balance start" | grep -qv grep; do
sleep 1
done
Since this is repeated in several test cases, move this logic to a common helper and use it in all affected test cases. This will help to avoid repeating the same code again several times in upcoming changes.
--- common/btrfs | 14 ++++++++++++++ tests/btrfs/060 | 8 ++------ tests/btrfs/061 | 10 ++++------ tests/btrfs/062 | 10 ++++------ tests/btrfs/063 | 10 ++++------ tests/btrfs/064 | 10 ++++------ tests/btrfs/255 | 8 ++------ 7 files changed, 34 insertions(+), 36 deletions(-)
common/btrfs +14 -0
@@ -308,6 +308,20 @@ _btrfs_stress_balance() done } +# Kill a background process running _btrfs_stress_balance() +_btrfs_kill_stress_balance_pid() +{ + local balance_pid=$1 + + # Ignore if process already died. + kill $balance_pid &> /dev/null + wait $balance_pid &> /dev/null + # Wait for the balance operation to finish. + while ps aux | grep "balance start" | grep -qv grep; do + sleep 1 + done +} + # stress btrfs by creating/mounting/umounting/deleting subvolume in a loop _btrfs_stress_subvolume() {
tests/btrfs/060 +2 -6
@@ -57,12 +57,8 @@ run_test() wait $fsstress_pid touch $stop_file - kill $balance_pid - wait - # wait for the balance operation to finish - while ps aux | grep "balance start" | grep -qv grep; do - sleep 1 - done + wait $subvol_pid + _btrfs_kill_stress_balance_pid $balance_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
tests/btrfs/061 +4 -6
@@ -51,12 +51,10 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $balance_pid $scrub_pid - wait - # wait for the balance and scrub operations to finish - while ps aux | grep "balance start" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_balance_pid $balance_pid + kill $scrub_pid + wait $scrub_pid + # wait for the crub operation to finish while ps aux | grep "scrub start" | grep -qv grep; do sleep 1 done
tests/btrfs/062 +4 -6
@@ -52,12 +52,10 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $balance_pid $defrag_pid - wait - # wait for the balance and defrag operations to finish - while ps aux | grep "balance start" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_balance_pid $balance_pid + kill $defrag_pid + wait $defrag_pid + # wait for the defrag operation to finish while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do sleep 1 done
tests/btrfs/063 +4 -6
@@ -51,12 +51,10 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $balance_pid $remount_pid - wait - # wait for the balance and remount loop to finish - while ps aux | grep "balance start" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_balance_pid $balance_pid + kill $remount_pid + wait $remount_pid + # wait for the remount loop to finish while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do sleep 1 done
tests/btrfs/064 +4 -6
@@ -63,12 +63,10 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $balance_pid $replace_pid - wait - # wait for the balance and replace operations to finish - while ps aux | grep "balance start" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_balance_pid $balance_pid + kill $replace_pid + wait $replace_pid + # wait for the replace operation to finish while ps aux | grep "replace start" | grep -qv grep; do sleep 1 done
tests/btrfs/255 +2 -6
@@ -41,12 +41,8 @@ for ((i = 0; i < 20; i++)); do $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT $BTRFS_UTIL_PROG quota disable $SCRATCH_MNT done -kill $balance_pid &> /dev/null -wait -# wait for the balance operation to finish -while ps aux | grep "balance start" | grep -qv grep; do - sleep 1 -done + +_btrfs_kill_stress_balance_pid $balance_pid echo "Silence is golden" status=0
Signature · 1 line
2.43.0
PATCH 2/10 btrfs/028: use the helper _btrfs_kill_stress_balance_pid
In reply to [email protected]From: Filipe Manana <[email protected]>
Now that there's a helper to kill a background process that is running _btrfs_stress_balance(), use it in btrfs/028. It's equivalent to the existing code in btrfs/028.
--- tests/btrfs/028 | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
tests/btrfs/028 +3 -6
@@ -44,12 +44,9 @@ balance_pid=$! # 30s is enough to trigger bug sleep $((30*$TIME_FACTOR)) -kill $fsstress_pid $balance_pid &> /dev/null -wait - -# kill _btrfs_stress_balance can't end balance, so call btrfs balance cancel -# to cancel running or paused balance. -$BTRFS_UTIL_PROG balance cancel $SCRATCH_MNT &> /dev/null +kill $fsstress_pid &> /dev/null +wait $fsstress_pid &> /dev/null +_btrfs_kill_stress_balance_pid $balance_pid _run_btrfs_util_prog filesystem sync $SCRATCH_MNT
Signature · 1 line
2.43.0
PATCH 3/10 btrfs/028: removed redundant sync and scratch filesystem unmount
In reply to [email protected]From: Filipe Manana <[email protected]>
There's no need to have an explicit scratch filesystem sync and unmount at the of the test, as the fstests framework automatically unmounts the filesystem and the unmount naturally syncs any data and metadata.
So remove them and update the comment to be more clear.
--- tests/btrfs/028 | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
tests/btrfs/028 +2 -5
@@ -48,11 +48,8 @@ kill $fsstress_pid &> /dev/null wait $fsstress_pid &> /dev/null _btrfs_kill_stress_balance_pid $balance_pid -_run_btrfs_util_prog filesystem sync $SCRATCH_MNT - -_scratch_unmount - -# qgroup will be checked at _check_scratch_fs() by fstest. +# The qgroups accounting will be checked by 'btrfs check' (fsck) after the +# fstests framework unmounts the filesystem. echo "Silence is golden" status=0
Signature · 1 line
2.43.0
PATCH 4/10 btrfs: add helper to kill background process running _btrfs_stress_scrub
In reply to [email protected]From: Filipe Manana <[email protected]>
Killing a background process running _btrfs_stress_scrub() is not as simple as sending a signal to the process and waiting for it to die. Therefore we have the following logic to terminate such process:
kill $pid
wait $pid
while ps aux | grep "scrub start" | grep -qv grep; do
sleep 1
done
Since this is repeated in several test cases, move this logic to a common helper and use it in all affected test cases. This will help to avoid repeating the same code again several times in upcoming changes.
--- common/btrfs | 14 ++++++++++++++ tests/btrfs/061 | 7 +------ tests/btrfs/066 | 8 ++------ tests/btrfs/069 | 11 +++++------ tests/btrfs/072 | 11 +++++------ tests/btrfs/073 | 11 +++++------ 6 files changed, 32 insertions(+), 30 deletions(-)
common/btrfs +14 -0
@@ -349,6 +349,20 @@ _btrfs_stress_scrub() done } +# Kill a background process running _btrfs_stress_scrub() +_btrfs_kill_stress_scrub_pid() +{ + local scrub_pid=$1 + + # Ignore if process already died. + kill $scrub_pid &> /dev/null + wait $scrub_pid &> /dev/null + # Wait for the scrub operation to finish. + while ps aux | grep "scrub start" | grep -qv grep; do + sleep 1 + done +} + # stress btrfs by defragmenting every file/dir in a loop and compress file # contents while defragmenting if second argument is not "nocompress" _btrfs_stress_defrag()
tests/btrfs/061 +1 -6
@@ -52,12 +52,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid _btrfs_kill_stress_balance_pid $balance_pid - kill $scrub_pid - wait $scrub_pid - # wait for the crub operation to finish - while ps aux | grep "scrub start" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_scrub_pid $scrub_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
tests/btrfs/066 +2 -6
@@ -57,12 +57,8 @@ run_test() wait $fsstress_pid touch $stop_file - kill $scrub_pid - wait - # wait for the scrub operation to finish - while ps aux | grep "scrub start" | grep -qv grep; do - sleep 1 - done + wait $subvol_pid + _btrfs_kill_stress_scrub_pid $scrub_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
tests/btrfs/069 +5 -6
@@ -59,17 +59,16 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $replace_pid $scrub_pid - wait + kill $replace_pid + wait $replace_pid - # wait for the scrub and replace operations to finish - while ps aux | grep "scrub start" | grep -qv grep; do - sleep 1 - done + # wait for the replace operation to finish while ps aux | grep "replace start" | grep -qv grep; do sleep 1 done + _btrfs_kill_stress_scrub_pid $scrub_pid + echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 if [ $? -ne 0 ]; then
tests/btrfs/072 +5 -6
@@ -52,16 +52,15 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $scrub_pid $defrag_pid - wait - # wait for the scrub and defrag operations to finish - while ps aux | grep "scrub start" | grep -qv grep; do - sleep 1 - done + kill $defrag_pid + wait $defrag_pid + # wait for the defrag operation to finish while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do sleep 1 done + _btrfs_kill_stress_scrub_pid $scrub_pid + echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 if [ $? -ne 0 ]; then
tests/btrfs/073 +5 -6
@@ -51,16 +51,15 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $scrub_pid $remount_pid - wait - # wait for the scrub and remount operations to finish - while ps aux | grep "scrub start" | grep -qv grep; do - sleep 1 - done + kill $remount_pid + wait $remount_pid + # wait for the remount operation to finish while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do sleep 1 done + _btrfs_kill_stress_scrub_pid $scrub_pid + echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 if [ $? -ne 0 ]; then
Signature · 1 line
2.43.0
PATCH 5/10 btrfs: add helper to kill background process running _btrfs_stress_defrag
In reply to [email protected]From: Filipe Manana <[email protected]>
Killing a background process running _btrfs_stress_defrag() is not as simple as sending a signal to the process and waiting for it to die. Therefore we have the following logic to terminate such process:
kill $pid
wait $pid
while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
sleep 1
done
Since this is repeated in several test cases, move this logic to a common helper and use it in all affected test cases. This will help to avoid repeating the same code again several times in upcoming changes.
--- common/btrfs | 14 ++++++++++++++ tests/btrfs/062 | 7 +------ tests/btrfs/067 | 8 ++------ tests/btrfs/070 | 11 +++++------ tests/btrfs/072 | 7 +------ tests/btrfs/074 | 11 +++++------ 6 files changed, 28 insertions(+), 30 deletions(-)
common/btrfs +14 -0
@@ -383,6 +383,20 @@ _btrfs_stress_defrag() done } +# Kill a background process running _btrfs_stress_defrag() +_btrfs_kill_stress_defrag_pid() +{ + local defrag_pid=$1 + + # Ignore if process already died. + kill $defrag_pid &> /dev/null + wait $defrag_pid &> /dev/null + # Wait for the defrag operation to finish. + while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do + sleep 1 + done +} + # stress btrfs by remounting it with different compression algorithms in a loop # run this with fsstress running at background could exercise the compression # code path and ensure no race when switching compression algorithm with constant
tests/btrfs/062 +1 -6
@@ -53,12 +53,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid _btrfs_kill_stress_balance_pid $balance_pid - kill $defrag_pid - wait $defrag_pid - # wait for the defrag operation to finish - while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_defrag_pid $defrag_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
tests/btrfs/067 +2 -6
@@ -58,12 +58,8 @@ run_test() wait $fsstress_pid touch $stop_file - kill $defrag_pid - wait - # wait for btrfs defrag process to exit, otherwise it will block umount - while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do - sleep 1 - done + wait $subvol_pid + _btrfs_kill_stress_defrag_pid $defrag_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
tests/btrfs/070 +5 -6
@@ -60,17 +60,16 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $replace_pid $defrag_pid - wait + kill $replace_pid + wait $replace_pid - # wait for the defrag and replace operations to finish - while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do - sleep 1 - done + # wait for the replace operation to finish while ps aux | grep "replace start" | grep -qv grep; do sleep 1 done + _btrfs_kill_stress_defrag_pid $defrag_pid + echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 if [ $? -ne 0 ]; then
tests/btrfs/072 +1 -6
@@ -52,13 +52,8 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $defrag_pid - wait $defrag_pid - # wait for the defrag operation to finish - while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_defrag_pid $defrag_pid _btrfs_kill_stress_scrub_pid $scrub_pid echo "Scrub the filesystem" >>$seqres.full
tests/btrfs/074 +5 -6
@@ -52,16 +52,15 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $defrag_pid $remount_pid - wait - # wait for the defrag and remount operations to finish - while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do - sleep 1 - done + kill $remount_pid + wait $remount_pid + # wait for the remount operation to finish while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do sleep 1 done + _btrfs_kill_stress_defrag_pid $defrag_pid + echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 if [ $? -ne 0 ]; then
Signature · 1 line
2.43.0
PATCH 6/10 btrfs: add helper to kill background process running _btrfs_stress_remount_compress
In reply to [email protected]From: Filipe Manana <[email protected]>
Killing a background process running _btrfs_stress_remount_compress() is not as simple as sending a signal to the process and waiting for it to die. Therefore we have the following logic to terminate such process:
kill $pid
wait $pid
while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
sleep 1
done
Since this is repeated in several test cases, move this logic to a common helper and use it in all affected test cases. This will help to avoid repeating the same code again several times in upcoming changes.
--- common/btrfs | 15 +++++++++++++++ tests/btrfs/063 | 7 +------ tests/btrfs/068 | 8 ++------ tests/btrfs/071 | 12 +++++------- tests/btrfs/073 | 8 +------- tests/btrfs/074 | 8 +------- 6 files changed, 25 insertions(+), 33 deletions(-)
common/btrfs +15 -0
@@ -411,6 +411,21 @@ _btrfs_stress_remount_compress() done } +# Kill a background process running _btrfs_stress_remount_compress() +_btrfs_kill_stress_remount_compress_pid() +{ + local remount_pid=$1 + local btrfs_mnt=$2 + + # Ignore if process already died. + kill $remount_pid &> /dev/null + wait $remount_pid &> /dev/null + # Wait for the remount loop to finish. + while ps aux | grep "mount.*${btrfs_mnt}" | grep -qv grep; do + sleep 1 + done +} + # stress btrfs by replacing devices in a loop # Note that at least 3 devices are needed in SCRATCH_DEV_POOL and the last # device should be free(not used by btrfs)
tests/btrfs/063 +1 -6
@@ -52,12 +52,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid _btrfs_kill_stress_balance_pid $balance_pid - kill $remount_pid - wait $remount_pid - # wait for the remount loop to finish - while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
tests/btrfs/068 +2 -6
@@ -58,12 +58,8 @@ run_test() wait $fsstress_pid touch $stop_file - kill $remount_pid - wait - # wait for the remount loop process to finish - while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do - sleep 1 - done + wait $subvol_pid + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
tests/btrfs/071 +5 -7
@@ -58,17 +58,15 @@ run_test() echo "$remount_pid" >>$seqres.full echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full - wait $fsstress_pid - kill $replace_pid $remount_pid - wait + kill $replace_pid + wait $fsstress_pid $replace_pid - # wait for the remount and replace operations to finish + # wait for the replace operationss to finish while ps aux | grep "replace start" | grep -qv grep; do sleep 1 done - while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do - sleep 1 - done + + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
tests/btrfs/073 +1 -7
@@ -51,13 +51,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $remount_pid - wait $remount_pid - # wait for the remount operation to finish - while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do - sleep 1 - done - + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT _btrfs_kill_stress_scrub_pid $scrub_pid echo "Scrub the filesystem" >>$seqres.full
tests/btrfs/074 +1 -7
@@ -52,13 +52,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $remount_pid - wait $remount_pid - # wait for the remount operation to finish - while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do - sleep 1 - done - + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT _btrfs_kill_stress_defrag_pid $defrag_pid echo "Scrub the filesystem" >>$seqres.full
Signature · 1 line
2.43.0
PATCH 7/10 btrfs: add helper to kill background process running _btrfs_stress_replace
In reply to [email protected]From: Filipe Manana <[email protected]>
Killing a background process running _btrfs_stress_replace() is not as simple as sending a signal to the process and waiting for it to die. Therefore we have the following logic to terminate such process:
kill $pid
wait $pid
while ps aux | grep "replace start" | grep -qv grep; do
sleep 1
done
Since this is repeated in several test cases, move this logic to a common helper and use it in all affected test cases. This will help to avoid repeating the same code again several times in upcoming changes.
--- common/btrfs | 14 ++++++++++++++ tests/btrfs/064 | 7 +------ tests/btrfs/065 | 8 ++------ tests/btrfs/069 | 9 +-------- tests/btrfs/070 | 9 +-------- tests/btrfs/071 | 10 ++-------- 6 files changed, 21 insertions(+), 36 deletions(-)
common/btrfs +14 -0
@@ -475,6 +475,20 @@ _btrfs_stress_replace() done } +# Kill a background process running _btrfs_stress_replace() +_btrfs_kill_stress_replace_pid() +{ + local replace_pid=$1 + + # Ignore if process already died. + kill $replace_pid &> /dev/null + wait $replace_pid &> /dev/null + # Wait for the replace operation to finish. + while ps aux | grep "replace start" | grep -qv grep; do + sleep 1 + done +} + # find the right option to force output in bytes, older versions of btrfs-progs # print that by default, newer print human readable numbers with unit suffix _btrfs_qgroup_units()
tests/btrfs/064 +1 -6
@@ -64,12 +64,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid _btrfs_kill_stress_balance_pid $balance_pid - kill $replace_pid - wait $replace_pid - # wait for the replace operation to finish - while ps aux | grep "replace start" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_replace_pid $replace_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
tests/btrfs/065 +2 -6
@@ -65,12 +65,8 @@ run_test() wait $fsstress_pid touch $stop_file - kill $replace_pid - wait - # wait for the replace operation to finish - while ps aux | grep "replace start" | grep -qv grep; do - sleep 1 - done + wait $subvol_pid + _btrfs_kill_stress_replace_pid $replace_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
tests/btrfs/069 +1 -8
@@ -59,15 +59,8 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $replace_pid - wait $replace_pid - - # wait for the replace operation to finish - while ps aux | grep "replace start" | grep -qv grep; do - sleep 1 - done - _btrfs_kill_stress_scrub_pid $scrub_pid + _btrfs_kill_stress_replace_pid $replace_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
tests/btrfs/070 +1 -8
@@ -60,14 +60,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $replace_pid - wait $replace_pid - - # wait for the replace operation to finish - while ps aux | grep "replace start" | grep -qv grep; do - sleep 1 - done - + _btrfs_kill_stress_replace_pid $replace_pid _btrfs_kill_stress_defrag_pid $defrag_pid echo "Scrub the filesystem" >>$seqres.full
tests/btrfs/071 +2 -8
@@ -58,14 +58,8 @@ run_test() echo "$remount_pid" >>$seqres.full echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full - kill $replace_pid - wait $fsstress_pid $replace_pid - - # wait for the replace operationss to finish - while ps aux | grep "replace start" | grep -qv grep; do - sleep 1 - done - + wait $fsstress_pid + _btrfs_kill_stress_replace_pid $replace_pid _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT echo "Scrub the filesystem" >>$seqres.full
Signature · 1 line
2.43.0
PATCH 8/10 btrfs: add helper to stop background process running _btrfs_stress_subvolume
In reply to [email protected]From: Filipe Manana <[email protected]>
We have this logic to stop a process running _btrfs_stress_subvolume() spread in several test cases:
touch $stop_file
wait $subvol_pid
Add a helper to encapsulate that logic and also remove the stop file after the process terminated as there's no point having it around anymore.
This will help to avoid repeating the same code again several times in upcoming changes.
--- common/btrfs | 12 ++++++++++++ tests/btrfs/060 | 3 +-- tests/btrfs/065 | 3 +-- tests/btrfs/066 | 3 +-- tests/btrfs/067 | 3 +-- tests/btrfs/068 | 3 +-- 6 files changed, 17 insertions(+), 10 deletions(-)
common/btrfs +12 -0
@@ -340,6 +340,18 @@ _btrfs_stress_subvolume() done } +# Kill a background process running _btrfs_stress_subvolume() +_btrfs_kill_stress_subvolume_pid() +{ + local subvol_pid=$1 + local stop_file=$2 + + touch $stop_file + # Ignore if process already died. + wait $subvol_pid &> /dev/null + rm -f $stop_file +} + # stress btrfs by running scrub in a loop _btrfs_stress_scrub() {
tests/btrfs/060 +1 -2
@@ -56,8 +56,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - touch $stop_file - wait $subvol_pid + _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file _btrfs_kill_stress_balance_pid $balance_pid echo "Scrub the filesystem" >>$seqres.full
tests/btrfs/065 +1 -2
@@ -64,8 +64,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - touch $stop_file - wait $subvol_pid + _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file _btrfs_kill_stress_replace_pid $replace_pid echo "Scrub the filesystem" >>$seqres.full
tests/btrfs/066 +1 -2
@@ -56,8 +56,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - touch $stop_file - wait $subvol_pid + _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file _btrfs_kill_stress_scrub_pid $scrub_pid echo "Scrub the filesystem" >>$seqres.full
tests/btrfs/067 +1 -2
@@ -57,8 +57,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - touch $stop_file - wait $subvol_pid + _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file _btrfs_kill_stress_defrag_pid $defrag_pid echo "Scrub the filesystem" >>$seqres.full
tests/btrfs/068 +1 -2
@@ -57,8 +57,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - touch $stop_file - wait $subvol_pid + _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT echo "Scrub the filesystem" >>$seqres.full
Signature · 1 line
2.43.0
PATCH 9/10 btrfs: remove stop file early at _btrfs_stress_subvolume
In reply to [email protected]From: Filipe Manana <[email protected]>
Instead of having every test case that uses _btrfs_stress_subvolume() removing the stop file before calling that function, do the file remove at _btrfs_stress_subvolume(). There's no point in doing it in every single test case.
--- common/btrfs | 1 + tests/btrfs/060 | 2 -- tests/btrfs/065 | 2 -- tests/btrfs/066 | 2 -- tests/btrfs/067 | 2 -- tests/btrfs/068 | 2 -- 6 files changed, 1 insertion(+), 10 deletions(-)
common/btrfs +1 -0
@@ -331,6 +331,7 @@ _btrfs_stress_subvolume() local subvol_mnt=$4 local stop_file=$5 + rm -f $stop_file mkdir -p $subvol_mnt while [ ! -e $stop_file ]; do $BTRFS_UTIL_PROG subvolume create $btrfs_mnt/$subvol_name
tests/btrfs/060 +0 -2
@@ -46,8 +46,6 @@ run_test() balance_pid=$! echo "$balance_pid" >>$seqres.full - # make sure the stop sign is not there - rm -f $stop_file echo -n "Start subvolume worker: " >>$seqres.full _btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 & subvol_pid=$!
tests/btrfs/065 +0 -2
@@ -49,8 +49,6 @@ run_test() $FSSTRESS_PROG $args >>$seqres.full & fsstress_pid=$! - # make sure the stop sign is not there - rm -f $stop_file echo -n "Start subvolume worker: " >>$seqres.full _btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 & subvol_pid=$!
tests/btrfs/066 +0 -2
@@ -41,8 +41,6 @@ run_test() $FSSTRESS_PROG $args >>$seqres.full & fsstress_pid=$! - # make sure the stop sign is not there - rm -f $stop_file echo -n "Start subvolume worker: " >>$seqres.full _btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 & subvol_pid=$!
tests/btrfs/067 +0 -2
@@ -42,8 +42,6 @@ run_test() $FSSTRESS_PROG $args >>$seqres.full & fsstress_pid=$! - # make sure the stop sign is not there - rm -f $stop_file echo -n "Start subvolume worker: " >>$seqres.full _btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 & subvol_pid=$!
tests/btrfs/068 +0 -2
@@ -42,8 +42,6 @@ run_test() $FSSTRESS_PROG $args >>$seqres.full & fsstress_pid=$! - # make sure the stop sign is not there - rm -f $stop_file echo -n "Start subvolume worker: " >>$seqres.full _btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 & subvol_pid=$!
Signature · 1 line
2.43.0
PATCH 10/10 btrfs/06[0-9]..07[0-4]: kill all background tasks when test is killed/interrupted
In reply to [email protected]From: Filipe Manana <[email protected]>
Test cases btrfs/06[0-9] and btrfs/07[0-4] exercise multiple concurrent operations while fsstress is running in parallel, and all these are left as child processes running in the background, which are correctly stopped if the tests are not interrupted/killed. However if any of these tests is interrupted/killed, it often leaves child processes still running in the background, which prevent further running fstests again. For example:
$ /check -g auto (...) btrfs/060 394s ... 264s btrfs/061 83s ... 69s btrfs/062 109s ... 105s btrfs/063 52s ... 67s btrfs/064 53s ... 51s btrfs/065 88s ... 271s btrfs/066 127s ... 241s btrfs/067 435s ... 248s btrfs/068 161s ... ^C^C ^C
$ ./check btrfs/068 FSTYP -- btrfs PLATFORM -- Linux/x86_64 debian0 6.8.0-rc7-btrfs-next-153+ #1 SMP PREEMPT_DYNAMIC Mon Mar 4 17:19:19 WET 2024 MKFS_OPTIONS -- /dev/sdb MOUNT_OPTIONS -- /dev/sdb /home/fdmanana/btrfs-tests/scratch_1
our local _scratch_mkfs routine ... btrfs-progs v6.6.2
See https://btrfs.readthedocs.io for more information.
ERROR: unable to open /dev/sdb: Device or resource busy
check: failed to mkfs $SCRATCH_DEV using specified options Interrupted!
Passed all 0 tests
In this case there was still a process running _btrfs_stress_subvolume() from common/btrfs.
This is a bit annoying because it requires manually finding out which process is preventing unmounting the scratch device and then properly stop/kill it.
So fix this by adding a _cleanup() function to all these tests and then making sure it stops all the child processes it spawned and are running in the background.
All these tests have the same structure as they were part of the same patchset and from the same author.
--- tests/btrfs/060 | 22 +++++++++++++++++++++- tests/btrfs/061 | 19 +++++++++++++++++++ tests/btrfs/062 | 19 +++++++++++++++++++ tests/btrfs/063 | 19 +++++++++++++++++++ tests/btrfs/064 | 19 +++++++++++++++++++ tests/btrfs/065 | 22 +++++++++++++++++++++- tests/btrfs/066 | 22 +++++++++++++++++++++- tests/btrfs/067 | 22 +++++++++++++++++++++- tests/btrfs/068 | 22 +++++++++++++++++++++- tests/btrfs/069 | 19 +++++++++++++++++++ tests/btrfs/070 | 19 +++++++++++++++++++ tests/btrfs/071 | 19 +++++++++++++++++++ tests/btrfs/072 | 19 +++++++++++++++++++ tests/btrfs/073 | 19 +++++++++++++++++++ tests/btrfs/074 | 19 +++++++++++++++++++ 15 files changed, 295 insertions(+), 5 deletions(-)
tests/btrfs/060 +21 -1
@@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto balance subvol scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then + _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file + fi + if [ ! -z "$balance_pid" ]; then + _btrfs_kill_stress_balance_pid $balance_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter
@@ -20,11 +36,12 @@ _require_scratch_nocheck _require_scratch_dev_pool 4 _btrfs_get_profile_configs +stop_file=$TEST_DIR/$seq.stop.$$ + run_test() { local mkfs_opts=$1 local subvol_mnt=$TEST_DIR/$seq.mnt - local stop_file=$TEST_DIR/$seq.stop.$$ echo "Test $mkfs_opts" >>$seqres.full
@@ -53,9 +70,12 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file + unset subvol_pid _btrfs_kill_stress_balance_pid $balance_pid + unset balance_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
tests/btrfs/061 +19 -0
@@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto balance scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$balance_pid" ]; then + _btrfs_kill_stress_balance_pid $balance_pid + fi + if [ ! -z "$scrub_pid" ]; then + _btrfs_kill_stress_scrub_pid $scrub_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter
@@ -51,8 +67,11 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_balance_pid $balance_pid + unset balance_pid _btrfs_kill_stress_scrub_pid $scrub_pid + unset scrub_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
tests/btrfs/062 +19 -0
@@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto balance defrag compress scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$balance_pid" ]; then + _btrfs_kill_stress_balance_pid $balance_pid + fi + if [ ! -z "$defrag_pid" ]; then + _btrfs_kill_stress_defrag_pid $defrag_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter
@@ -52,8 +68,11 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_balance_pid $balance_pid + unset balance_pid _btrfs_kill_stress_defrag_pid $defrag_pid + unset defrag_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
tests/btrfs/063 +19 -0
@@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto balance remount compress scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$balance_pid" ]; then + _btrfs_kill_stress_balance_pid $balance_pid + fi + if [ ! -z "$remount_pid" ]; then + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter
@@ -51,8 +67,11 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_balance_pid $balance_pid + unset balance_pid _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT + unset remount_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
tests/btrfs/064 +19 -0
@@ -12,6 +12,22 @@ . ./common/preamble _begin_fstest auto balance replace volume scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$balance_pid" ]; then + _btrfs_kill_stress_balance_pid $balance_pid + fi + if [ ! -z "$replace_pid" ]; then + _btrfs_kill_stress_replace_pid $replace_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter
@@ -63,8 +79,11 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_balance_pid $balance_pid + unset balance_pid _btrfs_kill_stress_replace_pid $replace_pid + unset replace_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
tests/btrfs/065 +21 -1
@@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto subvol replace volume scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then + _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file + fi + if [ ! -z "$replace_pid" ]; then + _btrfs_kill_stress_replace_pid $replace_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter
@@ -21,12 +37,13 @@ _require_scratch_dev_pool 5 _require_scratch_dev_pool_equal_size _btrfs_get_profile_configs replace +stop_file=$TEST_DIR/$seq.stop.$$ + run_test() { local mkfs_opts=$1 local saved_scratch_dev_pool=$SCRATCH_DEV_POOL local subvol_mnt=$TEST_DIR/$seq.mnt - local stop_file=$TEST_DIR/$seq.stop.$$ echo "Test $mkfs_opts" >>$seqres.full
@@ -61,9 +78,12 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file + unset subvol_pid _btrfs_kill_stress_replace_pid $replace_pid + unset replace_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
tests/btrfs/066 +21 -1
@@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto subvol scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then + _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file + fi + if [ ! -z "$scrub_pid" ]; then + _btrfs_kill_stress_scrub_pid $scrub_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter
@@ -20,11 +36,12 @@ _require_scratch_nocheck _require_scratch_dev_pool 4 _btrfs_get_profile_configs +stop_file=$TEST_DIR/$seq.stop.$$ + run_test() { local mkfs_opts=$1 local subvol_mnt=$TEST_DIR/$seq.mnt - local stop_file=$TEST_DIR/$seq.stop.$$ echo "Test $mkfs_opts" >>$seqres.full
@@ -53,9 +70,12 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file + unset subvol_pid _btrfs_kill_stress_scrub_pid $scrub_pid + unset scrub_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
tests/btrfs/067 +21 -1
@@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto subvol defrag compress scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then + _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file + fi + if [ ! -z "$defrag_pid" ]; then + _btrfs_kill_stress_defrag_pid $defrag_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter
@@ -20,12 +36,13 @@ _require_scratch_nocheck _require_scratch_dev_pool 4 _btrfs_get_profile_configs +stop_file=$TEST_DIR/$seq.stop.$$ + run_test() { local mkfs_opts=$1 local with_compress=$2 local subvol_mnt=$TEST_DIR/$seq.mnt - local stop_file=$TEST_DIR/$seq.stop.$$ echo "Test $mkfs_opts with $with_compress" >>$seqres.full
@@ -54,9 +71,12 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file + unset subvol_pid _btrfs_kill_stress_defrag_pid $defrag_pid + unset defrag_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
tests/btrfs/068 +21 -1
@@ -11,6 +11,22 @@ . ./common/preamble _begin_fstest auto subvol remount compress scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then + _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file + fi + if [ ! -z "$remount_pid" ]; then + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter
@@ -21,11 +37,12 @@ _require_scratch_nocheck _require_scratch_dev_pool 4 _btrfs_get_profile_configs +stop_file=$TEST_DIR/$seq.stop.$$ + run_test() { local mkfs_opts=$1 local subvol_mnt=$TEST_DIR/$seq.mnt - local stop_file=$TEST_DIR/$seq.stop.$$ echo "Test $mkfs_opts with $with_compress" >>$seqres.full
@@ -54,9 +71,12 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file + unset subvol_pid _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT + unset remount_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
tests/btrfs/069 +19 -0
@@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto replace scrub volume +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$replace_pid" ]; then + _btrfs_kill_stress_replace_pid $replace_pid + fi + if [ ! -z "$scrub_pid" ]; then + _btrfs_kill_stress_scrub_pid $scrub_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter
@@ -59,8 +75,11 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_scrub_pid $scrub_pid + unset scrub_pid _btrfs_kill_stress_replace_pid $replace_pid + unset replace_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
tests/btrfs/070 +19 -0
@@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto replace defrag compress volume scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$replace_pid" ]; then + _btrfs_kill_stress_replace_pid $replace_pid + fi + if [ ! -z "$defrag_pid" ]; then + _btrfs_kill_stress_defrag_pid $defrag_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter
@@ -60,8 +76,11 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_replace_pid $replace_pid + unset replace_pid _btrfs_kill_stress_defrag_pid $defrag_pid + unset defrag_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
tests/btrfs/071 +19 -0
@@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto replace remount compress volume scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$replace_pid" ]; then + _btrfs_kill_stress_replace_pid $replace_pid + fi + if [ ! -z "$remount_pid" ]; then + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter
@@ -59,8 +75,11 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_replace_pid $replace_pid + unset replace_pid _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT + unset remount_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
tests/btrfs/072 +19 -0
@@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto scrub defrag compress +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$defrag_pid" ]; then + _btrfs_kill_stress_defrag_pid $defrag_pid + fi + if [ ! -z "$scrub_pid" ]; then + _btrfs_kill_stress_scrub_pid $scrub_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter
@@ -52,9 +68,12 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_defrag_pid $defrag_pid + unset defrag_pid _btrfs_kill_stress_scrub_pid $scrub_pid + unset scrub_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
tests/btrfs/073 +19 -0
@@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto scrub remount compress +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$remount_pid" ]; then + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT + fi + if [ ! -z "$scrub_pid" ]; then + _btrfs_kill_stress_scrub_pid $scrub_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter
@@ -51,8 +67,11 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT + unset remount_pid _btrfs_kill_stress_scrub_pid $scrub_pid + unset scrub_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
tests/btrfs/074 +19 -0
@@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto defrag remount compress scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$remount_pid" ]; then + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT + fi + if [ ! -z "$defrag_pid" ]; then + _btrfs_kill_stress_defrag_pid $defrag_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter
@@ -52,8 +68,11 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT + unset remount_pid _btrfs_kill_stress_defrag_pid $defrag_pid + unset defrag_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
Signature · 1 line
2.43.0
Re: [PATCH 01/10] btrfs: add helper to kill background process running _btrfs_stress_balance
In reply to [email protected]Quoted 12 lines · On 3/28/24 01:11, [email protected] wrote:
From: Filipe Manana <[email protected]>
Killing a background process running
_btrfs_stress_balance()is not as simple as sending a signal to the process and waiting for it to die. Therefore we have the following logic to terminate such process:kill $pid
wait $pid
# Wait for the balance operation to finish. while ps aux | grep "balance start" | grep -qv grep; do
Quoted 8 lines
sleep 1
doneSince this is repeated in several test cases, move this logic to a common helper and use it in all affected test cases. This will help to avoid repeating the same code again several times in upcoming changes.
Signed-off-by Filipe Manana <[email protected]>
A few minor things below.
Quoted 18 lines
--- common/btrfs | 14 ++++++++++++++ tests/btrfs/060 | 8 ++------ tests/btrfs/061 | 10 ++++------ tests/btrfs/062 | 10 ++++------ tests/btrfs/063 | 10 ++++------ tests/btrfs/064 | 10 ++++------ tests/btrfs/255 | 8 ++------ 7 files changed, 34 insertions(+), 36 deletions(-)common/btrfs +0
-0@@ -308,6 +308,20 @@ _btrfs_stress_balance() done }
common/btrfs _btrfs_stress_balance() · line 320
Quoted 10 lines
common/btrfs +10
-0+# Kill a background process running _btrfs_stress_balance() +_btrfs_kill_stress_balance_pid() +{ + local balance_pid=$1 + + # Ignore if process already died. + kill $balance_pid &> /dev/null + wait $balance_pid &> /dev/null + # Wait for the balance operation to finish. + while ps aux | grep "balance start" | grep -qv grep; do
We can use pgrep instead. I will make the following changes before merging if you are okay with it.
- while ps aux | grep "balance start" | grep -qv grep; do
+ while pgrep -f "btrfs balance start" > /dev/null; do
Quoted 34 lines
common/btrfs +4
-0+ sleep 1 + done +} + # stress btrfs by creating/mounting/umounting/deleting subvolume in a loop _btrfs_stress_subvolume() {tests/btrfs/060 +2
-6@@ -57,12 +57,8 @@ run_test() wait $fsstress_pid touch $stop_file - kill $balance_pid - wait - # wait for the balance operation to finish - while ps aux | grep "balance start" | grep -qv grep; do - sleep 1 - done + wait $subvol_pid + _btrfs_kill_stress_balance_pid $balance_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1tests/btrfs/061 +0
-0@@ -51,12 +51,10 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid
tests/btrfs/061 run_test() · line 57
Quoted 10 lines
tests/btrfs/061 +4
-6- kill $balance_pid $scrub_pid - wait - # wait for the balance and scrub operations to finish - while ps aux | grep "balance start" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_balance_pid $balance_pid + kill $scrub_pid + wait $scrub_pid + # wait for the crub operation to finish
s/crub/scrub/
Thanks, Anand
Quoted 85 lines
tests/btrfs/061 +0
-0while ps aux | grep "scrub start" | grep -qv grep; do sleep 1 donetests/btrfs/062 +4
-6@@ -52,12 +52,10 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $balance_pid $defrag_pid - wait - # wait for the balance and defrag operations to finish - while ps aux | grep "balance start" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_balance_pid $balance_pid + kill $defrag_pid + wait $defrag_pid + # wait for the defrag operation to finish while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do sleep 1 donetests/btrfs/063 +4
-6@@ -51,12 +51,10 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $balance_pid $remount_pid - wait - # wait for the balance and remount loop to finish - while ps aux | grep "balance start" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_balance_pid $balance_pid + kill $remount_pid + wait $remount_pid + # wait for the remount loop to finish while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do sleep 1 donetests/btrfs/064 +4
-6@@ -63,12 +63,10 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $balance_pid $replace_pid - wait - # wait for the balance and replace operations to finish - while ps aux | grep "balance start" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_balance_pid $balance_pid + kill $replace_pid + wait $replace_pid + # wait for the replace operation to finish while ps aux | grep "replace start" | grep -qv grep; do sleep 1 donetests/btrfs/255 +2
-6@@ -41,12 +41,8 @@ for ((i = 0; i < 20; i++)); do $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT $BTRFS_UTIL_PROG quota disable $SCRATCH_MNT done -kill $balance_pid &> /dev/null -wait -# wait for the balance operation to finish -while ps aux | grep "balance start" | grep -qv grep; do - sleep 1 -done + +_btrfs_kill_stress_balance_pid $balance_pid echo "Silence is golden" status=0
Re: [PATCH 04/10] btrfs: add helper to kill background process running _btrfs_stress_scrub
In reply to [email protected]Quoted 36 lines · On 3/28/24 01:11, [email protected] wrote:
From: Filipe Manana <[email protected]>
Killing a background process running
_btrfs_stress_scrub()is not as simple as sending a signal to the process and waiting for it to die. Therefore we have the following logic to terminate such process:kill $pid
wait $pid
while ps aux | grep "scrub start" | grep -qv grep; do
sleep 1
doneSince this is repeated in several test cases, move this logic to a common helper and use it in all affected test cases. This will help to avoid repeating the same code again several times in upcoming changes.
Signed-off-by Filipe Manana <[email protected]>--- common/btrfs | 14 ++++++++++++++ tests/btrfs/061 | 7 +------ tests/btrfs/066 | 8 ++------ tests/btrfs/069 | 11 +++++------ tests/btrfs/072 | 11 +++++------ tests/btrfs/073 | 11 +++++------ 6 files changed, 32 insertions(+), 30 deletions(-)common/btrfs +2
-0@@ -349,6 +349,20 @@ _btrfs_stress_scrub() done } +# Kill a background process running _btrfs_stress_scrub() +_btrfs_kill_stress_scrub_pid()
common/btrfs _btrfs_stress_scrub() · line 363
Quoted 10 lines
common/btrfs +8
-0+{ + local scrub_pid=$1 + + # Ignore if process already died. + kill $scrub_pid &> /dev/null + wait $scrub_pid &> /dev/null + # Wait for the scrub operation to finish. + while ps aux | grep "scrub start" | grep -qv grep; do
This can be replaced by pgrep. I'll make the change if there are no objections.
while pgrep -f "btrfs scrub start" > /dev/null; do
Thanks, Anand
Quoted 123 lines
common/btrfs +4
-0+ sleep 1 + done +} + # stress btrfs by defragmenting every file/dir in a loop and compress file# contents while defragmenting if second argument is not "nocompress" _btrfs_stress_defrag()tests/btrfs/061 +1
-6@@ -52,12 +52,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid _btrfs_kill_stress_balance_pid $balance_pid - kill $scrub_pid - wait $scrub_pid - # wait for the crub operation to finish - while ps aux | grep "scrub start" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_scrub_pid $scrub_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1tests/btrfs/066 +2
-6@@ -57,12 +57,8 @@ run_test() wait $fsstress_pid touch $stop_file - kill $scrub_pid - wait - # wait for the scrub operation to finish - while ps aux | grep "scrub start" | grep -qv grep; do - sleep 1 - done + wait $subvol_pid + _btrfs_kill_stress_scrub_pid $scrub_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1tests/btrfs/069 +5
-6@@ -59,17 +59,16 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $replace_pid $scrub_pid - wait + kill $replace_pid + wait $replace_pid - # wait for the scrub and replace operations to finish - while ps aux | grep "scrub start" | grep -qv grep; do - sleep 1 - done + # wait for the replace operation to finish while ps aux | grep "replace start" | grep -qv grep; do sleep 1 done + _btrfs_kill_stress_scrub_pid $scrub_pid + echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 if [ $? -ne 0 ]; thentests/btrfs/072 +5
-6@@ -52,16 +52,15 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $scrub_pid $defrag_pid - wait - # wait for the scrub and defrag operations to finish - while ps aux | grep "scrub start" | grep -qv grep; do - sleep 1 - done + kill $defrag_pid + wait $defrag_pid + # wait for the defrag operation to finish while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do sleep 1 done + _btrfs_kill_stress_scrub_pid $scrub_pid + echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 if [ $? -ne 0 ]; thentests/btrfs/073 +5
-6@@ -51,16 +51,15 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $scrub_pid $remount_pid - wait - # wait for the scrub and remount operations to finish - while ps aux | grep "scrub start" | grep -qv grep; do - sleep 1 - done + kill $remount_pid + wait $remount_pid + # wait for the remount operation to finish while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do sleep 1 done + _btrfs_kill_stress_scrub_pid $scrub_pid + echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 if [ $? -ne 0 ]; then
Re: [PATCH 02/10] btrfs/028: use the helper _btrfs_kill_stress_balance_pid
In reply to [email protected]Quoted 17 lines · On 3/28/24 01:11, [email protected] wrote:
From: Filipe Manana <[email protected]>
Now that there's a helper to kill a background process that is running
_btrfs_stress_balance(), use it in btrfs/028. It's equivalent to the existing code in btrfs/028.Signed-off-by Filipe Manana <[email protected]>--- tests/btrfs/028 | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)tests/btrfs/028 +0
-0@@ -44,12 +44,9 @@ balance_pid=$!
tests/btrfs/028 balance_pid=$! · line 49
Quoted 10 lines
tests/btrfs/028 +3
-5# 30s is enough to trigger bug sleep $((30*$TIME_FACTOR)) -kill $fsstress_pid $balance_pid &> /dev/null -wait - -# kill _btrfs_stress_balance can't end balance, so call btrfs balance cancel -# to cancel running or paused balance. > -$BTRFS_UTIL_PROG balance cancel $SCRATCH_MNT &> /dev/null +kill $fsstress_pid &> /dev/null +wait $fsstress_pid &> /dev/null +_btrfs_kill_stress_balance_pid $balance_pid
I didn't understand the point of replacing 'balance cancel' with 'kill'. The Git change log also doesn't say anything about it. The old code also tested BTRFS_IOC_BALANCE_CTL ioctl.
Thanks, Anand
Quoted 2 lines
tests/btrfs/028 +0
-0_run_btrfs_util_prog filesystem sync $SCRATCH_MNT
Re: [PATCH 05/10] btrfs: add helper to kill background process running _btrfs_stress_defrag
In reply to [email protected]Quoted 34 lines · On 3/28/24 01:11, [email protected] wrote:
From: Filipe Manana <[email protected]>
Killing a background process running
_btrfs_stress_defrag()is not as simple as sending a signal to the process and waiting for it to die. Therefore we have the following logic to terminate such process:kill $pid
wait $pid
while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
sleep 1
doneSince this is repeated in several test cases, move this logic to a common helper and use it in all affected test cases. This will help to avoid repeating the same code again several times in upcoming changes.
Signed-off-by Filipe Manana <[email protected]>--- common/btrfs | 14 ++++++++++++++ tests/btrfs/062 | 7 +------ tests/btrfs/067 | 8 ++------ tests/btrfs/070 | 11 +++++------ tests/btrfs/072 | 7 +------ tests/btrfs/074 | 11 +++++------ 6 files changed, 28 insertions(+), 30 deletions(-)common/btrfs +0
-0@@ -383,6 +383,20 @@ _btrfs_stress_defrag() done }
common/btrfs _btrfs_stress_defrag() · line 395
Quoted 10 lines
common/btrfs +10
-0+# Kill a background process running _btrfs_stress_defrag() +_btrfs_kill_stress_defrag_pid() +{ + local defrag_pid=$1 + + # Ignore if process already died. + kill $defrag_pid &> /dev/null + wait $defrag_pid &> /dev/null + # Wait for the defrag operation to finish. + while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
The same comments apply here regarding the use of pgrep.
Looks good.
Thanks, Anand
Quoted 116 lines
common/btrfs +4
-0+ sleep 1 + done +} + # stress btrfs by remounting it with different compression algorithms in a loop # run this with fsstress running at background could exercise the compression # code path and ensure no race when switching compression algorithm with constanttests/btrfs/062 +1
-6@@ -53,12 +53,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid _btrfs_kill_stress_balance_pid $balance_pid - kill $defrag_pid - wait $defrag_pid - # wait for the defrag operation to finish - while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_defrag_pid $defrag_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1tests/btrfs/067 +2
-6@@ -58,12 +58,8 @@ run_test() wait $fsstress_pid touch $stop_file - kill $defrag_pid - wait - # wait for btrfs defrag process to exit, otherwise it will block umount - while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do - sleep 1 - done + wait $subvol_pid + _btrfs_kill_stress_defrag_pid $defrag_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1tests/btrfs/070 +5
-6@@ -60,17 +60,16 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $replace_pid $defrag_pid - wait + kill $replace_pid + wait $replace_pid - # wait for the defrag and replace operations to finish - while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do - sleep 1 - done + # wait for the replace operation to finish while ps aux | grep "replace start" | grep -qv grep; do sleep 1 done + _btrfs_kill_stress_defrag_pid $defrag_pid + echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 if [ $? -ne 0 ]; thentests/btrfs/072 +1
-6@@ -52,13 +52,8 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $defrag_pid - wait $defrag_pid - # wait for the defrag operation to finish - while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_defrag_pid $defrag_pid _btrfs_kill_stress_scrub_pid $scrub_pid echo "Scrub the filesystem" >>$seqres.fulltests/btrfs/074 +5
-6@@ -52,16 +52,15 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $defrag_pid $remount_pid - wait - # wait for the defrag and remount operations to finish - while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do - sleep 1 - done + kill $remount_pid + wait $remount_pid + # wait for the remount operation to finish while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do sleep 1 done + _btrfs_kill_stress_defrag_pid $defrag_pid + echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 if [ $? -ne 0 ]; then
Re: [PATCH 01/10] btrfs: add helper to kill background process running _btrfs_stress_balance
In reply to Anand JainQuoted 45 lines · Anand Jain
Quoted 12 lines · On 3/28/24 01:11, [email protected] wrote:
From: Filipe Manana <[email protected]>
Killing a background process running
_btrfs_stress_balance()is not as simple as sending a signal to the process and waiting for it to die. Therefore we have the following logic to terminate such process:kill $pid
wait $pid
# Wait for the balance operation to finish. while ps aux | grep "balance start" | grep -qv grep; doQuoted 8 lines
sleep 1
doneSince this is repeated in several test cases, move this logic to a common helper and use it in all affected test cases. This will help to avoid repeating the same code again several times in upcoming changes.
Signed-off-by Filipe Manana <[email protected]>Reviewed-by Anand Jain <[email protected]>A few minor things below.
Quoted 18 lines
--- common/btrfs | 14 ++++++++++++++ tests/btrfs/060 | 8 ++------ tests/btrfs/061 | 10 ++++------ tests/btrfs/062 | 10 ++++------ tests/btrfs/063 | 10 ++++------ tests/btrfs/064 | 10 ++++------ tests/btrfs/255 | 8 ++------ 7 files changed, 34 insertions(+), 36 deletions(-)common/btrfs +0
-0@@ -308,6 +308,20 @@ _btrfs_stress_balance() done }
Quoted 14 lines
common/btrfs _btrfs_stress_balance() · line 320
Quoted 10 lines
common/btrfs +10
-0+# Kill a background process running _btrfs_stress_balance() +_btrfs_kill_stress_balance_pid() +{ + local balance_pid=$1 + + # Ignore if process already died. + kill $balance_pid &> /dev/null + wait $balance_pid &> /dev/null + # Wait for the balance operation to finish. + while ps aux | grep "balance start" | grep -qv grep; doWe can use pgrep instead. I will make the following changes before merging if you are okay with it.
Not doing such a change was intentional, as the goal is just to move repeated code into a helper.
I would prefer for such change to be done separately in its own patch.
Quoted 38 lines
(quoted diff) +1
-1- while ps aux | grep "balance start" | grep -qv grep; do + while pgrep -f "btrfs balance start" > /dev/null; doQuoted 35 lines
common/btrfs +4
-0+ sleep 1 + done +} + # stress btrfs by creating/mounting/umounting/deleting subvolume in a loop _btrfs_stress_subvolume() {tests/btrfs/060 +2
-6@@ -57,12 +57,8 @@ run_test() wait $fsstress_pid touch $stop_file - kill $balance_pid - wait - # wait for the balance operation to finish - while ps aux | grep "balance start" | grep -qv grep; do - sleep 1 - done + wait $subvol_pid + _btrfs_kill_stress_balance_pid $balance_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1tests/btrfs/061 +0
-0@@ -51,12 +51,10 @@ run_test()
Quoted 14 lines
tests/btrfs/061 run_test() · line 57
Quoted 12 lines
tests/btrfs/061 +4
-6echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $balance_pid $scrub_pid - wait - # wait for the balance and scrub operations to finish - while ps aux | grep "balance start" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_balance_pid $balance_pid + kill $scrub_pid + wait $scrub_pid + # wait for the crub operation to finishs/crub/scrub/
Yeah, but the comment is going away in the patch that adds the helper to kill scrub.
Thanks.
Quoted 89 lines
Thanks, Anand
Quoted 85 lines
tests/btrfs/061 +0
-0while ps aux | grep "scrub start" | grep -qv grep; do sleep 1 donetests/btrfs/062 +4
-6@@ -52,12 +52,10 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $balance_pid $defrag_pid - wait - # wait for the balance and defrag operations to finish - while ps aux | grep "balance start" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_balance_pid $balance_pid + kill $defrag_pid + wait $defrag_pid + # wait for the defrag operation to finish while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do sleep 1 donetests/btrfs/063 +4
-6@@ -51,12 +51,10 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $balance_pid $remount_pid - wait - # wait for the balance and remount loop to finish - while ps aux | grep "balance start" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_balance_pid $balance_pid + kill $remount_pid + wait $remount_pid + # wait for the remount loop to finish while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do sleep 1 donetests/btrfs/064 +4
-6@@ -63,12 +63,10 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $balance_pid $replace_pid - wait - # wait for the balance and replace operations to finish - while ps aux | grep "balance start" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_balance_pid $balance_pid + kill $replace_pid + wait $replace_pid + # wait for the replace operation to finish while ps aux | grep "replace start" | grep -qv grep; do sleep 1 donetests/btrfs/255 +2
-6@@ -41,12 +41,8 @@ for ((i = 0; i < 20; i++)); do $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT $BTRFS_UTIL_PROG quota disable $SCRATCH_MNT done -kill $balance_pid &> /dev/null -wait -# wait for the balance operation to finish -while ps aux | grep "balance start" | grep -qv grep; do - sleep 1 -done + +_btrfs_kill_stress_balance_pid $balance_pid echo "Silence is golden" status=0
Re: [PATCH 06/10] btrfs: add helper to kill background process running _btrfs_stress_remount_compress
In reply to [email protected]Quoted 12 lines · On 3/28/24 01:11, [email protected] wrote:
From: Filipe Manana <[email protected]>
Killing a background process running
_btrfs_stress_remount_compress()is not as simple as sending a signal to the process and waiting for it to die. Therefore we have the following logic to terminate such process:kill $pid
wait $pid
while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do
sleep 1
done
Quoted 5 lines
Since this is repeated in several test cases, move this logic to a common helper and use it in all affected test cases. This will help to avoid repeating the same code again several times in upcoming changes.
Signed-off-by Filipe Manana <[email protected]>
Thanks, Anand
Quoted 137 lines
--- common/btrfs | 15 +++++++++++++++ tests/btrfs/063 | 7 +------ tests/btrfs/068 | 8 ++------ tests/btrfs/071 | 12 +++++------- tests/btrfs/073 | 8 +------- tests/btrfs/074 | 8 +------- 6 files changed, 25 insertions(+), 33 deletions(-)common/btrfs +15
-0@@ -411,6 +411,21 @@ _btrfs_stress_remount_compress() done } +# Kill a background process running _btrfs_stress_remount_compress() +_btrfs_kill_stress_remount_compress_pid() +{ + local remount_pid=$1 + local btrfs_mnt=$2 + + # Ignore if process already died. + kill $remount_pid &> /dev/null + wait $remount_pid &> /dev/null + # Wait for the remount loop to finish. + while ps aux | grep "mount.*${btrfs_mnt}" | grep -qv grep; do + sleep 1 + done +} + # stress btrfs by replacing devices in a loop # Note that at least 3 devices are needed in SCRATCH_DEV_POOL and the last # device should be free(not used by btrfs)tests/btrfs/063 +1
-6@@ -52,12 +52,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid _btrfs_kill_stress_balance_pid $balance_pid - kill $remount_pid - wait $remount_pid - # wait for the remount loop to finish - while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1tests/btrfs/068 +2
-6@@ -58,12 +58,8 @@ run_test() wait $fsstress_pid touch $stop_file - kill $remount_pid - wait - # wait for the remount loop process to finish - while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do - sleep 1 - done + wait $subvol_pid + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1tests/btrfs/071 +5
-7@@ -58,17 +58,15 @@ run_test() echo "$remount_pid" >>$seqres.full echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full - wait $fsstress_pid - kill $replace_pid $remount_pid - wait + kill $replace_pid + wait $fsstress_pid $replace_pid - # wait for the remount and replace operations to finish + # wait for the replace operationss to finish while ps aux | grep "replace start" | grep -qv grep; do sleep 1 done - while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do - sleep 1 - done + + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1tests/btrfs/073 +1
-7@@ -51,13 +51,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $remount_pid - wait $remount_pid - # wait for the remount operation to finish - while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do - sleep 1 - done - + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT _btrfs_kill_stress_scrub_pid $scrub_pid echo "Scrub the filesystem" >>$seqres.fulltests/btrfs/074 +1
-7@@ -52,13 +52,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $remount_pid - wait $remount_pid - # wait for the remount operation to finish - while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do - sleep 1 - done - + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT _btrfs_kill_stress_defrag_pid $defrag_pid echo "Scrub the filesystem" >>$seqres.full
Re: [PATCH 02/10] btrfs/028: use the helper _btrfs_kill_stress_balance_pid
In reply to Anand JainQuoted 19 lines · Anand Jain
Quoted 17 lines · On 3/28/24 01:11, [email protected] wrote:
From: Filipe Manana <[email protected]>
Now that there's a helper to kill a background process that is running
_btrfs_stress_balance(), use it in btrfs/028. It's equivalent to the existing code in btrfs/028.Signed-off-by Filipe Manana <[email protected]>--- tests/btrfs/028 | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)tests/btrfs/028 +0
-0@@ -44,12 +44,9 @@ balance_pid=$!
Quoted 14 lines
tests/btrfs/028 balance_pid=$! · line 49
Quoted 10 lines
tests/btrfs/028 +3
-5# 30s is enough to trigger bug sleep $((30*$TIME_FACTOR)) -kill $fsstress_pid $balance_pid &> /dev/null -wait - -# kill _btrfs_stress_balance can't end balance, so call btrfs balance cancel -# to cancel running or paused balance. > -$BTRFS_UTIL_PROG balance cancel $SCRATCH_MNT &> /dev/null +kill $fsstress_pid &> /dev/null +wait $fsstress_pid &> /dev/null +_btrfs_kill_stress_balance_pid $balance_pidI didn't understand the point of replacing 'balance cancel' with 'kill'. The Git change log also doesn't say anything about it. The old code also tested
BTRFS_IOC_BALANCE_CTLioctl.
The point is to use the helper to kill the background task running balance in a loop, so for every _btrfs_stress_balance() call we have a matching _btrfs_kill_stress_balance_pid().
Doing the kill + cancel is equivalent to what the helper does, and the goal of the test is not to exercise the balance cancel.
Thanks.
Quoted 7 lines
Thanks, Anand
Quoted 2 lines
tests/btrfs/028 +0
-0_run_btrfs_util_prog filesystem sync $SCRATCH_MNT
Re: [PATCH 04/10] btrfs: add helper to kill background process running _btrfs_stress_scrub
In reply to Anand JainQuoted 47 lines · Anand Jain
Quoted 43 lines · On 3/28/24 01:11, [email protected] wrote:
From: Filipe Manana <[email protected]>
Killing a background process running
_btrfs_stress_scrub()is not as simple as sending a signal to the process and waiting for it to die. Therefore we have the following logic to terminate such process:kill $pid
wait $pid
while ps aux | grep "scrub start" | grep -qv grep; do
sleep 1
doneSince this is repeated in several test cases, move this logic to a common helper and use it in all affected test cases. This will help to avoid repeating the same code again several times in upcoming changes.
Signed-off-by Filipe Manana <[email protected]>--- common/btrfs | 14 ++++++++++++++ tests/btrfs/061 | 7 +------ tests/btrfs/066 | 8 ++------ tests/btrfs/069 | 11 +++++------ tests/btrfs/072 | 11 +++++------ tests/btrfs/073 | 11 +++++------ 6 files changed, 32 insertions(+), 30 deletions(-)common/btrfs +9
-0@@ -349,6 +349,20 @@ _btrfs_stress_scrub() done } +# Kill a background process running _btrfs_stress_scrub() +_btrfs_kill_stress_scrub_pid() +{ + local scrub_pid=$1 + + # Ignore if process already died. + kill $scrub_pid &> /dev/null + wait $scrub_pid &> /dev/null + # Wait for the scrub operation to finish.
Quoted 4 lines
common/btrfs _btrfs_stress_scrub() · line 361
Quoted 1 line
common/btrfs +1
-0+ while ps aux | grep "scrub start" | grep -qv grep; doThis can be replaced by pgrep. I'll make the change if there are no objections.
Yes, but as previously pointed out, the goal of the patch is just to move repeated code into a helper function.
I would prefer such a change to be done separately.
Thanks.
Quoted 129 lines
while pgrep -f "btrfs scrub start" >
/dev/null; doThanks, Anand
Quoted 123 lines
common/btrfs +4
-0+ sleep 1 + done +} + # stress btrfs by defragmenting every file/dir in a loop and compress file # contents while defragmenting if second argument is not "nocompress" _btrfs_stress_defrag()tests/btrfs/061 +1
-6@@ -52,12 +52,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid _btrfs_kill_stress_balance_pid $balance_pid - kill $scrub_pid - wait $scrub_pid - # wait for the crub operation to finish - while ps aux | grep "scrub start" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_scrub_pid $scrub_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1tests/btrfs/066 +2
-6@@ -57,12 +57,8 @@ run_test() wait $fsstress_pid touch $stop_file - kill $scrub_pid - wait - # wait for the scrub operation to finish - while ps aux | grep "scrub start" | grep -qv grep; do - sleep 1 - done + wait $subvol_pid + _btrfs_kill_stress_scrub_pid $scrub_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1tests/btrfs/069 +5
-6@@ -59,17 +59,16 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $replace_pid $scrub_pid - wait + kill $replace_pid + wait $replace_pid - # wait for the scrub and replace operations to finish - while ps aux | grep "scrub start" | grep -qv grep; do - sleep 1 - done + # wait for the replace operation to finish while ps aux | grep "replace start" | grep -qv grep; do sleep 1 done + _btrfs_kill_stress_scrub_pid $scrub_pid + echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 if [ $? -ne 0 ]; thentests/btrfs/072 +5
-6@@ -52,16 +52,15 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $scrub_pid $defrag_pid - wait - # wait for the scrub and defrag operations to finish - while ps aux | grep "scrub start" | grep -qv grep; do - sleep 1 - done + kill $defrag_pid + wait $defrag_pid + # wait for the defrag operation to finish while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do sleep 1 done + _btrfs_kill_stress_scrub_pid $scrub_pid + echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 if [ $? -ne 0 ]; thentests/btrfs/073 +5
-6@@ -51,16 +51,15 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $scrub_pid $remount_pid - wait - # wait for the scrub and remount operations to finish - while ps aux | grep "scrub start" | grep -qv grep; do - sleep 1 - done + kill $remount_pid + wait $remount_pid + # wait for the remount operation to finish while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do sleep 1 done + _btrfs_kill_stress_scrub_pid $scrub_pid + echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 if [ $? -ne 0 ]; then
Re: [PATCH 05/10] btrfs: add helper to kill background process running _btrfs_stress_defrag
In reply to Anand JainQuoted 36 lines · Anand Jain
Quoted 34 lines · On 3/28/24 01:11, [email protected] wrote:
From: Filipe Manana <[email protected]>
Killing a background process running
_btrfs_stress_defrag()is not as simple as sending a signal to the process and waiting for it to die. Therefore we have the following logic to terminate such process:kill $pid
wait $pid
while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
sleep 1
doneSince this is repeated in several test cases, move this logic to a common helper and use it in all affected test cases. This will help to avoid repeating the same code again several times in upcoming changes.
Signed-off-by Filipe Manana <[email protected]>--- common/btrfs | 14 ++++++++++++++ tests/btrfs/062 | 7 +------ tests/btrfs/067 | 8 ++------ tests/btrfs/070 | 11 +++++------ tests/btrfs/072 | 7 +------ tests/btrfs/074 | 11 +++++------ 6 files changed, 28 insertions(+), 30 deletions(-)common/btrfs +0
-0@@ -383,6 +383,20 @@ _btrfs_stress_defrag() done }
Quoted 12 lines
common/btrfs _btrfs_stress_defrag() · line 395
Quoted 10 lines
common/btrfs +10
-0+# Kill a background process running _btrfs_stress_defrag() +_btrfs_kill_stress_defrag_pid() +{ + local defrag_pid=$1 + + # Ignore if process already died. + kill $defrag_pid &> /dev/null + wait $defrag_pid &> /dev/null + # Wait for the defrag operation to finish. + while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; doThe same comments apply here regarding the use of pgrep.
Yes, but as previously pointed out, the goal of the patch is just to move repeated code into a helper function.
I would prefer such a change to be done separately.
Thanks.
Quoted 123 lines
Looks good.
Reviewed-by Anand Jain <[email protected]>Thanks, Anand
Quoted 116 lines
common/btrfs +4
-0+ sleep 1 + done +} + # stress btrfs by remounting it with different compression algorithms in a loop # run this with fsstress running at background could exercise the compression # code path and ensure no race when switching compression algorithm with constanttests/btrfs/062 +1
-6@@ -53,12 +53,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid _btrfs_kill_stress_balance_pid $balance_pid - kill $defrag_pid - wait $defrag_pid - # wait for the defrag operation to finish - while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_defrag_pid $defrag_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1tests/btrfs/067 +2
-6@@ -58,12 +58,8 @@ run_test() wait $fsstress_pid touch $stop_file - kill $defrag_pid - wait - # wait for btrfs defrag process to exit, otherwise it will block umount - while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do - sleep 1 - done + wait $subvol_pid + _btrfs_kill_stress_defrag_pid $defrag_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1tests/btrfs/070 +5
-6@@ -60,17 +60,16 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $replace_pid $defrag_pid - wait + kill $replace_pid + wait $replace_pid - # wait for the defrag and replace operations to finish - while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do - sleep 1 - done + # wait for the replace operation to finish while ps aux | grep "replace start" | grep -qv grep; do sleep 1 done + _btrfs_kill_stress_defrag_pid $defrag_pid + echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 if [ $? -ne 0 ]; thentests/btrfs/072 +1
-6@@ -52,13 +52,8 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $defrag_pid - wait $defrag_pid - # wait for the defrag operation to finish - while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_defrag_pid $defrag_pid _btrfs_kill_stress_scrub_pid $scrub_pid echo "Scrub the filesystem" >>$seqres.fulltests/btrfs/074 +5
-6@@ -52,16 +52,15 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $defrag_pid $remount_pid - wait - # wait for the defrag and remount operations to finish - while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do - sleep 1 - done + kill $remount_pid + wait $remount_pid + # wait for the remount operation to finish while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do sleep 1 done + _btrfs_kill_stress_defrag_pid $defrag_pid + echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 if [ $? -ne 0 ]; then
Re: [PATCH 07/10] btrfs: add helper to kill background process running _btrfs_stress_replace
In reply to [email protected]Quoted 12 lines · On 3/28/24 01:11, [email protected] wrote:
From: Filipe Manana <[email protected]>
Killing a background process running
_btrfs_stress_replace()is not as simple as sending a signal to the process and waiting for it to die. Therefore we have the following logic to terminate such process:kill $pid
wait $pid
while ps aux | grep "replace start" | grep -qv grep; do
sleep 1
done
Quoted 5 lines
Since this is repeated in several test cases, move this logic to a common helper and use it in all affected test cases. This will help to avoid repeating the same code again several times in upcoming changes.
Signed-off-by Filipe Manana <[email protected]>
Thanks, Anand
Quoted 133 lines
--- common/btrfs | 14 ++++++++++++++ tests/btrfs/064 | 7 +------ tests/btrfs/065 | 8 ++------ tests/btrfs/069 | 9 +-------- tests/btrfs/070 | 9 +-------- tests/btrfs/071 | 10 ++-------- 6 files changed, 21 insertions(+), 36 deletions(-)common/btrfs +14
-0@@ -475,6 +475,20 @@ _btrfs_stress_replace() done } +# Kill a background process running _btrfs_stress_replace() +_btrfs_kill_stress_replace_pid() +{ + local replace_pid=$1 + + # Ignore if process already died. + kill $replace_pid &> /dev/null + wait $replace_pid &> /dev/null + # Wait for the replace operation to finish. + while ps aux | grep "replace start" | grep -qv grep; do + sleep 1 + done +} + # find the right option to force output in bytes, older versions of btrfs-progs # print that by default, newer print human readable numbers with unit suffix _btrfs_qgroup_units()tests/btrfs/064 +1
-6@@ -64,12 +64,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid _btrfs_kill_stress_balance_pid $balance_pid - kill $replace_pid - wait $replace_pid - # wait for the replace operation to finish - while ps aux | grep "replace start" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_replace_pid $replace_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1tests/btrfs/065 +2
-6@@ -65,12 +65,8 @@ run_test() wait $fsstress_pid touch $stop_file - kill $replace_pid - wait - # wait for the replace operation to finish - while ps aux | grep "replace start" | grep -qv grep; do - sleep 1 - done + wait $subvol_pid + _btrfs_kill_stress_replace_pid $replace_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1tests/btrfs/069 +1
-8@@ -59,15 +59,8 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $replace_pid - wait $replace_pid - - # wait for the replace operation to finish - while ps aux | grep "replace start" | grep -qv grep; do - sleep 1 - done - _btrfs_kill_stress_scrub_pid $scrub_pid + _btrfs_kill_stress_replace_pid $replace_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1tests/btrfs/070 +1
-8@@ -60,14 +60,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $replace_pid - wait $replace_pid - - # wait for the replace operation to finish - while ps aux | grep "replace start" | grep -qv grep; do - sleep 1 - done - + _btrfs_kill_stress_replace_pid $replace_pid _btrfs_kill_stress_defrag_pid $defrag_pid echo "Scrub the filesystem" >>$seqres.fulltests/btrfs/071 +2
-8@@ -58,14 +58,8 @@ run_test() echo "$remount_pid" >>$seqres.full echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full - kill $replace_pid - wait $fsstress_pid $replace_pid - - # wait for the replace operationss to finish - while ps aux | grep "replace start" | grep -qv grep; do - sleep 1 - done - + wait $fsstress_pid + _btrfs_kill_stress_replace_pid $replace_pid _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT echo "Scrub the filesystem" >>$seqres.full
Re: [PATCH 08/10] btrfs: add helper to stop background process running _btrfs_stress_subvolume
In reply to [email protected]Quoted 8 lines · On 3/28/24 01:11, [email protected] wrote:
From: Filipe Manana <[email protected]>
We have this logic to stop a process running
_btrfs_stress_subvolume()spread in several test cases:touch $stop_file
wait $subvol_pid
Quoted 7 lines
Add a helper to encapsulate that logic and also remove the stop file after the process terminated as there's no point having it around anymore.
This will help to avoid repeating the same code again several times in upcoming changes.
Signed-off-by Filipe Manana <[email protected]>
Thanks, Anand
Quoted 102 lines
--- common/btrfs | 12 ++++++++++++ tests/btrfs/060 | 3 +-- tests/btrfs/065 | 3 +-- tests/btrfs/066 | 3 +-- tests/btrfs/067 | 3 +-- tests/btrfs/068 | 3 +-- 6 files changed, 17 insertions(+), 10 deletions(-)common/btrfs +12
-0@@ -340,6 +340,18 @@ _btrfs_stress_subvolume() done } +# Kill a background process running _btrfs_stress_subvolume() +_btrfs_kill_stress_subvolume_pid() +{ + local subvol_pid=$1 + local stop_file=$2 + + touch $stop_file + # Ignore if process already died. + wait $subvol_pid &> /dev/null + rm -f $stop_file +} + # stress btrfs by running scrub in a loop _btrfs_stress_scrub() {tests/btrfs/060 +1
-2@@ -56,8 +56,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - touch $stop_file - wait $subvol_pid + _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file _btrfs_kill_stress_balance_pid $balance_pid echo "Scrub the filesystem" >>$seqres.fulltests/btrfs/065 +1
-2@@ -64,8 +64,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - touch $stop_file - wait $subvol_pid + _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file _btrfs_kill_stress_replace_pid $replace_pid echo "Scrub the filesystem" >>$seqres.fulltests/btrfs/066 +1
-2@@ -56,8 +56,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - touch $stop_file - wait $subvol_pid + _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file _btrfs_kill_stress_scrub_pid $scrub_pid echo "Scrub the filesystem" >>$seqres.fulltests/btrfs/067 +1
-2@@ -57,8 +57,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - touch $stop_file - wait $subvol_pid + _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file _btrfs_kill_stress_defrag_pid $defrag_pid echo "Scrub the filesystem" >>$seqres.fulltests/btrfs/068 +1
-2@@ -57,8 +57,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - touch $stop_file - wait $subvol_pid + _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT echo "Scrub the filesystem" >>$seqres.full
Re: [PATCH 09/10] btrfs: remove stop file early at _btrfs_stress_subvolume
In reply to [email protected]Quoted 8 lines · On 3/28/24 01:11, [email protected] wrote:
From: Filipe Manana <[email protected]>
Instead of having every test case that uses
_btrfs_stress_subvolume()removing the stop file before calling that function, do the file remove at_btrfs_stress_subvolume(). There's no point in doing it in every single test case.Signed-off-by Filipe Manana <[email protected]>
Thanks Anand
Quoted 86 lines
--- common/btrfs | 1 + tests/btrfs/060 | 2 -- tests/btrfs/065 | 2 -- tests/btrfs/066 | 2 -- tests/btrfs/067 | 2 -- tests/btrfs/068 | 2 -- 6 files changed, 1 insertion(+), 10 deletions(-)common/btrfs +1
-0@@ -331,6 +331,7 @@ _btrfs_stress_subvolume() local subvol_mnt=$4 local stop_file=$5 + rm -f $stop_file mkdir -p $subvol_mnt while [ ! -e $stop_file ]; do $BTRFS_UTIL_PROG subvolume create $btrfs_mnt/$subvol_nametests/btrfs/060 +0
-2@@ -46,8 +46,6 @@ run_test() balance_pid=$! echo "$balance_pid" >>$seqres.full - # make sure the stop sign is not there - rm -f $stop_file echo -n "Start subvolume worker: " >>$seqres.full _btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 & subvol_pid=$!tests/btrfs/065 +0
-2@@ -49,8 +49,6 @@ run_test() $FSSTRESS_PROG $args >>$seqres.full & fsstress_pid=$! - # make sure the stop sign is not there - rm -f $stop_file echo -n "Start subvolume worker: " >>$seqres.full _btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 & subvol_pid=$!tests/btrfs/066 +0
-2@@ -41,8 +41,6 @@ run_test() $FSSTRESS_PROG $args >>$seqres.full & fsstress_pid=$! - # make sure the stop sign is not there - rm -f $stop_file echo -n "Start subvolume worker: " >>$seqres.full _btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 & subvol_pid=$!tests/btrfs/067 +0
-2@@ -42,8 +42,6 @@ run_test() $FSSTRESS_PROG $args >>$seqres.full & fsstress_pid=$! - # make sure the stop sign is not there - rm -f $stop_file echo -n "Start subvolume worker: " >>$seqres.full _btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 & subvol_pid=$!tests/btrfs/068 +0
-2@@ -42,8 +42,6 @@ run_test() $FSSTRESS_PROG $args >>$seqres.full & fsstress_pid=$! - # make sure the stop sign is not there - rm -f $stop_file echo -n "Start subvolume worker: " >>$seqres.full _btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 & subvol_pid=$!
Re: [PATCH 10/10] btrfs/06[0-9]..07[0-4]: kill all background tasks when test is killed/interrupted
In reply to [email protected]Quoted 44 lines · On 3/28/24 01:11, [email protected] wrote:
From: Filipe Manana <[email protected]>
Test cases btrfs/06[0-9] and btrfs/07[0-4] exercise multiple concurrent operations while fsstress is running in parallel, and all these are left as child processes running in the background, which are correctly stopped if the tests are not interrupted/killed. However if any of these tests is interrupted/killed, it often leaves child processes still running in the background, which prevent further running fstests again. For example:
$ /check -g auto (...) btrfs/060 394s ... 264s btrfs/061 83s ... 69s btrfs/062 109s ... 105s btrfs/063 52s ... 67s btrfs/064 53s ... 51s btrfs/065 88s ... 271s btrfs/066 127s ... 241s btrfs/067 435s ... 248s btrfs/068 161s ... ^C^C ^C$ ./check btrfs/068 FSTYP -- btrfs PLATFORM -- Linux/x86_64 debian0 6.8.0-rc7-btrfs-next-153+ #1 SMP PREEMPT_DYNAMIC Mon Mar 4 17:19:19 WET 2024 MKFS_OPTIONS -- /dev/sdb MOUNT_OPTIONS -- /dev/sdb /home/fdmanana/btrfs-tests/scratch_1our local
_scratch_mkfsroutine ... btrfs-progs v6.6.2
See https://btrfs.readthedocs.io for more information.ERROR: unable to open
/dev/sdb: Device or resource busy
check: failed to mkfs $SCRATCH_DEV using specified options Interrupted!
Passed all 0 testsIn this case there was still a process running
_btrfs_stress_subvolume()from common/btrfs.This is a bit annoying because it requires manually finding out which process is preventing unmounting the scratch device and then properly stop/kill it.
Quoted 8 lines
So fix this by adding a
_cleanup()function to all these tests and then making sure it stops all the child processes it spawned and are running in the background.All these tests have the same structure as they were part of the same patchset and from the same author.
Signed-off-by Filipe Manana <[email protected]>
Thanks, Anand
Quoted 681 lines
--- tests/btrfs/060 | 22 +++++++++++++++++++++- tests/btrfs/061 | 19 +++++++++++++++++++ tests/btrfs/062 | 19 +++++++++++++++++++ tests/btrfs/063 | 19 +++++++++++++++++++ tests/btrfs/064 | 19 +++++++++++++++++++ tests/btrfs/065 | 22 +++++++++++++++++++++- tests/btrfs/066 | 22 +++++++++++++++++++++- tests/btrfs/067 | 22 +++++++++++++++++++++- tests/btrfs/068 | 22 +++++++++++++++++++++- tests/btrfs/069 | 19 +++++++++++++++++++ tests/btrfs/070 | 19 +++++++++++++++++++ tests/btrfs/071 | 19 +++++++++++++++++++ tests/btrfs/072 | 19 +++++++++++++++++++ tests/btrfs/073 | 19 +++++++++++++++++++ tests/btrfs/074 | 19 +++++++++++++++++++ 15 files changed, 295 insertions(+), 5 deletions(-)tests/btrfs/060 +21
-1@@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto balance subvol scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then + _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file + fi + if [ ! -z "$balance_pid" ]; then + _btrfs_kill_stress_balance_pid $balance_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter@@ -20,11 +36,12 @@ _require_scratch_nocheck _require_scratch_dev_pool 4 _btrfs_get_profile_configs +stop_file=$TEST_DIR/$seq.stop.$$ + run_test() { local mkfs_opts=$1 local subvol_mnt=$TEST_DIR/$seq.mnt - local stop_file=$TEST_DIR/$seq.stop.$$ echo "Test $mkfs_opts" >>$seqres.full@@ -53,9 +70,12 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file + unset subvol_pid _btrfs_kill_stress_balance_pid $balance_pid + unset balance_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1tests/btrfs/061 +19
-0@@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto balance scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$balance_pid" ]; then + _btrfs_kill_stress_balance_pid $balance_pid + fi + if [ ! -z "$scrub_pid" ]; then + _btrfs_kill_stress_scrub_pid $scrub_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter@@ -51,8 +67,11 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_balance_pid $balance_pid + unset balance_pid _btrfs_kill_stress_scrub_pid $scrub_pid + unset scrub_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1tests/btrfs/062 +19
-0@@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto balance defrag compress scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$balance_pid" ]; then + _btrfs_kill_stress_balance_pid $balance_pid + fi + if [ ! -z "$defrag_pid" ]; then + _btrfs_kill_stress_defrag_pid $defrag_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter@@ -52,8 +68,11 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_balance_pid $balance_pid + unset balance_pid _btrfs_kill_stress_defrag_pid $defrag_pid + unset defrag_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1tests/btrfs/063 +19
-0@@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto balance remount compress scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$balance_pid" ]; then + _btrfs_kill_stress_balance_pid $balance_pid + fi + if [ ! -z "$remount_pid" ]; then + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter@@ -51,8 +67,11 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_balance_pid $balance_pid + unset balance_pid _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT + unset remount_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1tests/btrfs/064 +19
-0@@ -12,6 +12,22 @@ . ./common/preamble _begin_fstest auto balance replace volume scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$balance_pid" ]; then + _btrfs_kill_stress_balance_pid $balance_pid + fi + if [ ! -z "$replace_pid" ]; then + _btrfs_kill_stress_replace_pid $replace_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter@@ -63,8 +79,11 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_balance_pid $balance_pid + unset balance_pid _btrfs_kill_stress_replace_pid $replace_pid + unset replace_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1tests/btrfs/065 +21
-1@@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto subvol replace volume scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then + _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file + fi + if [ ! -z "$replace_pid" ]; then + _btrfs_kill_stress_replace_pid $replace_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter@@ -21,12 +37,13 @@ _require_scratch_dev_pool 5 _require_scratch_dev_pool_equal_size _btrfs_get_profile_configs replace +stop_file=$TEST_DIR/$seq.stop.$$ + run_test() { local mkfs_opts=$1 local saved_scratch_dev_pool=$SCRATCH_DEV_POOL local subvol_mnt=$TEST_DIR/$seq.mnt - local stop_file=$TEST_DIR/$seq.stop.$$ echo "Test $mkfs_opts" >>$seqres.full@@ -61,9 +78,12 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file + unset subvol_pid _btrfs_kill_stress_replace_pid $replace_pid + unset replace_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1tests/btrfs/066 +21
-1@@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto subvol scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then + _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file + fi + if [ ! -z "$scrub_pid" ]; then + _btrfs_kill_stress_scrub_pid $scrub_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter@@ -20,11 +36,12 @@ _require_scratch_nocheck _require_scratch_dev_pool 4 _btrfs_get_profile_configs +stop_file=$TEST_DIR/$seq.stop.$$ + run_test() { local mkfs_opts=$1 local subvol_mnt=$TEST_DIR/$seq.mnt - local stop_file=$TEST_DIR/$seq.stop.$$ echo "Test $mkfs_opts" >>$seqres.full@@ -53,9 +70,12 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file + unset subvol_pid _btrfs_kill_stress_scrub_pid $scrub_pid + unset scrub_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1tests/btrfs/067 +21
-1@@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto subvol defrag compress scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then + _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file + fi + if [ ! -z "$defrag_pid" ]; then + _btrfs_kill_stress_defrag_pid $defrag_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter@@ -20,12 +36,13 @@ _require_scratch_nocheck _require_scratch_dev_pool 4 _btrfs_get_profile_configs +stop_file=$TEST_DIR/$seq.stop.$$ + run_test() { local mkfs_opts=$1 local with_compress=$2 local subvol_mnt=$TEST_DIR/$seq.mnt - local stop_file=$TEST_DIR/$seq.stop.$$ echo "Test $mkfs_opts with $with_compress" >>$seqres.full@@ -54,9 +71,12 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file + unset subvol_pid _btrfs_kill_stress_defrag_pid $defrag_pid + unset defrag_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1tests/btrfs/068 +21
-1@@ -11,6 +11,22 @@ . ./common/preamble _begin_fstest auto subvol remount compress scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then + _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file + fi + if [ ! -z "$remount_pid" ]; then + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter@@ -21,11 +37,12 @@ _require_scratch_nocheck _require_scratch_dev_pool 4 _btrfs_get_profile_configs +stop_file=$TEST_DIR/$seq.stop.$$ + run_test() { local mkfs_opts=$1 local subvol_mnt=$TEST_DIR/$seq.mnt - local stop_file=$TEST_DIR/$seq.stop.$$ echo "Test $mkfs_opts with $with_compress" >>$seqres.full@@ -54,9 +71,12 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file + unset subvol_pid _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT + unset remount_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1tests/btrfs/069 +19
-0@@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto replace scrub volume +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$replace_pid" ]; then + _btrfs_kill_stress_replace_pid $replace_pid + fi + if [ ! -z "$scrub_pid" ]; then + _btrfs_kill_stress_scrub_pid $scrub_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter@@ -59,8 +75,11 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_scrub_pid $scrub_pid + unset scrub_pid _btrfs_kill_stress_replace_pid $replace_pid + unset replace_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1tests/btrfs/070 +19
-0@@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto replace defrag compress volume scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$replace_pid" ]; then + _btrfs_kill_stress_replace_pid $replace_pid + fi + if [ ! -z "$defrag_pid" ]; then + _btrfs_kill_stress_defrag_pid $defrag_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter@@ -60,8 +76,11 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_replace_pid $replace_pid + unset replace_pid _btrfs_kill_stress_defrag_pid $defrag_pid + unset defrag_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1tests/btrfs/071 +19
-0@@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto replace remount compress volume scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$replace_pid" ]; then + _btrfs_kill_stress_replace_pid $replace_pid + fi + if [ ! -z "$remount_pid" ]; then + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter@@ -59,8 +75,11 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_replace_pid $replace_pid + unset replace_pid _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT + unset remount_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1tests/btrfs/072 +19
-0@@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto scrub defrag compress +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$defrag_pid" ]; then + _btrfs_kill_stress_defrag_pid $defrag_pid + fi + if [ ! -z "$scrub_pid" ]; then + _btrfs_kill_stress_scrub_pid $scrub_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter@@ -52,9 +68,12 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_defrag_pid $defrag_pid + unset defrag_pid _btrfs_kill_stress_scrub_pid $scrub_pid + unset scrub_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1tests/btrfs/073 +19
-0@@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto scrub remount compress +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$remount_pid" ]; then + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT + fi + if [ ! -z "$scrub_pid" ]; then + _btrfs_kill_stress_scrub_pid $scrub_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter@@ -51,8 +67,11 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT + unset remount_pid _btrfs_kill_stress_scrub_pid $scrub_pid + unset scrub_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1tests/btrfs/074 +19
-0@@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto defrag remount compress scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$remount_pid" ]; then + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT + fi + if [ ! -z "$defrag_pid" ]; then + _btrfs_kill_stress_defrag_pid $defrag_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter@@ -52,8 +68,11 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT + unset remount_pid _btrfs_kill_stress_defrag_pid $defrag_pid + unset defrag_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
Re: [PATCH 06/10] btrfs: add helper to kill background process running _btrfs_stress_remount_compress
In reply to Anand JainQuoted 10 lines
Quoted 7 lines
tests/btrfs/071 +0
-0@@ -58,17 +58,15 @@ run_test()echo "$remount_pid" >>$seqres.full
Quoted 7 lines
Quoted 7 lines
echo "Wait for fsstress to exit and kill all background workers"
Quoted 1 line
Quoted 1 line
$seqres.full
- wait $fsstress_pid
- kill $replace_pid $remount_pid
- wait
+ kill $replace_pid
+ wait $fsstress_pid $replace_pid
The change first kills the replace and then wait for fsstress. Was this intentional?
This patch is causing a regression. The replace never gets killed, as the echo-comment specifically states to wait for fsstress and then kill the replace. Following it fixes the issue.
Which the patch 7/10 reversed the order to fix. But why?
Thanks, Anand
Quoted 16 lines
Quoted 16 lines
- # wait for the remount and replace operations to finish + # wait for the replace operationss to finish
while ps aux | grep "replace start" | grep -qv grep; do sleep 1
done
- while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do - sleep 1
- done
+
+_btrfs_kill_stress_remount_compress_pid$remount_pid $SCRATCH_MNT echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
Re: [PATCH 06/10] btrfs: add helper to kill background process running _btrfs_stress_remount_compress
Quoted 13 lines · Anand Jain
Quoted 13 lines
Quoted 13 lines
tests/btrfs/071 +0
-0@@ -58,17 +58,15 @@ run_test() echo "$remount_pid" >>$seqres.full echo "Wait for fsstress to exit and kill all background workers"Quoted 1 line
Quoted 1 line
$seqres.full
Quoted 8 lines
Quoted 5 lines
tests/btrfs/071 run_test() · line 62
Quoted 5 lines
tests/btrfs/071 +2
-3- wait $fsstress_pid - kill $replace_pid $remount_pid - wait + kill $replace_pid + wait $fsstress_pid $replace_pidThe change first kills the replace and then wait for fsstress. Was this intentional?
It wasn't. But after all patches applied, everything's correct, we wait for fsstress to finish and then kill replace.
Do you want me to fix that?
The sequence will have to be:
wait $fsstress_pid
kill $replace_pid
wait $replace_pid
Thanks.
Quoted 26 lines
This patch is causing a regression. The replace never gets killed, as the echo-comment specifically states to wait for fsstress and then kill the replace. Following it fixes the issue.
Which the patch 7/10 reversed the order to fix. But why?
Thanks, Anand
Quoted 16 lines
Quoted 16 lines
tests/btrfs/071 +3
-4- # wait for the remount and replace operations to finish + # wait for the replace operationss to finish while ps aux | grep "replace start" | grep -qv grep; do sleep 1 done - while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do - sleep 1 - done + + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
Re: [PATCH 06/10] btrfs: add helper to kill background process running _btrfs_stress_remount_compress
Quoted 21 lines · Filipe Manana
Quoted 19 lines · Anand Jain
Quoted 18 lines
Quoted 18 lines
tests/btrfs/071 +0
-0@@ -58,17 +58,15 @@ run_test() echo "$remount_pid" >>$seqres.full echo "Wait for fsstress to exit and kill all background workers"Quoted 1 line
Quoted 1 line
$seqres.full
tests/btrfs/071 +2
-3- wait $fsstress_pid - kill $replace_pid $remount_pid - wait + kill $replace_pid + wait $fsstress_pid $replace_pid
Quoted 5 lines
Quoted 2 lines
The change first kills the replace and then wait for fsstress. Was this intentional?
It wasn't.
Ok. Thanks for confirming. I will fix it.
-Anand
Quoted 38 lines
But after all patches applied, everything's correct, we wait for fsstress to finish and then kill replace. Do you want me to fix that?
The sequence will have to be:
wait $fsstress_pid
kill $replace_pid
wait $replace_pidThanks.
Quoted 26 lines
This patch is causing a regression. The replace never gets killed, as the echo-comment specifically states to wait for fsstress and then kill the replace. Following it fixes the issue.
Which the patch 7/10 reversed the order to fix. But why?
Thanks, Anand
Quoted 16 lines
Quoted 16 lines
tests/btrfs/071 +3
-4- # wait for the remount and replace operations to finish + # wait for the replace operationss to finish while ps aux | grep "replace start" | grep -qv grep; do sleep 1 done - while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do - sleep 1 - done + + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1