generic: Verify the inheritance behavior of FS_XFLAG_DAX flag in various combinations
[xfstests-dev.git] / tests / generic / 372
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 372
6 #
7 # Check that bmap/fiemap accurately report shared extents.
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 7 15
17
18 _cleanup()
19 {
20         cd /
21         rm -rf $tmp.*
22         wait
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28 . ./common/reflink
29
30 # real QA test starts here
31 _supported_os Linux
32 _supported_fs generic
33 _require_scratch_reflink
34 _require_xfs_io_command "falloc"
35 _require_xfs_io_command "fiemap"
36 _require_scratch_explicit_shared_extents
37
38 echo "Format and mount"
39 _scratch_mkfs > $seqres.full 2>&1
40 _scratch_mount >> $seqres.full 2>&1
41
42 testdir=$SCRATCH_MNT/test-$seq
43 mkdir $testdir
44
45 blocks=5
46 blksz=65536
47 sz=$((blocks * blksz))
48
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
52 _scratch_cycle_mount
53
54 echo "file1 extents and holes"
55 _count_extents $testdir/file1
56 _count_holes $testdir/file1
57
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
60 _scratch_cycle_mount
61
62 echo "Compare files"
63 md5sum $testdir/file1 | _filter_scratch
64 md5sum $testdir/file2 | _filter_scratch
65
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]...$'
74
75 # success, all done
76 status=0
77 exit