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