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
33 _require_scratch_reflink
34 _require_xfs_io_command "falloc"
35 _require_xfs_io_command "fiemap"
36 _require_scratch_explicit_shared_extents
38 echo "Format and mount"
39 _scratch_mkfs > $seqres.full 2>&1
40 _scratch_mount >> $seqres.full 2>&1
42 testdir=$SCRATCH_MNT/test-$seq
47 sz=$((blocks * blksz))
49 echo "Create the original files"
50 $XFS_IO_PROG -f -c "falloc 0 $sz" $testdir/file1 >> $seqres.full
51 _pwrite_byte 0x61 0 $sz $testdir/file1 >> $seqres.full
54 echo "file1 extents and holes"
55 _count_extents $testdir/file1
56 _count_holes $testdir/file1
58 _reflink_range $testdir/file1 $blksz $testdir/file2 $((blksz * 3)) $blksz >> $seqres.full
59 _reflink_range $testdir/file1 $((blksz * 3)) $testdir/file2 $blksz $blksz >> $seqres.full
63 md5sum $testdir/file1 | _filter_scratch
64 md5sum $testdir/file2 | _filter_scratch
66 echo "file1 extents and holes"
67 _count_extents $testdir/file1
68 _count_holes $testdir/file1
69 echo "file2 extents and holes"
70 _count_extents $testdir/file2
71 _count_holes $testdir/file2
72 echo "file1 shared extents"
73 $XFS_IO_PROG -c 'fiemap -v' $testdir/file1 | awk '{print $5}' | grep -c '0x.*[2367aAbBfF]...$'