]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
generic/038: kill background threads on interrupt
authorDave Chinner <dchinner@redhat.com>
Thu, 2 Jun 2022 00:31:22 +0000 (10:31 +1000)
committerZorro Lang <zlang@kernel.org>
Fri, 3 Jun 2022 05:17:42 +0000 (13:17 +0800)
When I ctrl-c g/038, it either does nothing or it leaves processes
running in the background. It is not cleaning up it's background
processes correctly, so add kill vectors into the cleanup. Make sure
we only kill in the cleanup trap if the background processes are
running.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tests/generic/038

index c6cea94e345bb479a36ff9e503f4f666710a8aef..e9b4996787f4a0ecd0380107425ad36820b31cba 100755 (executable)
@@ -36,6 +36,10 @@ _begin_fstest auto stress trim
 # Override the default cleanup function.
 _cleanup()
 {
+       [ -n "${create_pids}" ] && kill ${create_pids[@]}
+       [ -n "${fallocate_pids}" ] && kill ${fallocate_pids[@]}
+       [ -n "${trim_pids}" ] && kill ${trim_pids[@]}
+       wait
        rm -fr $tmp
 }
 
@@ -47,6 +51,8 @@ _supported_fs generic
 _require_scratch
 _require_xfs_io_command "falloc"
 
+echo "Silence is golden"
+
 # Keep allocating and deallocating 1G of data space with the goal of creating
 # and deleting 1 block group constantly. The intention is to race with the
 # fstrim loop below.
@@ -113,7 +119,7 @@ create_files()
        done
 
        wait ${create_pids[@]}
-
+       unset create_pids
 }
 
 _scratch_mkfs >>$seqres.full 2>&1
@@ -136,12 +142,8 @@ create_files "foobar"
 kill ${fallocate_pids[@]}
 kill ${trim_pids[@]}
 wait
+unset fallocate_pids
+unset trim_pids
 
-# The fstests framework will now check for fs consistency with fsck.
-# The trimming was racy and caused some btree nodes to get full of zeroes on
-# disk, which obviously caused fs metadata corruption. The race often lead
-# to missing free space entries in a block group's free space cache too.
-
-echo "Silence is golden"
 status=0
 exit