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