4 # Test I/O error path by fully filling an dm snapshot.
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2015 Red Hat Inc. All Rights Reserved.
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #-----------------------------------------------------------------------
25 seqres=$RESULT_DIR/$seq
26 echo "QA output created by $seq"
30 status=1 # failure is the default!
31 trap "_cleanup; exit \$status" 0 1 2 3 15
37 # lvm may have umounted it on I/O error, but in case it does not
38 $UMOUNT_PROG $mnt >/dev/null 2>&1
39 $LVM_PROG vgremove -f $vgname >>$seqres.full 2>&1
40 $LVM_PROG pvremove -f $SCRATCH_DEV >>$seqres.full 2>&1
43 # get standard environment, filters and checks
47 # real QA test starts here
51 _require_scratch_nocheck
52 _require_dm_target snapshot
53 _require_command $LVM_PROG lvm
55 echo "Silence is golden"
61 mnt=$TEST_DIR/mnt_$seq
64 # make sure there's enough disk space for 256M lv, test for 300M here in case
65 # lvm uses some space for metadata
66 _scratch_mkfs_sized $((300 * 1024 * 1024)) >>$seqres.full 2>&1
67 $LVM_PROG vgcreate -f $vgname $SCRATCH_DEV >>$seqres.full 2>&1
68 # We use yes pipe instead of 'lvcreate --yes' because old version of lvm
69 # (like 2.02.95 in RHEL6) don't support --yes option
70 yes | $LVM_PROG lvcreate -L 256M -n $lvname $vgname >>$seqres.full 2>&1
71 # wait for lvcreation to fully complete
72 $UDEV_SETTLE_PROG >>$seqres.full 2>&1
74 # _mkfs_dev exits the test on failure, this can make sure lv is created in
75 # above vgcreate/lvcreate steps
76 _mkfs_dev /dev/mapper/$vgname-$lvname
78 # create a 4M snapshot
79 $LVM_PROG lvcreate -s -L 4M -n $snapname $vgname/$lvname >>$seqres.full 2>&1 || \
80 _fail "Failed to create snapshot"
82 _mount /dev/mapper/$vgname-$snapname $mnt
84 # write 5M data to the snapshot
85 $XFS_IO_PROG -fc "pwrite 0 5m" -c fsync $mnt/testfile >>$seqres.full 2>&1
87 # _check_dmesg will check for WARNINGs/BUGs in dmesg