]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
btrfs: add helper to stop background process running _btrfs_stress_subvolume
authorFilipe Manana <fdmanana@suse.com>
Wed, 27 Mar 2024 17:11:42 +0000 (17:11 +0000)
committerAnand Jain <anand.jain@oracle.com>
Wed, 3 Apr 2024 07:08:41 +0000 (15:08 +0800)
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>
common/btrfs
tests/btrfs/060
tests/btrfs/065
tests/btrfs/066
tests/btrfs/067
tests/btrfs/068

index 217373f54fd3f9ffe211ba08f63f02a882e6ab93..0f79b2510ff1716aae52964d3c514f90750a2bd4 100644 (file)
@@ -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()
 {
index 58167cc6ba7f35d93fdc0fb2b82be93c50e7dbc0..87823abad17859d0384f73c8c0e9a2cd52f07063 100755 (executable)
@@ -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
index d2b04178d69e48353b328529f9569a48dab7e498..ddc286161f418726b914f0ed1fd21aeb07b26e97 100755 (executable)
@@ -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
index 29821fddc05fa657501116c70dc0033248af5089..c74886027586e6d6aab728a8d1eede793ef29177 100755 (executable)
@@ -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
index 2bb00b875abaa57ffaf32ca1aa80fe38fce95d70..ebbec1beecb1d74cb48acee751effa42b22f14b7 100755 (executable)
@@ -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
index db53254a150d9bb3d1f7db3a0a8940fd778998d1..5f41fb7428f1554f57767827f07721a665faa504 100755 (executable)
@@ -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