2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2021 Oracle. All Rights Reserved.
7 # Regression test for commit:
9 # 72a048c1056a ("xfs: only set IOMAP_F_SHARED when providing a srcmap to a write")
11 # If a user creates a sparse shared region in a file, convinces XFS to create a
12 # copy-on-write delayed allocation reservation spanning both the shared blocks
13 # and the holes, and then calls the fallocate unshare command to unshare the
14 # entire sparse region, XFS incorrectly tells iomap that the delalloc blocks
15 # for the holes are shared, which causes it to error out while trying to
19 _begin_fstest auto clone unshare
21 # Override the default cleanup function.
25 rm -r -f $tmp.* $TEST_DIR/$seq
28 # Import common functions.
32 # real QA test starts here
34 # Modify as appropriate.
38 _require_test_program "punch-alternating"
39 _require_xfs_io_command "fpunch" # make sure punch-alt can do its job
40 _require_xfs_io_command "funshare"
41 test "$FSTYP" = "xfs" && _require_xfs_io_command "cowextsize"
44 file1=$TEST_DIR/$seq/a
45 file2=$TEST_DIR/$seq/b
47 $XFS_IO_PROG -f -c "pwrite -S 0x58 -b 10m 0 10m" $file1 >> $seqres.full
49 f1sum0="$(md5sum $file1 | _filter_test_dir)"
51 _cp_reflink $file1 $file2
52 $here/src/punch-alternating -o 1 $file2
54 f2sum0="$(md5sum $file2 | _filter_test_dir)"
56 # set cowextsize to the defaults (128k) to force delalloc cow preallocations
57 test "$FSTYP" = "xfs" && $XFS_IO_PROG -c 'cowextsize 0' $file2
58 $XFS_IO_PROG -c "funshare 0 10m" $file2
60 f1sum1="$(md5sum $file1 | _filter_test_dir)"
61 f2sum1="$(md5sum $file2 | _filter_test_dir)"
63 test "${f1sum0}" = "${f1sum1}" || echo "file1 should not have changed"
64 test "${f2sum0}" = "${f2sum1}" || echo "file2 should not have changed"
68 f1sum2="$(md5sum $file1 | _filter_test_dir)"
69 f2sum2="$(md5sum $file2 | _filter_test_dir)"
71 test "${f1sum2}" = "${f1sum1}" || echo "file1 should not have changed ondisk"
72 test "${f2sum2}" = "${f2sum1}" || echo "file2 should not have changed ondisk"
75 echo Silence is golden