tests: remove udf/101
[xfstests-dev.git] / tests / generic / 108
1 #! /bin/bash
2 # FS QA Test 108
3 #
4 # Test partial block device failure. Calls like fsync() should report failure
5 # on partial I/O failure, e.g. a single failed disk in a raid 0 stripe.
6 #
7 # Test motivated by an XFS bug, and this commit fixed the issue
8 # xfs: return errors from partial I/O failures to files
9 #
10 #-----------------------------------------------------------------------
11 # Copyright (c) 2015 Red Hat Inc. All Rights Reserved.
12 #
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
16 #
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
25 #-----------------------------------------------------------------------
26 #
27
28 seq=`basename $0`
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
31
32 here=`pwd`
33 tmp=/tmp/$$
34 status=1        # failure is the default!
35 trap "_cleanup; exit \$status" 0 1 2 3 15
36
37 _cleanup()
38 {
39         cd /
40         echo running > /sys/block/`_short_dev $SCSI_DEBUG_DEV`/device/state
41         $UMOUNT_PROG $SCRATCH_MNT >>$seqres.full 2>&1
42         $LVM_PROG vgremove -f $vgname >>$seqres.full 2>&1
43         $LVM_PROG pvremove -f $SCRATCH_DEV $SCSI_DEBUG_DEV >>$seqres.full 2>&1
44         _put_scsi_debug_dev
45         rm -f $tmp.*
46 }
47
48 # get standard environment, filters and checks
49 . ./common/rc
50 . ./common/filter
51 . ./common/scsi_debug
52
53 # real QA test starts here
54 _supported_fs generic
55 _supported_os Linux
56 _require_scratch_nocheck
57 _require_block_device $SCRATCH_DEV
58 _require_scsi_debug
59 _require_command "$LVM_PROG" lvm
60
61 lvname=lv_$seq
62 vgname=vg_$seq
63 rm -f $seqres.full
64
65 # _get_scsi_debug_dev returns a scsi debug device with 128M in size by default
66 SCSI_DEBUG_DEV=`_get_scsi_debug_dev`
67 if [ "$SCSI_DEBUG_DEV" == "/dev/" ]; then
68         _fail "Failed to initialize scsi debug device"
69 fi
70 echo "SCSI debug device $SCSI_DEBUG_DEV" >>$seqres.full
71
72 # create striped volume with 4MB stripe size
73 $LVM_PROG pvcreate -f $SCSI_DEBUG_DEV $SCRATCH_DEV >>$seqres.full 2>&1
74 $LVM_PROG vgcreate -f $vgname $SCSI_DEBUG_DEV $SCRATCH_DEV >>$seqres.full 2>&1
75 # We use yes pipe instead of 'lvcreate --yes' because old version of lvm
76 # (like 2.02.95 in RHEL6) don't support --yes option
77 yes | $LVM_PROG lvcreate -i 2 -I 4m -l 100%FREE -n $lvname $vgname \
78         >>$seqres.full 2>&1
79 # wait for lv creation to fully complete
80 $UDEV_SETTLE_PROG >>$seqres.full 2>&1
81
82 # _mkfs_dev exits the test on failure, this makes sure test lv is created by
83 # above vgcreate/lvcreate operations
84 _mkfs_dev /dev/mapper/$vgname-$lvname
85
86 _mount /dev/mapper/$vgname-$lvname $SCRATCH_MNT
87
88 # create a test file with contiguous blocks which will span across the 2 disks
89 $XFS_IO_PROG -f -c "pwrite 0 16M" -c fsync $SCRATCH_MNT/testfile >>$seqres.full
90
91 # offline the scsi debug device
92 echo offline > /sys/block/`_short_dev $SCSI_DEBUG_DEV`/device/state
93
94 # write to an allocated area of the test file with writes which spans both disks
95 # and call fsync, the fsync should report failure
96 $XFS_IO_PROG -c "pwrite -b 1M 0 6M" -c fsync $SCRATCH_MNT/testfile \
97         >>$seqres.full
98
99 status=0
100 exit