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()
{
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
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
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
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
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
$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