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.
8 # Force XFS into "two refcount updates per transaction" mode.
11 _begin_fstest auto quick clone
13 # Override the default cleanup function.
17 _scratch_unmount > /dev/null 2>&1
21 # Import common functions.
26 # real QA test starts here
29 _require_scratch_reflink
30 _require_error_injection
31 _require_xfs_io_command "fpunch"
32 _require_xfs_io_error_injection "refcount_continue_update"
37 echo "Format filesystem"
38 _scratch_mkfs >/dev/null 2>&1
39 _scratch_mount >> $seqres.full
42 _pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
43 _cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
44 _cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3
46 # Punch holes in file3
47 seq 1 2 $blks | while read off; do
48 $XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full
53 md5sum $SCRATCH_MNT/file1 | _filter_scratch
54 md5sum $SCRATCH_MNT/file2 | _filter_scratch
55 md5sum $SCRATCH_MNT/file3 | _filter_scratch
58 _scratch_inject_error "refcount_continue_update"
60 echo "Reflink all the blocks"
61 _cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file4
63 echo "Remount to replay log"
64 _scratch_inject_logprint >> $seqres.full
66 echo "FS should be online, touch should succeed"
67 touch $SCRATCH_MNT/goodfs
69 echo "Check files again"
70 md5sum $SCRATCH_MNT/file1 | _filter_scratch
71 md5sum $SCRATCH_MNT/file2 | _filter_scratch
72 md5sum $SCRATCH_MNT/file3 | _filter_scratch
73 md5sum $SCRATCH_MNT/file4 | _filter_scratch