]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
btrfs: properly shutdown subvolume stress worker to avoid umount failures
authorFilipe Manana <fdmanana@suse.com>
Wed, 24 Jul 2024 13:58:52 +0000 (14:58 +0100)
committerAnand Jain <anand.jain@oracle.com>
Thu, 25 Jul 2024 11:09:33 +0000 (19:09 +0800)
When killing a test that is using the subvolume stress worker, we may end
up in a situation where we end up leaving a subvolume mounted which makes
the shutdown sequence fail. Example when killing a script that keeps
running fstests in a loop:

   FSTYP         -- btrfs
   PLATFORM      -- Linux/x86_64 debian0 6.10.0-rc7-btrfs-next-167+ #1 SMP PREEMPT_DYNAMIC Thu Jul 11 17:54:07 WEST 2024
   MKFS_OPTIONS  -- /dev/sdc
   MOUNT_OPTIONS -- /dev/sdc /home/fdmanana/btrfs-tests/scratch_1

   (...)
   btrfs/065 23s ... ^C^C^C
   Iteration 134, errors 1, leaks 0, Wed Jul 24 12:14:33 PM WEST 2024, flakey errors: 0 MKFS_OPTIONS="" MOUNT_OPTIONS=""

   SCRATCH_DEV=/dev/sdc is mounted but not on SCRATCH_MNT=/home/fdmanana/btrfs-tests/scratch_1 - aborting
   Already mounted result:
   /dev/sdc /home/fdmanana/btrfs-tests/scratch_1 /dev/sdc /home/fdmanana/btrfs-tests/dev/065.mnt
   grep: results/btrfs/065.out.bad: No such file or directory
   Error iteration 134, total errors 2, leaks 0
   'results/btrfs/065.full' -> '/home/fdmanana/failures/btrfs_065/134/065.full'

Running 'mount' to see what's going on:

   $ mount
   (...)
   /dev/sdb on /home/fdmanana/btrfs-tests/dev type btrfs (rw,relatime,discard=async,space_cache=v2,subvolid=5,subvol=/)
   /dev/sdc on /home/fdmanana/btrfs-tests/scratch_1 type btrfs (rw,relatime,discard=async,space_cache=v2,subvolid=5,subvol=/)
   /dev/sdc on /home/fdmanana/btrfs-tests/dev/065.mnt type btrfs (rw,relatime,discard=async,space_cache=v2,subvolid=2627,subvol=/subvol_3395330)

Then this makes the next attempt to run a test (./check) always fail due
to the extra mount of the subvolume, requiring one to manually umount the
subvolume before running fstests again.

So update _btrfs_kill_stress_subvolume_pid() to also unmount the subvolume.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.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 c0be7c08acc389cb8c19b501466f6ffabd2398da..95a9c8e6c7f44839f6ac7905707470e4ff4a9576 100644 (file)
@@ -362,11 +362,13 @@ _btrfs_kill_stress_subvolume_pid()
 {
        local subvol_pid=$1
        local stop_file=$2
+       local subvol_mnt=$3
 
        touch $stop_file
        # Ignore if process already died.
        wait $subvol_pid &> /dev/null
        rm -f $stop_file
+       $UMOUNT_PROG $subvol_mnt &> /dev/null
 }
 
 # stress btrfs by running scrub in a loop
index 00f57841a3c065f13f9666899e92adcd544f1cd0..75c10bd23c36f59fd86cc46d32932d05b4fff8c1 100755 (executable)
@@ -14,8 +14,9 @@ _cleanup()
 {
        cd /
        rm -rf $tmp.*
-       if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then
-               _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
+       if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ] && \
+                  [ ! -z "$subvol_mnt" ]; then
+               _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file $subvol_mnt
        fi
        if [ ! -z "$balance_pid" ]; then
                _btrfs_kill_stress_balance_pid $balance_pid
@@ -34,11 +35,11 @@ _require_scratch_dev_pool 4
 _btrfs_get_profile_configs
 
 stop_file=$TEST_DIR/$seq.stop.$$
+subvol_mnt=$TEST_DIR/$seq.mnt
 
 run_test()
 {
        local mkfs_opts=$1
-       local subvol_mnt=$TEST_DIR/$seq.mnt
 
        echo "Test $mkfs_opts" >>$seqres.full
 
@@ -69,7 +70,7 @@ run_test()
        wait $fsstress_pid
        unset fsstress_pid
 
-       _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
+       _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file $subvol_mnt
        unset subvol_pid
        _btrfs_kill_stress_balance_pid $balance_pid
        unset balance_pid
index 5fb635abffa7d7b4744839137603da6eac6dbc43..b87c66d6e3d45e86fa63f34eb19f5b7a78ec5c56 100755 (executable)
@@ -14,8 +14,9 @@ _cleanup()
 {
        cd /
        rm -rf $tmp.*
-       if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then
-               _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
+       if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ] && \
+                  [ ! -z "$subvol_mnt" ]; then
+               _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file $subvol_mnt
        fi
        if [ ! -z "$replace_pid" ]; then
                _btrfs_kill_stress_replace_pid $replace_pid
@@ -35,12 +36,12 @@ _require_scratch_dev_pool_equal_size
 _btrfs_get_profile_configs replace
 
 stop_file=$TEST_DIR/$seq.stop.$$
+subvol_mnt=$TEST_DIR/$seq.mnt
 
 run_test()
 {
        local mkfs_opts=$1
        local saved_scratch_dev_pool=$SCRATCH_DEV_POOL
-       local subvol_mnt=$TEST_DIR/$seq.mnt
 
        echo "Test $mkfs_opts" >>$seqres.full
 
@@ -77,7 +78,7 @@ run_test()
        wait $fsstress_pid
        unset fsstress_pid
 
-       _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
+       _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file $subvol_mnt
        unset subvol_pid
        _btrfs_kill_stress_replace_pid $replace_pid
        unset replace_pid
index 30fa438a52d814aa5fc3e681b058137cdabe8348..cc7cd9b7273d1ca93ffafe1157e8782f1a03ee02 100755 (executable)
@@ -14,8 +14,9 @@ _cleanup()
 {
        cd /
        rm -rf $tmp.*
-       if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then
-               _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
+       if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ] && \
+                  [ ! -z "$subvol_mnt" ]; then
+               _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file $subvol_mnt
        fi
        if [ ! -z "$scrub_pid" ]; then
                _btrfs_kill_stress_scrub_pid $scrub_pid
@@ -34,11 +35,11 @@ _require_scratch_dev_pool 4
 _btrfs_get_profile_configs
 
 stop_file=$TEST_DIR/$seq.stop.$$
+subvol_mnt=$TEST_DIR/$seq.mnt
 
 run_test()
 {
        local mkfs_opts=$1
-       local subvol_mnt=$TEST_DIR/$seq.mnt
 
        echo "Test $mkfs_opts" >>$seqres.full
 
@@ -69,7 +70,7 @@ run_test()
        wait $fsstress_pid
        unset fsstress_pid
 
-       _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
+       _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file $subvol_mnt
        unset subvol_pid
        _btrfs_kill_stress_scrub_pid $scrub_pid
        unset scrub_pid
index 899b96da47b8ff947993050067f5e14a9a991c74..0b473050027a0a7f33ded550f7a99b64c18ba504 100755 (executable)
@@ -14,8 +14,9 @@ _cleanup()
 {
        cd /
        rm -rf $tmp.*
-       if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then
-               _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
+       if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ] && \
+                  [ ! -z "$subvol_mnt" ]; then
+               _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file $subvol_mnt
        fi
        if [ ! -z "$defrag_pid" ]; then
                _btrfs_kill_stress_defrag_pid $defrag_pid
@@ -34,12 +35,12 @@ _require_scratch_dev_pool 4
 _btrfs_get_profile_configs
 
 stop_file=$TEST_DIR/$seq.stop.$$
+subvol_mnt=$TEST_DIR/$seq.mnt
 
 run_test()
 {
        local mkfs_opts=$1
        local with_compress=$2
-       local subvol_mnt=$TEST_DIR/$seq.mnt
 
        echo "Test $mkfs_opts with $with_compress" >>$seqres.full
 
@@ -70,7 +71,7 @@ run_test()
        wait $fsstress_pid
        unset fsstress_pid
 
-       _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
+       _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file $subvol_mnt
        unset subvol_pid
        _btrfs_kill_stress_defrag_pid $defrag_pid
        unset defrag_pid
index 48b6cdb089c41d9ae230ae6c49368cf50b35e2f5..83e932e8417c0d2e0e4a1b69970d828febdf1b5b 100755 (executable)
@@ -15,8 +15,9 @@ _cleanup()
 {
        cd /
        rm -rf $tmp.*
-       if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then
-               _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
+       if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ] && \
+                  [ ! -z "$subvol_mnt" ]; then
+               _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file $subvol_mnt
        fi
        if [ ! -z "$remount_pid" ]; then
                _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
@@ -35,11 +36,11 @@ _require_scratch_dev_pool 4
 _btrfs_get_profile_configs
 
 stop_file=$TEST_DIR/$seq.stop.$$
+subvol_mnt=$TEST_DIR/$seq.mnt
 
 run_test()
 {
        local mkfs_opts=$1
-       local subvol_mnt=$TEST_DIR/$seq.mnt
 
        echo "Test $mkfs_opts with $with_compress" >>$seqres.full
 
@@ -70,7 +71,7 @@ run_test()
        wait $fsstress_pid
        unset fsstress_pid
 
-       _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file
+       _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file $subvol_mnt
        unset subvol_pid
        _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT
        unset remount_pid