generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / xfs / 276
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 276
6 #
7 # Check that getfsmap agrees with getbmap when realtime files are present.
8 #
9 . ./common/preamble
10 _begin_fstest auto quick rmap fsmap realtime
11
12 # Override the default cleanup function.
13 _cleanup()
14 {
15         cd /
16         rm -rf "$tmp".* $TEST_DIR/fsmap $TEST_DIR/bmap
17 }
18
19 # Import common functions.
20 . ./common/filter
21
22 # real QA test starts here
23 _supported_fs xfs
24 _require_realtime
25 _require_xfs_scratch_rmapbt
26 _require_xfs_io_command "fsmap"
27 _require_test_program "punch-alternating"
28
29 rm -f "$seqres.full"
30
31 echo "Format and mount"
32 _scratch_mkfs | _filter_mkfs 2> "$tmp.mkfs" >/dev/null
33 . $tmp.mkfs
34 cat "$tmp.mkfs" > $seqres.full
35 _scratch_mount
36
37 # Don't let the rt extent size perturb the fsmap output with unwritten
38 # extents in places we don't expect them
39 test $rtextsz -eq $dbsize || _notrun "Skipping test due to rtextsize > 1 fsb"
40
41 $XFS_IO_PROG -f -R -c 'pwrite -S 0x80 0 737373' $SCRATCH_MNT/urk >> $seqres.full
42 sync
43 $here/src/punch-alternating $SCRATCH_MNT/urk >> $seqres.full
44 ino=$(stat -c '%i' $SCRATCH_MNT/urk)
45
46 echo "Get fsmap" | tee -a $seqres.full
47 $XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT >> $seqres.full
48 $XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT | tr '[]()' '    ' > $TEST_DIR/fsmap
49
50 echo "Get bmap" | tee -a $seqres.full
51 $XFS_IO_PROG -c 'bmap -v' $SCRATCH_MNT/urk >> $seqres.full
52 $XFS_IO_PROG -c 'bmap -v' $SCRATCH_MNT/urk | grep '^[[:space:]]*[0-9]*:' | grep -v 'hole' | tr '[]()' '    ' > $TEST_DIR/bmap
53
54 echo "Check bmap and fsmap" | tee -a $seqres.full
55 cat $TEST_DIR/bmap | while read ext offrange colon blockrange ag agrange total crap; do
56         qstr="^[[:space:]]*[0-9]*:[[:space:]]*[0-9]*:[0-9]*[[:space:]]*${blockrange} :[[:space:]]*${ino}[[:space:]]*${offrange}[[:space:]]*${ag}[[:space:]]*${agrange}[[:space:]]*${total}$"
57         echo "${qstr}" >> $seqres.full
58         grep "${qstr}" $TEST_DIR/fsmap >> $seqres.full
59         found=$(grep -c "${qstr}" $TEST_DIR/fsmap)
60         test $found -eq 1 || echo "Unexpected output for offset ${offrange}."
61 done
62
63 echo "Check device field of FS metadata and realtime file"
64 data_dev=$(grep 'static fs metadata' $TEST_DIR/fsmap | head -n 1 | awk '{print $2}')
65 rt_dev=$(grep "${ino}[[:space:]]*[0-9]*\.\.[0-9]*[[:space:]]*[0-9]*$" $TEST_DIR/fsmap | head -n 1 | awk '{print $2}')
66 test "${data_dev}" != "${rt_dev}" || echo "data ${data_dev} realtime ${rt_dev}?"
67
68 # success, all done
69 status=0
70 exit