4 # Reflink a file with a few dozen extents, CoW a few blocks, and rm.
5 # Inject an error during refcount updates to test log recovery. Use
6 # cowextsize so that the refcount failure is somewhere in the CoW remap
7 # instead of when we're stashing the CoW orphan record.
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #-----------------------------------------------------------------------
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
32 status=1 # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
38 _scratch_unmount > /dev/null 2>&1
42 # get standard environment, filters and checks
48 # real QA test starts here
52 _require_scratch_reflink
53 _require_xfs_io_command "cowextsize"
54 _require_xfs_io_error_injection "refcount_finish_one"
61 echo "Format filesystem"
62 _scratch_mkfs >/dev/null 2>&1
63 _scratch_mount >> $seqres.full
65 $XFS_IO_PROG -c "cowextsize $sz" $SCRATCH_MNT
68 _pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
69 _cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
70 _cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3
72 # Punch holes in file3
73 seq 1 2 $blks | while read off; do
74 $XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full
79 md5sum $SCRATCH_MNT/file1 | _filter_scratch
80 md5sum $SCRATCH_MNT/file2 | _filter_scratch
81 md5sum $SCRATCH_MNT/file3 | _filter_scratch
83 $XFS_IO_PROG -c "pwrite -W -S 0x67 $((10 * blksz)) 1" $SCRATCH_MNT/file2 >> $seqres.full
87 _scratch_inject_error "refcount_finish_one"
89 echo "CoW a few blocks"
90 $XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz $((10 * blksz)) $((10 * blksz))" $SCRATCH_MNT/file2 >> $seqres.full 2>&1
92 echo "FS should be shut down, touch will fail"
93 touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
95 echo "Remount to replay log"
96 _scratch_inject_logprint >> $seqres.full
98 echo "FS should be online, touch should succeed"
99 touch $SCRATCH_MNT/goodfs
101 echo "Check files again"
102 md5sum $SCRATCH_MNT/file1 | _filter_scratch
103 md5sum $SCRATCH_MNT/file2 | _filter_scratch
104 md5sum $SCRATCH_MNT/file3 | _filter_scratch