aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@suse.com>2024-03-27 17:11:42 +0000
committerAnand Jain <anand.jain@oracle.com>2024-04-03 15:08:41 +0800
commitd2e240298b8c652b78ca5e8a3f13dc2a3f3066e8 (patch)
tree2ffed8e86965c75afaaf8ce16f9ddfa33832dce3
parent1305165c278eb1cd86e3677ee32603cd7801531f (diff)
downloadxfstests-dev-d2e240298b8c652b78ca5e8a3f13dc2a3f3066e8.tar.gz
btrfs: add helper to stop background process running _btrfs_stress_subvolume
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. Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: Anand Jain <anand.jain@oracle.com>
-rw-r--r--common/btrfs12
-rwxr-xr-xtests/btrfs/0603
-rwxr-xr-xtests/btrfs/0653
-rwxr-xr-xtests/btrfs/0663
-rwxr-xr-xtests/btrfs/0673
-rwxr-xr-xtests/btrfs/0683
6 files changed, 17 insertions, 10 deletions
diff --git a/common/btrfs b/common/btrfs
index 217373f54f..0f79b2510f 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -350,6 +350,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()
{
diff --git a/tests/btrfs/060 b/tests/btrfs/060
index 58167cc6ba..87823abad1 100755
--- a/tests/btrfs/060
+++ b/tests/btrfs/060
@@ -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
diff --git a/tests/btrfs/065 b/tests/btrfs/065
index d2b04178d6..ddc286161f 100755
--- a/tests/btrfs/065
+++ b/tests/btrfs/065
@@ -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
diff --git a/tests/btrfs/066 b/tests/btrfs/066
index 29821fddc0..c748860275 100755
--- a/tests/btrfs/066
+++ b/tests/btrfs/066
@@ -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
diff --git a/tests/btrfs/067 b/tests/btrfs/067
index 2bb00b875a..ebbec1beec 100755
--- a/tests/btrfs/067
+++ b/tests/btrfs/067
@@ -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
diff --git a/tests/btrfs/068 b/tests/btrfs/068
index db53254a15..5f41fb7428 100755
--- a/tests/btrfs/068
+++ b/tests/btrfs/068
@@ -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