]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
btrfs: 'subvolume stress' tasks need to exit gracefully
authorChandan Rajendra <chandan@linux.vnet.ibm.com>
Wed, 23 Mar 2016 06:39:11 +0000 (17:39 +1100)
committerDave Chinner <david@fromorbit.com>
Wed, 23 Mar 2016 06:39:11 +0000 (17:39 +1100)
The following scenario can occur when running btrfs/066,

  Task A                                Task B                     Task C

  run_test()
  - Execute _btrfs_stress_subvolume()
    in a background shell.
                                        _btrfs_stress_subvolme()
                                          ...
                                        - fork & exec "mount"
                                                          Mount subvolume on directory in $TEST_DIR
  - Wait for fsstress to finish                                    do_mount()
  - kill shell process executing                                   - btrfs_mount()
    _btrfs_stress_subvolume()
    i.e. Task B.
  - Init process becomes the parent
    of "subvolume mount" task
    i.e. Task C.
  - In case subvolume is mounted
    (which is not the case),
    unmount it.
                                                                   - Complete mounting subvolume

Hence on the completion of one iteration of run_test(), the subvolume
created inside the filesystem on $SCRATCH_DEV continues to be mounted on
$TEST_DIR/$seq.mnt. Subsequent invocations of run_test() (called for
remaining Btrfs profile configs) fail during _scratch_pool_mkfs.

Instead of killing the 'subvolume stress' task this commit makes
_btrfs_stress_subvolume() to break out of the loop when a file exists
on the filesystem. The commit also makes relevant changes to other
users of _btrfs_stress_subvolume() i.e. btrfs/060, btrfs/065,
btrfs/067 & btrfs/068.

Suggested-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
common/rc
tests/btrfs/060
tests/btrfs/065
tests/btrfs/066
tests/btrfs/067
tests/btrfs/068

index 2ac159d905c43c6b2c3a7ba0be33864861e0d4cd..a412e4e585246dba4c5c899ad0a878af3937c059 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -3280,9 +3280,10 @@ _btrfs_stress_subvolume()
        local btrfs_mnt=$2
        local subvol_name=$3
        local subvol_mnt=$4
+       local stop_file=$5
 
        mkdir -p $subvol_mnt
-       while true; do
+       while [ ! -e $stop_file ]; do
                $BTRFS_UTIL_PROG subvolume create $btrfs_mnt/$subvol_name
                $MOUNT_PROG -o subvol=$subvol_name $btrfs_dev $subvol_mnt
                $UMOUNT_PROG $subvol_mnt
index 8ef0e7f823b3ef59051f0405c73ba899e2636afb..6b6a480aa109d6081e7419f1e6c5f92a682ed760 100755 (executable)
@@ -56,6 +56,7 @@ 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
 
@@ -77,15 +78,18 @@ run_test()
        balance_pid=$!
        echo "$balance_pid" >>$seqres.full
 
+       # make sure the stop sign is not there
+       rm -f $stop_file
        echo -n "Start subvolume worker: " >>$seqres.full
-       _btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt >/dev/null 2>&1 &
+       _btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 &
        subvol_pid=$!
        echo "$subvol_pid" >>$seqres.full
 
        echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
        wait $fsstress_pid
 
-       kill $balance_pid $subvol_pid
+       touch $stop_file
+       kill $balance_pid
        wait
        # wait for the balance operation to finish
        while ps aux | grep "balance start" | grep -qv grep; do
index 7d8249b94edfac0fab6156a23f976f34a6fa550f..a4afe7335776b460e56b3af724cc711c79a789c9 100755 (executable)
@@ -58,6 +58,7 @@ 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
 
@@ -80,8 +81,10 @@ run_test()
        $FSSTRESS_PROG $args >/dev/null 2>&1 &
        fsstress_pid=$!
 
+       # make sure the stop sign is not there
+       rm -f $stop_file
        echo -n "Start subvolume worker: " >>$seqres.full
-       _btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt >/dev/null 2>&1 &
+       _btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 &
        subvol_pid=$!
        echo "$subvol_pid" >>$seqres.full
 
@@ -93,7 +96,8 @@ run_test()
        echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
        wait $fsstress_pid
 
-       kill $subvol_pid $replace_pid
+       touch $stop_file
+       kill $replace_pid
        wait
        # wait for the replace operation to finish
        while ps aux | grep "replace start" | grep -qv grep; do
index 2d9a1d2d2a4da63be7a6ddc0b5643fc7ee06692f..cf4dd0daf3b6dd2d8832b56b98ed9119dfc02cb6 100755 (executable)
@@ -56,6 +56,7 @@ 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
 
@@ -72,8 +73,10 @@ run_test()
        $FSSTRESS_PROG $args >/dev/null 2>&1 &
        fsstress_pid=$!
 
+       # make sure the stop sign is not there
+       rm -f $stop_file
        echo -n "Start subvolume worker: " >>$seqres.full
-       _btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt >/dev/null 2>&1 &
+       _btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 &
        subvol_pid=$!
        echo "$subvol_pid" >>$seqres.full
 
@@ -85,7 +88,8 @@ run_test()
        echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
        wait $fsstress_pid
 
-       kill $subvol_pid $scrub_pid
+       touch $stop_file
+       kill $scrub_pid
        wait
        # wait for the scrub operation to finish
        while ps aux | grep "scrub start" | grep -qv grep; do
index 2c1e284d5d2c527e335512859482c23b6e1e5152..b76f5ec92748aade7175520e2741b35b4def5a0f 100755 (executable)
@@ -57,6 +57,7 @@ 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
 
@@ -73,8 +74,10 @@ run_test()
        $FSSTRESS_PROG $args >/dev/null 2>&1 &
        fsstress_pid=$!
 
+       # make sure the stop sign is not there
+       rm -f $stop_file
        echo -n "Start subvolume worker: " >>$seqres.full
-       _btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt >/dev/null 2>&1 &
+       _btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 &
        subvol_pid=$!
        echo "$subvol_pid" >>$seqres.full
 
@@ -86,7 +89,8 @@ run_test()
        echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
        wait $fsstress_pid
 
-       kill $subvol_pid $defrag_pid
+       touch $stop_file
+       kill $defrag_pid
        wait
        # wait for btrfs defrag process to exit, otherwise it will block umount
        while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do
index 3126ec2542535b956bbfa7224e77e053557cdb0e..534aee62b7998127d1a8ec78412f007e7e3e6595 100755 (executable)
@@ -57,6 +57,7 @@ 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
 
@@ -73,8 +74,10 @@ run_test()
        $FSSTRESS_PROG $args >/dev/null 2>&1 &
        fsstress_pid=$!
 
+       # make sure the stop sign is not there
+       rm -f $stop_file
        echo -n "Start subvolume worker: " >>$seqres.full
-       _btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt >/dev/null 2>&1 &
+       _btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 &
        subvol_pid=$!
        echo "$subvol_pid" >>$seqres.full
 
@@ -86,7 +89,8 @@ run_test()
        echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full
        wait $fsstress_pid
 
-       kill $subvol_pid $remount_pid
+       touch $stop_file
+       kill $remount_pid
        wait
        # wait for the remount loop process to finish
        while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do