4 # Reflink a file with a few dozen extents and CoW a few blocks.
5 # Inject an error during extent freeing to test log recovery.
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #-----------------------------------------------------------------------
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
36 _scratch_unmount > /dev/null 2>&1
40 # get standard environment, filters and checks
46 # real QA test starts here
50 _require_scratch_reflink
51 _require_error_injection
52 _require_xfs_io_command "cowextsize"
53 _require_xfs_io_error_injection "free_extent"
60 echo "Format filesystem"
61 _scratch_mkfs >/dev/null 2>&1
62 _scratch_mount >> $seqres.full
64 $XFS_IO_PROG -c "cowextsize $sz" $SCRATCH_MNT
67 _pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
68 _pwrite_byte 0x66 $((sz / 2)) $((sz / 2)) $SCRATCH_MNT/file2 >> $seqres.full
69 _reflink_range $SCRATCH_MNT/file1 0 $SCRATCH_MNT/file2 0 $((sz / 2)) >> $seqres.full
73 md5sum $SCRATCH_MNT/file1 | _filter_scratch
74 md5sum $SCRATCH_MNT/file2 | _filter_scratch
77 _scratch_inject_error "free_extent"
79 echo "CoW a few blocks"
80 $XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz 0 $sz" $SCRATCH_MNT/file1 >> $seqres.full 2>&1
83 echo "FS should be shut down, touch will fail"
84 touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
86 echo "Remount to replay log"
87 _scratch_inject_logprint >> $seqres.full
89 echo "FS should be online, touch should succeed"
90 touch $SCRATCH_MNT/goodfs
92 echo "Check files again"
93 md5sum $SCRATCH_MNT/file1 | _filter_scratch
94 md5sum $SCRATCH_MNT/file2 | _filter_scratch