2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
7 # Make sure that reflink deals with extents going beyond EOF.
8 # - fallocate 256k in file1
9 # - pwrite 252-257k to cause it to speculatively prealloc file1
10 # - reflink file1 to file2
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
19 status=1 # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
28 # get standard environment, filters and checks
33 # real QA test starts here
37 _require_scratch_reflink
38 _require_xfs_io_command "falloc"
39 _require_xfs_io_command "bmap" "-c"
44 echo "Format and mount"
45 _scratch_mkfs > $seqres.full 2>&1
46 _scratch_mount >> $seqres.full 2>&1
48 testdir=$SCRATCH_MNT/test-$seq
51 echo "Create the original files"
52 $XFS_IO_PROG -f -c "falloc 0 256k" -c "pwrite 252k 6k" $testdir/file1 >> $seqres.full
54 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
57 md5sum $testdir/file1 | _filter_scratch
58 md5sum $testdir/file2 | _filter_scratch
60 echo "Unwritten data extents"
61 test $(_xfs_bmapx_find data $testdir/file1 '10000$') -gt 0 || \
62 echo "Expected to find an unwritten file1 extent"
63 echo "Shared data extents"
64 test $(_xfs_bmapx_find data $testdir/file1 '100000$') -gt 0 || \
65 echo "Expected to find a shared data extent"
67 echo "Hole data extents"
68 test $(_xfs_bmapx_find data $testdir/file2 'hole') -gt 0 || \
69 echo "Expected to find a hole data extent"
70 echo "Shared data extents"
71 test $(_xfs_bmapx_find data $testdir/file2 '100000$') -gt 0 || \
72 echo "Expected to find a shared data extent"
74 echo "Hole cow extents"
75 test $(_xfs_bmapx_find cow $testdir/file1 'hole') -gt 0 || \
76 echo "Expected to find a hole cow extent"
77 echo "Hole cow extents"
78 test $(_xfs_bmapx_find cow $testdir/file2 'hole') -gt 0 || \
79 echo "Expected to find a hole cow extent"