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 # wait a bit for lvm to settle, sigh..
40 $UMOUNT_PROG $mnt >/dev/null 2>&1
41 $LVM_PROG vgremove -f $vgname >>$seqres.full 2>&1
42 $LVM_PROG pvremove -f $SCRATCH_DEV >>$seqres.full 2>&1
45 # get standard environment, filters and checks
49 # real QA test starts here
53 _require_scratch_nocheck
54 _require_dm_target snapshot
55 _require_command $LVM_PROG lvm
57 echo "Silence is golden"
63 mnt=$TEST_DIR/mnt_$seq
66 # make sure there's enough disk space for 256M lv, test for 300M here in case
67 # lvm uses some space for metadata
68 _scratch_mkfs_sized $((300 * 1024 * 1024)) >>$seqres.full 2>&1
69 $LVM_PROG vgcreate -f $vgname $SCRATCH_DEV >>$seqres.full 2>&1
70 # We use yes pipe instead of 'lvcreate --yes' because old version of lvm
71 # (like 2.02.95 in RHEL6) don't support --yes option
72 yes | $LVM_PROG lvcreate -L 256M -n $lvname $vgname >>$seqres.full 2>&1
73 # wait for lvcreation to fully complete
74 $UDEV_SETTLE_PROG >>$seqres.full 2>&1
76 # _mkfs_dev exits the test on failure, this can make sure lv is created in
77 # above vgcreate/lvcreate steps
78 _mkfs_dev /dev/mapper/$vgname-$lvname
80 # create a 4M snapshot
81 $LVM_PROG lvcreate -s -L 4M -n $snapname $vgname/$lvname >>$seqres.full 2>&1 || \
82 _fail "Failed to create snapshot"
84 _mount /dev/mapper/$vgname-$snapname $mnt
86 # write 5M data to the snapshot
87 $XFS_IO_PROG -fc "pwrite 0 5m" -c fsync $mnt/testfile >>$seqres.full 2>&1
89 # _check_dmesg will check for WARNINGs/BUGs in dmesg