]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
btrfs/028: kill lingering processes when test is interrupted
authorFilipe Manana <fdmanana@suse.com>
Thu, 28 Nov 2024 12:14:56 +0000 (12:14 +0000)
committerZorro Lang <zlang@kernel.org>
Thu, 28 Nov 2024 13:32:56 +0000 (21:32 +0800)
If we interrupt the test after it spawned the fsstress and balance
processes (while it's sleeping for 30 seconds * $TIME_FACTOR), we don't
kill them and they stay around for a long time, making it impossible to
unmount the scratch filesystem (failing with -EBUSY).

Fix this by adding a _cleanup function that kills the processes and
waits for them to exit.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tests/btrfs/028

index f64fc831dbe090d3eccc2e816c7f1493a28d71cd..05366e5a18af64a2f09c6ddd3aee3a450178c13a 100755 (executable)
 . ./common/preamble
 _begin_fstest auto qgroup balance
 
+_cleanup()
+{
+       cd /
+       rm -r -f $tmp.*
+       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
+}
+
 . ./common/filter
 
 _require_scratch
@@ -44,6 +57,7 @@ sleep $((30*$TIME_FACTOR))
 kill $fsstress_pid &> /dev/null
 wait $fsstress_pid &> /dev/null
 _btrfs_kill_stress_balance_pid $balance_pid
+unset fsstress_pid balance_pid
 
 # The qgroups accounting will be checked by 'btrfs check' (fsck) after the
 # fstests framework unmounts the filesystem.