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