fstests: check if the scratch device is an lv device for certain tests
[xfstests-dev.git] / tests / generic / 459
index aee71a0f5081e91c24c9ed403b3c61209ad19090..cda19e6eb235dd8dde29193d8163060810e50acc 100755 (executable)
 #
 # This test might hang the filesystem when ran on an unpatched kernel
 #
-seq=`basename $0`
-seqres=$RESULT_DIR/$seq
-echo "QA output created by $seq"
-
-here=`pwd`
-tmp=/tmp/$$
-status=1       # failure is the default!
-trap "_cleanup; exit \$status" 0 1 2 3 15
+. ./common/preamble
+_begin_fstest auto freeze thin
 
+# Override the default cleanup function.
 _cleanup()
 {
        cd /
@@ -34,39 +29,35 @@ _cleanup()
        $UMOUNT_PROG $SCRATCH_MNT >>$seqres.full 2>&1
        $LVM_PROG vgremove -ff $vgname >>$seqres.full 2>&1
        $LVM_PROG pvremove -ff $SCRATCH_DEV >>$seqres.full 2>&1
+       $UDEV_SETTLE_PROG
 }
 
-# get standard environment, filters and checks
-. ./common/rc
+# Import common functions.
 
 # real QA test starts here
 
 # This tests for filesystem lockup not consistency, so don't check for fs
 # consistency after test
 _supported_fs generic
-_supported_os Linux
-_require_scratch_nocheck
+_require_scratch_nolvm
 _require_dm_target thin-pool
 _require_dm_target snapshot
 _require_command $LVM_PROG lvm
 _require_command "$THIN_CHECK_PROG" thin_check
 _require_freeze
 
-# remove previous $seqres.full before test
-rm -f $seqres.full
-
 vgname=vg_$seq
 lvname=lv_$seq
 poolname=pool_$seq
 snapname=snap_$seq
-origpsize=100
-virtsize=200
-newpsize=200
+origpsize=200
+virtsize=300
+newpsize=300
 
 # Ensure we have enough disk space
-_scratch_mkfs_sized $((250 * 1024 * 1024)) >>$seqres.full 2>&1
+_scratch_mkfs_sized $((350 * 1024 * 1024)) >>$seqres.full 2>&1
 
-# Create a 100MB dm-thin POOL
+# Create a 200MB dm-thin POOL
 $LVM_PROG pvcreate -f $SCRATCH_DEV >>$seqres.full 2>&1
 $LVM_PROG vgcreate -f $vgname $SCRATCH_DEV >>$seqres.full 2>&1
 
@@ -74,25 +65,26 @@ $LVM_PROG lvcreate  --thinpool $poolname  --errorwhenfull y \
                    --zero n -L $origpsize \
                    --poolmetadatasize 4M $vgname >>$seqres.full 2>&1
 
-# Create a overprovisioned 200MB dm-thin virt. device
+# Create a overprovisioned 300MB dm-thin virt. device
 $LVM_PROG lvcreate  --virtualsize $virtsize \
                    -T $vgname/$poolname \
                    -n $lvname >>$seqres.full 2>&1
 
 _mkfs_dev /dev/mapper/$vgname-$lvname >>$seqres.full 2>&1
 
-
 # Running the test over the original volume doesn't reproduce the problem
 # reliably, while, running it over a snapshot, makes the problem 100%
 # reproducible, so, create a snapshot and run the test over it.
 $LVM_PROG lvcreate  -k n -s $vgname/$lvname \
                    -n $snapname >>$seqres.full 2>&1
 
-_mount /dev/mapper/$vgname-$snapname $SCRATCH_MNT
+# Catch mount failure so we don't blindly go an freeze the root filesystem
+# instead of lvm volume.
+_mount /dev/mapper/$vgname-$snapname $SCRATCH_MNT || _fail "mount failed"
 
 # Consume all space available in the volume and freeze to ensure everything
 # required to make the fs consistent is flushed to disk.
-$XFS_IO_PROG -f -d -c 'pwrite -b 1m 0 120m' $SCRATCH_MNT/f1 >>$seqres.full 2>&1
+$XFS_IO_PROG -f -d -c 'pwrite -b 1m 0 220m' $SCRATCH_MNT/f1 >>$seqres.full 2>&1
 
 # In XFS, this freeze will never complete until the dm-thin POOL device is
 # extended. It is expected, and is only used so xfsaild is triggered to