]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
btrfs/06[0-9]..07[0-4]: kill all background tasks when test is killed/interrupted
authorFilipe Manana <fdmanana@suse.com>
Wed, 27 Mar 2024 17:11:44 +0000 (17:11 +0000)
committerAnand Jain <anand.jain@oracle.com>
Wed, 3 Apr 2024 07:08:54 +0000 (15:08 +0800)
Test cases btrfs/06[0-9] and btrfs/07[0-4] exercise multiple concurrent
operations while fsstress is running in parallel, and all these are left
as child processes running in the background, which are correctly stopped
if the tests are not interrupted/killed. However if any of these tests is
interrupted/killed, it often leaves child processes still running in the
background, which prevent further running fstests again. For example:

  $ /check -g auto
  (...)
  btrfs/060 394s ...  264s
  btrfs/061 83s ...  69s
  btrfs/062 109s ...  105s
  btrfs/063 52s ...  67s
  btrfs/064 53s ...  51s
  btrfs/065 88s ...  271s
  btrfs/066 127s ...  241s
  btrfs/067 435s ...  248s
  btrfs/068 161s ... ^C^C
  ^C

  $ ./check btrfs/068
  FSTYP         -- btrfs
  PLATFORM      -- Linux/x86_64 debian0 6.8.0-rc7-btrfs-next-153+ #1 SMP PREEMPT_DYNAMIC Mon Mar  4 17:19:19 WET 2024
  MKFS_OPTIONS  -- /dev/sdb
  MOUNT_OPTIONS -- /dev/sdb /home/fdmanana/btrfs-tests/scratch_1

  our local _scratch_mkfs routine ...
  btrfs-progs v6.6.2
  See https://btrfs.readthedocs.io for more information.

  ERROR: unable to open /dev/sdb: Device or resource busy
  check: failed to mkfs $SCRATCH_DEV using specified options
  Interrupted!
  Passed all 0 tests

In this case there was still a process running _btrfs_stress_subvolume()
from common/btrfs.

This is a bit annoying because it requires manually finding out which
process is preventing unmounting the scratch device and then properly
stop/kill it.

So fix this by adding a _cleanup() function to all these tests and then
making sure it stops all the child processes it spawned and are running
in the background.

All these tests have the same structure as they were part of the same
patchset and from the same author.

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>
15 files changed:
tests/btrfs/060
tests/btrfs/061
tests/btrfs/062
tests/btrfs/063
tests/btrfs/064
tests/btrfs/065
tests/btrfs/066
tests/btrfs/067
tests/btrfs/068
tests/btrfs/069
tests/btrfs/070
tests/btrfs/071
tests/btrfs/072
tests/btrfs/073
tests/btrfs/074

index 53cbd3a0d772adaee7e13148176741c1a314dbf6..f74d959347299d39d1ccdaa60a7448905a2fe187 100755 (executable)
 . ./common/preamble
 _begin_fstest auto balance subvol scrub
 
+_cleanup()
+{
+       cd /
+       rm -rf $tmp.*
+       if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then
+               _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
+       fi
+       if [ ! -z "$balance_pid" ]; then
+               _btrfs_kill_stress_balance_pid $balance_pid
+       fi
+       if [ ! -z "$fsstress_pid" ]; then
+               kill $fsstress_pid &> /dev/null
+               wait $fsstress_pid &> /dev/null
+       fi
+}
+
 # Import common functions.
 . ./common/filter
 
@@ -20,11 +36,12 @@ _require_scratch_nocheck
 _require_scratch_dev_pool 4
 _btrfs_get_profile_configs
 
+stop_file=$TEST_DIR/$seq.stop.$$
+
 run_test()
 {
        local mkfs_opts=$1
        local subvol_mnt=$TEST_DIR/$seq.mnt
-       local stop_file=$TEST_DIR/$seq.stop.$$
 
        echo "Test $mkfs_opts" >>$seqres.full
 
@@ -53,9 +70,12 @@ run_test()
 
        echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
        wait $fsstress_pid
+       unset fsstress_pid
 
        _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
+       unset subvol_pid
        _btrfs_kill_stress_balance_pid $balance_pid
+       unset balance_pid
 
        echo "Scrub the filesystem" >>$seqres.full
        $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
index b8b2706c666fe3a6f60fcf625f575db937b232d0..fec9088217f148d5b8f0384136261755b9d7ad76 100755 (executable)
 . ./common/preamble
 _begin_fstest auto balance scrub
 
+_cleanup()
+{
+       cd /
+       rm -rf $tmp.*
+       if [ ! -z "$balance_pid" ]; then
+               _btrfs_kill_stress_balance_pid $balance_pid
+       fi
+       if [ ! -z "$scrub_pid" ]; then
+               _btrfs_kill_stress_scrub_pid $scrub_pid
+       fi
+       if [ ! -z "$fsstress_pid" ]; then
+               kill $fsstress_pid &> /dev/null
+               wait $fsstress_pid &> /dev/null
+       fi
+}
+
 # Import common functions.
 . ./common/filter
 
@@ -51,8 +67,11 @@ run_test()
 
        echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
        wait $fsstress_pid
+       unset fsstress_pid
        _btrfs_kill_stress_balance_pid $balance_pid
+       unset balance_pid
        _btrfs_kill_stress_scrub_pid $scrub_pid
+       unset scrub_pid
 
        echo "Scrub the filesystem" >>$seqres.full
        $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
index 59d581beadd1e2ed1edae41a543626d9c64da7bf..0b57681f90b14c1e85b122e53474344f7696ffe4 100755 (executable)
 . ./common/preamble
 _begin_fstest auto balance defrag compress scrub
 
+_cleanup()
+{
+       cd /
+       rm -rf $tmp.*
+       if [ ! -z "$balance_pid" ]; then
+               _btrfs_kill_stress_balance_pid $balance_pid
+       fi
+       if [ ! -z "$defrag_pid" ]; then
+               _btrfs_kill_stress_defrag_pid $defrag_pid
+       fi
+       if [ ! -z "$fsstress_pid" ]; then
+               kill $fsstress_pid &> /dev/null
+               wait $fsstress_pid &> /dev/null
+       fi
+}
+
 # Import common functions.
 . ./common/filter
 
@@ -52,8 +68,11 @@ run_test()
 
        echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
        wait $fsstress_pid
+       unset fsstress_pid
        _btrfs_kill_stress_balance_pid $balance_pid
+       unset balance_pid
        _btrfs_kill_stress_defrag_pid $defrag_pid
+       unset defrag_pid
 
        echo "Scrub the filesystem" >>$seqres.full
        $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
index 5ee2837f891d66908387153281ca46edae785010..99d9d2c1e8c6baec726677f51692228e01c355bb 100755 (executable)
 . ./common/preamble
 _begin_fstest auto balance remount compress scrub
 
+_cleanup()
+{
+       cd /
+       rm -rf $tmp.*
+       if [ ! -z "$balance_pid" ]; then
+               _btrfs_kill_stress_balance_pid $balance_pid
+       fi
+       if [ ! -z "$remount_pid" ]; then
+               _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
+       fi
+       if [ ! -z "$fsstress_pid" ]; then
+               kill $fsstress_pid &> /dev/null
+               wait $fsstress_pid &> /dev/null
+       fi
+}
+
 # Import common functions.
 . ./common/filter
 
@@ -51,8 +67,11 @@ run_test()
 
        echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
        wait $fsstress_pid
+       unset fsstress_pid
        _btrfs_kill_stress_balance_pid $balance_pid
+       unset balance_pid
        _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
+       unset remount_pid
 
        echo "Scrub the filesystem" >>$seqres.full
        $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
index 9e0b3b30236caa2972867cb38f5cb993cb716b1a..663442c69a59bc41720f054f86f69267526bc13e 100755 (executable)
 . ./common/preamble
 _begin_fstest auto balance replace volume scrub
 
+_cleanup()
+{
+       cd /
+       rm -rf $tmp.*
+       if [ ! -z "$balance_pid" ]; then
+               _btrfs_kill_stress_balance_pid $balance_pid
+       fi
+       if [ ! -z "$replace_pid" ]; then
+               _btrfs_kill_stress_replace_pid $replace_pid
+       fi
+       if [ ! -z "$fsstress_pid" ]; then
+               kill $fsstress_pid &> /dev/null
+               wait $fsstress_pid &> /dev/null
+       fi
+}
+
 # Import common functions.
 . ./common/filter
 
@@ -63,8 +79,11 @@ run_test()
 
        echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
        wait $fsstress_pid
+       unset fsstress_pid
        _btrfs_kill_stress_balance_pid $balance_pid
+       unset balance_pid
        _btrfs_kill_stress_replace_pid $replace_pid
+       unset replace_pid
 
        echo "Scrub the filesystem" >>$seqres.full
        $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
index f9e43cdc01884f49c70dd634fdcce43ed923a43d..b1e54fc8aef23eeaa2bb7fa95af0f1d5cddb8b27 100755 (executable)
 . ./common/preamble
 _begin_fstest auto subvol replace volume scrub
 
+_cleanup()
+{
+       cd /
+       rm -rf $tmp.*
+       if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then
+               _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
+       fi
+       if [ ! -z "$replace_pid" ]; then
+               _btrfs_kill_stress_replace_pid $replace_pid
+       fi
+       if [ ! -z "$fsstress_pid" ]; then
+               kill $fsstress_pid &> /dev/null
+               wait $fsstress_pid &> /dev/null
+       fi
+}
+
 # Import common functions.
 . ./common/filter
 
@@ -21,12 +37,13 @@ _require_scratch_dev_pool 5
 _require_scratch_dev_pool_equal_size
 _btrfs_get_profile_configs replace
 
+stop_file=$TEST_DIR/$seq.stop.$$
+
 run_test()
 {
        local mkfs_opts=$1
        local saved_scratch_dev_pool=$SCRATCH_DEV_POOL
        local subvol_mnt=$TEST_DIR/$seq.mnt
-       local stop_file=$TEST_DIR/$seq.stop.$$
 
        echo "Test $mkfs_opts" >>$seqres.full
 
@@ -61,9 +78,12 @@ run_test()
 
        echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
        wait $fsstress_pid
+       unset fsstress_pid
 
        _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
+       unset subvol_pid
        _btrfs_kill_stress_replace_pid $replace_pid
+       unset replace_pid
 
        echo "Scrub the filesystem" >>$seqres.full
        $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
index b6f904ac509d39c1e8694b0a3fde20d40d1b177a..feb6062e348c1b8f80b1971d94ce3a55ab48d156 100755 (executable)
 . ./common/preamble
 _begin_fstest auto subvol scrub
 
+_cleanup()
+{
+       cd /
+       rm -rf $tmp.*
+       if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then
+               _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
+       fi
+       if [ ! -z "$scrub_pid" ]; then
+               _btrfs_kill_stress_scrub_pid $scrub_pid
+       fi
+       if [ ! -z "$fsstress_pid" ]; then
+               kill $fsstress_pid &> /dev/null
+               wait $fsstress_pid &> /dev/null
+       fi
+}
+
 # Import common functions.
 . ./common/filter
 
@@ -20,11 +36,12 @@ _require_scratch_nocheck
 _require_scratch_dev_pool 4
 _btrfs_get_profile_configs
 
+stop_file=$TEST_DIR/$seq.stop.$$
+
 run_test()
 {
        local mkfs_opts=$1
        local subvol_mnt=$TEST_DIR/$seq.mnt
-       local stop_file=$TEST_DIR/$seq.stop.$$
 
        echo "Test $mkfs_opts" >>$seqres.full
 
@@ -53,9 +70,12 @@ run_test()
 
        echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
        wait $fsstress_pid
+       unset fsstress_pid
 
        _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
+       unset subvol_pid
        _btrfs_kill_stress_scrub_pid $scrub_pid
+       unset scrub_pid
 
        echo "Scrub the filesystem" >>$seqres.full
        $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
index 7be09d52f14de3ed893b491cecfae4a2e7770502..0bbfe83f0fbbf8de08caab6695c4ebcbc4a352ea 100755 (executable)
 . ./common/preamble
 _begin_fstest auto subvol defrag compress scrub
 
+_cleanup()
+{
+       cd /
+       rm -rf $tmp.*
+       if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then
+               _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
+       fi
+       if [ ! -z "$defrag_pid" ]; then
+               _btrfs_kill_stress_defrag_pid $defrag_pid
+       fi
+       if [ ! -z "$fsstress_pid" ]; then
+               kill $fsstress_pid &> /dev/null
+               wait $fsstress_pid &> /dev/null
+       fi
+}
+
 # Import common functions.
 . ./common/filter
 
@@ -20,12 +36,13 @@ _require_scratch_nocheck
 _require_scratch_dev_pool 4
 _btrfs_get_profile_configs
 
+stop_file=$TEST_DIR/$seq.stop.$$
+
 run_test()
 {
        local mkfs_opts=$1
        local with_compress=$2
        local subvol_mnt=$TEST_DIR/$seq.mnt
-       local stop_file=$TEST_DIR/$seq.stop.$$
 
        echo "Test $mkfs_opts with $with_compress" >>$seqres.full
 
@@ -54,9 +71,12 @@ run_test()
 
        echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
        wait $fsstress_pid
+       unset fsstress_pid
 
        _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
+       unset subvol_pid
        _btrfs_kill_stress_defrag_pid $defrag_pid
+       unset defrag_pid
 
        echo "Scrub the filesystem" >>$seqres.full
        $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
index 19e3701023bf7ac70c745ae8b79c9cf228a5afe3..7ab6fecacca0d6d94352624543eca3980ebf2119 100755 (executable)
 . ./common/preamble
 _begin_fstest auto subvol remount compress scrub
 
+_cleanup()
+{
+       cd /
+       rm -rf $tmp.*
+       if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then
+               _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
+       fi
+       if [ ! -z "$remount_pid" ]; then
+               _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
+       fi
+       if [ ! -z "$fsstress_pid" ]; then
+               kill $fsstress_pid &> /dev/null
+               wait $fsstress_pid &> /dev/null
+       fi
+}
+
 # Import common functions.
 . ./common/filter
 
@@ -21,11 +37,12 @@ _require_scratch_nocheck
 _require_scratch_dev_pool 4
 _btrfs_get_profile_configs
 
+stop_file=$TEST_DIR/$seq.stop.$$
+
 run_test()
 {
        local mkfs_opts=$1
        local subvol_mnt=$TEST_DIR/$seq.mnt
-       local stop_file=$TEST_DIR/$seq.stop.$$
 
        echo "Test $mkfs_opts with $with_compress" >>$seqres.full
 
@@ -54,9 +71,12 @@ run_test()
 
        echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
        wait $fsstress_pid
+       unset fsstress_pid
 
        _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
+       unset subvol_pid
        _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
+       unset remount_pid
 
        echo "Scrub the filesystem" >>$seqres.full
        $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
index ad1609d401620eb163c515e1f410bccbac51e2fa..3fbfecdbb84ded404a77c456c08ece2773e44074 100755 (executable)
 . ./common/preamble
 _begin_fstest auto replace scrub volume
 
+_cleanup()
+{
+       cd /
+       rm -rf $tmp.*
+       if [ ! -z "$replace_pid" ]; then
+               _btrfs_kill_stress_replace_pid $replace_pid
+       fi
+       if [ ! -z "$scrub_pid" ]; then
+               _btrfs_kill_stress_scrub_pid $scrub_pid
+       fi
+       if [ ! -z "$fsstress_pid" ]; then
+               kill $fsstress_pid &> /dev/null
+               wait $fsstress_pid &> /dev/null
+       fi
+}
+
 # Import common functions.
 . ./common/filter
 
@@ -59,8 +75,11 @@ run_test()
 
        echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
        wait $fsstress_pid
+       unset fsstress_pid
        _btrfs_kill_stress_scrub_pid $scrub_pid
+       unset scrub_pid
        _btrfs_kill_stress_replace_pid $replace_pid
+       unset replace_pid
 
        echo "Scrub the filesystem" >>$seqres.full
        $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
index 3054c270bcf592f47417d5ab14ae5f29dfa66710..11fddc86259493d075c973139a6f0977c0c76b8d 100755 (executable)
 . ./common/preamble
 _begin_fstest auto replace defrag compress volume scrub
 
+_cleanup()
+{
+       cd /
+       rm -rf $tmp.*
+       if [ ! -z "$replace_pid" ]; then
+               _btrfs_kill_stress_replace_pid $replace_pid
+       fi
+       if [ ! -z "$defrag_pid" ]; then
+               _btrfs_kill_stress_defrag_pid $defrag_pid
+       fi
+       if [ ! -z "$fsstress_pid" ]; then
+               kill $fsstress_pid &> /dev/null
+               wait $fsstress_pid &> /dev/null
+       fi
+}
+
 # Import common functions.
 . ./common/filter
 
@@ -60,8 +76,11 @@ run_test()
 
        echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
        wait $fsstress_pid
+       unset fsstress_pid
        _btrfs_kill_stress_replace_pid $replace_pid
+       unset replace_pid
        _btrfs_kill_stress_defrag_pid $defrag_pid
+       unset defrag_pid
 
        echo "Scrub the filesystem" >>$seqres.full
        $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
index 36b393412a738b66acd6feaa4a0438fa6bf42c6b..1a91ec450210ea705be84601033637c518c20f5b 100755 (executable)
 . ./common/preamble
 _begin_fstest auto replace remount compress volume scrub
 
+_cleanup()
+{
+       cd /
+       rm -rf $tmp.*
+       if [ ! -z "$replace_pid" ]; then
+               _btrfs_kill_stress_replace_pid $replace_pid
+       fi
+       if [ ! -z "$remount_pid" ]; then
+               _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
+       fi
+       if [ ! -z "$fsstress_pid" ]; then
+               kill $fsstress_pid &> /dev/null
+               wait $fsstress_pid &> /dev/null
+       fi
+}
+
 # Import common functions.
 . ./common/filter
 
@@ -59,8 +75,11 @@ run_test()
 
        echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
        wait $fsstress_pid
+       unset fsstress_pid
        _btrfs_kill_stress_replace_pid $replace_pid
+       unset replace_pid
        _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
+       unset remount_pid
 
        echo "Scrub the filesystem" >>$seqres.full
        $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
index 505d0b578c221419e834c8b1d44c4a4190946999..e66e49c9c0cad100d898815f1c0df24f4ac658ca 100755 (executable)
 . ./common/preamble
 _begin_fstest auto scrub defrag compress
 
+_cleanup()
+{
+       cd /
+       rm -rf $tmp.*
+       if [ ! -z "$defrag_pid" ]; then
+               _btrfs_kill_stress_defrag_pid $defrag_pid
+       fi
+       if [ ! -z "$scrub_pid" ]; then
+               _btrfs_kill_stress_scrub_pid $scrub_pid
+       fi
+       if [ ! -z "$fsstress_pid" ]; then
+               kill $fsstress_pid &> /dev/null
+               wait $fsstress_pid &> /dev/null
+       fi
+}
+
 # Import common functions.
 . ./common/filter
 
@@ -52,9 +68,12 @@ run_test()
 
        echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
        wait $fsstress_pid
+       unset fsstress_pid
 
        _btrfs_kill_stress_defrag_pid $defrag_pid
+       unset defrag_pid
        _btrfs_kill_stress_scrub_pid $scrub_pid
+       unset scrub_pid
 
        echo "Scrub the filesystem" >>$seqres.full
        $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
index 503582862f6de34cc49105acdb175ca95fad4959..e6cfd92a895d9cfabdc7a655d464650f278bdf6c 100755 (executable)
 . ./common/preamble
 _begin_fstest auto scrub remount compress
 
+_cleanup()
+{
+       cd /
+       rm -rf $tmp.*
+       if [ ! -z "$remount_pid" ]; then
+               _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
+       fi
+       if [ ! -z "$scrub_pid" ]; then
+               _btrfs_kill_stress_scrub_pid $scrub_pid
+       fi
+       if [ ! -z "$fsstress_pid" ]; then
+               kill $fsstress_pid &> /dev/null
+               wait $fsstress_pid &> /dev/null
+       fi
+}
+
 # Import common functions.
 . ./common/filter
 
@@ -51,8 +67,11 @@ run_test()
 
        echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
        wait $fsstress_pid
+       unset fsstress_pid
        _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
+       unset remount_pid
        _btrfs_kill_stress_scrub_pid $scrub_pid
+       unset scrub_pid
 
        echo "Scrub the filesystem" >>$seqres.full
        $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1
index 6e93b36a9702432c99497cbe3f9afbc604e21899..1dd88bcd659cd77b017b0e6b5c84ecbcaf870cad 100755 (executable)
 . ./common/preamble
 _begin_fstest auto defrag remount compress scrub
 
+_cleanup()
+{
+       cd /
+       rm -rf $tmp.*
+       if [ ! -z "$remount_pid" ]; then
+               _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
+       fi
+       if [ ! -z "$defrag_pid" ]; then
+               _btrfs_kill_stress_defrag_pid $defrag_pid
+       fi
+       if [ ! -z "$fsstress_pid" ]; then
+               kill $fsstress_pid &> /dev/null
+               wait $fsstress_pid &> /dev/null
+       fi
+}
+
 # Import common functions.
 . ./common/filter
 
@@ -52,8 +68,11 @@ run_test()
 
        echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
        wait $fsstress_pid
+       unset fsstress_pid
        _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
+       unset remount_pid
        _btrfs_kill_stress_defrag_pid $defrag_pid
+       unset defrag_pid
 
        echo "Scrub the filesystem" >>$seqres.full
        $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1