2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
7 # Ensure that unaligned punch-hole steps around reflinked ranges:
8 # - Create a reflink clone of a file
9 # - Perform an unaligned punch in the middle of the file.
10 # - Check that the reflinked areas are still there.
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
18 status=1 # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
24 rm -rf $tmp.* $testdir
27 # get standard environment, filters and checks
32 # real QA test starts here
35 _require_xfs_io_command "fpunch"
39 testdir=$TEST_DIR/test-$seq
43 echo "Create the original files"
45 _pwrite_byte 0x61 0 $((blksz * 3)) $testdir/file1 >> $seqres.full
47 _cp_reflink $testdir/file1 $testdir/file2
49 _pwrite_byte 0x61 0 $((blksz * 3)) $testdir/file2.chk >> $seqres.full
50 _pwrite_byte 0x00 $((blksz - 17)) $((blksz + 17)) $testdir/file2.chk >> $seqres.full
53 md5sum $testdir/file1 | _filter_test_dir
54 md5sum $testdir/file2 | _filter_test_dir
55 md5sum $testdir/file2.chk | _filter_test_dir
57 c1=$(_md5_checksum $testdir/file1)
58 c2=$(_md5_checksum $testdir/file2)
60 test ${c1} = ${c2} || echo "file1 and file2 should match"
63 $XFS_IO_PROG -f -c "fpunch $((blksz - 17)) $((blksz + 17))" $testdir/file2
67 md5sum $testdir/file1 | _filter_test_dir
68 md5sum $testdir/file2 | _filter_test_dir
69 md5sum $testdir/file2.chk | _filter_test_dir
71 c1=$(_md5_checksum $testdir/file1)
72 c2=$(_md5_checksum $testdir/file2)
74 test ${c1} != ${c2} || echo "file1 and file2 should not match"
76 echo "Compare against check files"
77 cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk do not match"