2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
7 # Reflink a file with a few dozen extents, CoW a few blocks, and rm.
8 # Force XFS into "two refcount updates per transaction" mode.
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=1 # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
22 _scratch_unmount > /dev/null 2>&1
26 # get standard environment, filters and checks
32 # real QA test starts here
36 _require_scratch_reflink
37 _require_error_injection
38 _require_xfs_io_command "fpunch"
39 _require_xfs_io_error_injection "refcount_continue_update"
46 echo "Format filesystem"
47 _scratch_mkfs >/dev/null 2>&1
48 _scratch_mount >> $seqres.full
51 _pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
52 _cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
53 _cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3
55 # Punch holes in file3
56 seq 1 2 $blks | while read off; do
57 $XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full
62 md5sum $SCRATCH_MNT/file1 | _filter_scratch
63 md5sum $SCRATCH_MNT/file2 | _filter_scratch
64 md5sum $SCRATCH_MNT/file3 | _filter_scratch
67 _scratch_inject_error "refcount_continue_update"
69 echo "CoW all the blocks"
70 $XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz 0 $((blks * blksz))" $SCRATCH_MNT/file2 >> $seqres.full
72 echo "Remount to replay log"
73 _scratch_inject_logprint >> $seqres.full
75 echo "FS should be online, touch should succeed"
76 touch $SCRATCH_MNT/goodfs
78 echo "Check files again"
79 md5sum $SCRATCH_MNT/file1 | _filter_scratch
80 md5sum $SCRATCH_MNT/file2 | _filter_scratch
81 md5sum $SCRATCH_MNT/file3 | _filter_scratch