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 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 7 15
24 # get standard environment, filters and checks
29 # real QA test starts here
32 _require_scratch_reflink
33 _require_xfs_io_command "bmap"
34 _require_xfs_io_command "falloc"
36 echo "Format and mount"
37 _scratch_mkfs > $seqres.full 2>&1
38 _scratch_mount >> $seqres.full 2>&1
40 testdir=$SCRATCH_MNT/test-$seq
45 sz=$((blocks * blksz))
47 echo "Create the original files"
48 $XFS_IO_PROG -f -c "falloc 0 $sz" $testdir/file1 >> $seqres.full
49 _pwrite_byte 0x61 0 $sz $testdir/file1 >> $seqres.full
53 $XFS_IO_PROG -c 'bmap -v' $1 | grep '^[[:space:]]*[0-9]*:'
56 echo "file1 extents and holes"
57 bmap $testdir/file1 | grep -v -c hole
58 bmap $testdir/file1 | grep -c hole
60 _reflink_range $testdir/file1 $blksz $testdir/file2 $((blksz * 3)) $blksz >> $seqres.full
61 _reflink_range $testdir/file1 $((blksz * 3)) $testdir/file2 $blksz $blksz >> $seqres.full
65 md5sum $testdir/file1 | _filter_scratch
66 md5sum $testdir/file2 | _filter_scratch
68 echo "file1 extents and holes"
69 bmap $testdir/file1 | grep -v -c hole
70 bmap $testdir/file1 | grep -c hole
71 echo "file2 extents and holes"
72 bmap $testdir/file2 | grep -v -c hole
73 bmap $testdir/file2 | grep -c hole
74 echo "file1 shared extents"
75 bmap $testdir/file1 | grep -c '1.....$'