2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Red Hat Inc. All Rights Reserved.
7 # Test I/O error path by fully filling an dm snapshot.
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
22 # lvm may have umounted it on I/O error, but in case it does not
23 # wait a bit for lvm to settle, sigh..
25 $UMOUNT_PROG $mnt >/dev/null 2>&1
26 $LVM_PROG vgremove -f $vgname >>$seqres.full 2>&1
27 $LVM_PROG pvremove -f $SCRATCH_DEV >>$seqres.full 2>&1
30 # get standard environment, filters and checks
34 # real QA test starts here
38 _require_scratch_nocheck
39 _require_dm_target snapshot
40 _require_command $LVM_PROG lvm
42 echo "Silence is golden"
48 mnt=$TEST_DIR/mnt_$seq
51 # make sure there's enough disk space for 256M lv, test for 300M here in case
52 # lvm uses some space for metadata
53 _scratch_mkfs_sized $((300 * 1024 * 1024)) >>$seqres.full 2>&1
54 $LVM_PROG vgcreate -f $vgname $SCRATCH_DEV >>$seqres.full 2>&1
55 # We use yes pipe instead of 'lvcreate --yes' because old version of lvm
56 # (like 2.02.95 in RHEL6) don't support --yes option
57 yes | $LVM_PROG lvcreate -L 256M -n $lvname $vgname >>$seqres.full 2>&1
58 # wait for lvcreation to fully complete
59 $UDEV_SETTLE_PROG >>$seqres.full 2>&1
61 # _mkfs_dev exits the test on failure, this can make sure lv is created in
62 # above vgcreate/lvcreate steps
63 _mkfs_dev /dev/mapper/$vgname-$lvname
65 # create a 4M snapshot
66 $LVM_PROG lvcreate -s -L 4M -n $snapname $vgname/$lvname >>$seqres.full 2>&1 || \
67 _fail "Failed to create snapshot"
69 _mount /dev/mapper/$vgname-$snapname $mnt
71 # write 5M data to the snapshot
72 $XFS_IO_PROG -fc "pwrite 0 5m" -c fsync $mnt/testfile >>$seqres.full 2>&1
74 # _check_dmesg will check for WARNINGs/BUGs in dmesg