2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
7 # Punch a file at midway through a CoW region.
9 # This test is dependent on the system page size, so we cannot use md5 in
10 # the golden output; we can only compare to a check file.
13 _begin_fstest auto quick clone punch
15 # Import common functions.
19 # real QA test starts here
20 _require_scratch_reflink
22 _require_xfs_io_command "fpunch"
24 echo "Format and mount"
25 _scratch_mkfs > $seqres.full 2>&1
26 _scratch_mount >> $seqres.full 2>&1
28 testdir=$SCRATCH_MNT/test-$seq
33 filesize=$((blksz * nr))
35 echo "Create the original files"
36 _pwrite_byte 0x61 0 $filesize $testdir/file1 >> $seqres.full
37 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
38 _pwrite_byte 0x61 0 $filesize $testdir/file2.chk >> $seqres.full
42 md5sum $testdir/file1 | _filter_scratch
43 md5sum $testdir/file2 | _filter_scratch
44 md5sum $testdir/file2.chk | _filter_scratch
46 echo "CoW and unmount"
47 $XFS_IO_PROG -f -c "pwrite -S 0x62 -b $((blksz * 3)) $blksz $((blksz * 3))" -c "fpunch $((blksz * 2)) $blksz" $testdir/file2 >> $seqres.full
49 $XFS_IO_PROG -f -c "pwrite -S 0x62 -b $((blksz * 3)) $blksz $((blksz * 3))" -c "pwrite -S 0x00 $((blksz * 2)) $blksz" $testdir/file2.chk >> $seqres.full
53 md5sum $testdir/file1 | _filter_scratch
54 md5sum $testdir/file2 | _filter_scratch
55 md5sum $testdir/file2.chk | _filter_scratch