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
36 _require_scratch_reflink
37 _require_xfs_io_command "falloc"
38 _require_xfs_io_command "bmap" "-c"
43 echo "Format and mount"
44 _scratch_mkfs > $seqres.full 2>&1
45 _scratch_mount >> $seqres.full 2>&1
47 testdir=$SCRATCH_MNT/test-$seq
50 echo "Create the original files"
51 $XFS_IO_PROG -f -c "falloc 0 256k" -c "pwrite 252k 6k" $testdir/file1 >> $seqres.full
53 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
56 md5sum $testdir/file1 | _filter_scratch
57 md5sum $testdir/file2 | _filter_scratch
59 echo "Unwritten data extents"
60 test $(_xfs_bmapx_find data $testdir/file1 '10000$') -gt 0 || \
61 echo "Expected to find an unwritten file1 extent"
62 echo "Shared data extents"
63 test $(_xfs_bmapx_find data $testdir/file1 '100000$') -gt 0 || \
64 echo "Expected to find a shared data extent"
66 echo "Hole data extents"
67 test $(_xfs_bmapx_find data $testdir/file2 'hole') -gt 0 || \
68 echo "Expected to find a hole data extent"
69 echo "Shared data extents"
70 test $(_xfs_bmapx_find data $testdir/file2 '100000$') -gt 0 || \
71 echo "Expected to find a shared data extent"
73 echo "Hole cow extents"
74 test $(_xfs_bmapx_find cow $testdir/file1 'hole') -gt 0 || \
75 echo "Expected to find a hole cow extent"
76 echo "Hole cow extents"
77 test $(_xfs_bmapx_find cow $testdir/file2 'hole') -gt 0 || \
78 echo "Expected to find a hole cow extent"