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
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 $LVM_PROG lvcreate --yes -L 256M -n $lvname $vgname >>$seqres.full 2>&1
69 # wait for lvcreation to fully complete
70 $UDEV_SETTLE_PROG >>$seqres.full 2>&1
72 # _mkfs_dev exits the test on failure, this can make sure lv is created in
73 # above vgcreate/lvcreate steps
74 _mkfs_dev /dev/mapper/$vgname-$lvname
76 # create a 4M snapshot
77 $LVM_PROG lvcreate -s -L 4M -n $snapname $vgname/$lvname >>$seqres.full 2>&1 || \
78 _fail "Failed to create snapshot"
80 _mount /dev/mapper/$vgname-$snapname $mnt
82 # write 5M data to the snapshot
83 $XFS_IO_PROG -fc "pwrite 0 5m" -c fsync $mnt/testfile >>$seqres.full 2>&1
85 # _check_dmesg will check for WARNINGs/BUGs in dmesg