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
31 _require_scratch_reflink
32 _require_xfs_io_command "bmap"
33 _require_xfs_io_command "falloc"
35 echo "Format and mount"
36 _scratch_mkfs > $seqres.full 2>&1
37 _scratch_mount >> $seqres.full 2>&1
39 testdir=$SCRATCH_MNT/test-$seq
44 sz=$((blocks * blksz))
46 echo "Create the original files"
47 $XFS_IO_PROG -f -c "falloc 0 $sz" $testdir/file1 >> $seqres.full
48 _pwrite_byte 0x61 0 $sz $testdir/file1 >> $seqres.full
52 $XFS_IO_PROG -c 'bmap -v' $1 | grep '^[[:space:]]*[0-9]*:'
55 echo "file1 extents and holes"
56 bmap $testdir/file1 | grep -v -c hole
57 bmap $testdir/file1 | grep -c hole
59 _reflink_range $testdir/file1 $blksz $testdir/file2 $((blksz * 3)) $blksz >> $seqres.full
60 _reflink_range $testdir/file1 $((blksz * 3)) $testdir/file2 $blksz $blksz >> $seqres.full
64 md5sum $testdir/file1 | _filter_scratch
65 md5sum $testdir/file2 | _filter_scratch
67 echo "file1 extents and holes"
68 bmap $testdir/file1 | grep -v -c hole
69 bmap $testdir/file1 | grep -c hole
70 echo "file2 extents and holes"
71 bmap $testdir/file2 | grep -v -c hole
72 bmap $testdir/file2 | grep -c hole
73 echo "file1 shared extents"
74 bmap $testdir/file1 | grep -c '1.....$'