2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Oracle, Inc. All Rights Reserved.
7 # Check that GETBMAPX accurately report shared extents.
10 _begin_fstest auto quick clone
12 _register_cleanup "_cleanup" BUS
14 # Import common functions.
18 # real QA test starts here
20 _require_scratch_reflink
21 _require_xfs_io_command "bmap"
22 _require_xfs_io_command "falloc"
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 sz=$((blocks * blksz))
35 echo "Create the original files"
36 $XFS_IO_PROG -f -c "falloc 0 $sz" $testdir/file1 >> $seqres.full
37 _pwrite_byte 0x61 0 $sz $testdir/file1 >> $seqres.full
41 $XFS_IO_PROG -c 'bmap -v' $1 | grep '^[[:space:]]*[0-9]*:'
44 echo "file1 extents and holes"
45 bmap $testdir/file1 | grep -v -c hole
46 bmap $testdir/file1 | grep -c hole
48 _reflink_range $testdir/file1 $blksz $testdir/file2 $((blksz * 3)) $blksz >> $seqres.full
49 _reflink_range $testdir/file1 $((blksz * 3)) $testdir/file2 $blksz $blksz >> $seqres.full
53 md5sum $testdir/file1 | _filter_scratch
54 md5sum $testdir/file2 | _filter_scratch
56 echo "file1 extents and holes"
57 bmap $testdir/file1 | grep -v -c hole
58 bmap $testdir/file1 | grep -c hole
59 echo "file2 extents and holes"
60 bmap $testdir/file2 | grep -v -c hole
61 bmap $testdir/file2 | grep -c hole
62 echo "file1 shared extents"
63 bmap $testdir/file1 | grep -c '1.....$'