2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Oracle, Inc. All Rights Reserved.
7 # Check that bmap/fiemap 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
25 # get standard environment, filters and checks
30 # real QA test starts here
32 _require_scratch_reflink
33 _require_xfs_io_command "falloc"
34 _require_xfs_io_command "fiemap"
35 _require_scratch_explicit_shared_extents
37 echo "Format and mount"
38 _scratch_mkfs > $seqres.full 2>&1
39 _scratch_mount >> $seqres.full 2>&1
41 testdir=$SCRATCH_MNT/test-$seq
46 sz=$((blocks * blksz))
48 echo "Create the original files"
49 $XFS_IO_PROG -f -c "falloc 0 $sz" $testdir/file1 >> $seqres.full
50 _pwrite_byte 0x61 0 $sz $testdir/file1 >> $seqres.full
53 echo "file1 extents and holes"
54 _count_extents $testdir/file1
55 _count_holes $testdir/file1
57 _reflink_range $testdir/file1 $blksz $testdir/file2 $((blksz * 3)) $blksz >> $seqres.full
58 _reflink_range $testdir/file1 $((blksz * 3)) $testdir/file2 $blksz $blksz >> $seqres.full
62 md5sum $testdir/file1 | _filter_scratch
63 md5sum $testdir/file2 | _filter_scratch
65 echo "file1 extents and holes"
66 _count_extents $testdir/file1
67 _count_holes $testdir/file1
68 echo "file2 extents and holes"
69 _count_extents $testdir/file2
70 _count_holes $testdir/file2
71 echo "file1 shared extents"
72 $XFS_IO_PROG -c 'fiemap -v' $testdir/file1 | awk '{print $5}' | grep -c '0x.*[2367aAbBfF]...$'