generic/223: make sure all files get created on the data device
[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_fs generic
32 _require_scratch_reflink
33 _require_xfs_io_command "falloc"
34 _require_xfs_io_command "fiemap"
35 _require_scratch_explicit_shared_extents
36
37 echo "Format and mount"
38 _scratch_mkfs > $seqres.full 2>&1
39 _scratch_mount >> $seqres.full 2>&1
40
41 testdir=$SCRATCH_MNT/test-$seq
42 mkdir $testdir
43
44 blocks=5
45 blksz=65536
46 sz=$((blocks * blksz))
47
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
51 _scratch_cycle_mount
52
53 echo "file1 extents and holes"
54 _count_extents $testdir/file1
55 _count_holes $testdir/file1
56
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
59 _scratch_cycle_mount
60
61 echo "Compare files"
62 md5sum $testdir/file1 | _filter_scratch
63 md5sum $testdir/file2 | _filter_scratch
64
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]...$'
73
74 # success, all done
75 status=0
76 exit