2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
7 # Check that getfsmap agrees with getbmap.
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 15
21 rm -rf "$tmp".* $TEST_DIR/fsmap $TEST_DIR/bmap
24 # get standard environment, filters and checks
28 # real QA test starts here
30 _require_xfs_scratch_rmapbt
31 _require_xfs_io_command "fsmap"
32 _require_test_program "punch-alternating"
36 echo "Format and mount"
37 _scratch_mkfs > "$seqres.full" 2>&1
40 # Make sure everything is on the data device
41 $XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
43 _pwrite_byte 0x80 0 737373 $SCRATCH_MNT/urk >> $seqres.full
45 $here/src/punch-alternating $SCRATCH_MNT/urk >> $seqres.full
46 ino=$(stat -c '%i' $SCRATCH_MNT/urk)
48 echo "Get fsmap" | tee -a $seqres.full
49 $XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT >> $seqres.full
50 $XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT | tr '[]()' ' ' > $TEST_DIR/fsmap
52 echo "Get bmap" | tee -a $seqres.full
53 $XFS_IO_PROG -c 'bmap -v' $SCRATCH_MNT/urk >> $seqres.full
54 $XFS_IO_PROG -c 'bmap -v' $SCRATCH_MNT/urk | grep '^[[:space:]]*[0-9]*:' | grep -v 'hole' | tr '[]()' ' ' > $TEST_DIR/bmap
56 echo "Check bmap and fsmap" | tee -a $seqres.full
57 cat $TEST_DIR/bmap | while read ext offrange colon blockrange ag agrange total crap; do
58 qstr="^[[:space:]]*[0-9]*:[[:space:]]*[0-9]*:[0-9]*[[:space:]]*${blockrange} :[[:space:]]*${ino}[[:space:]]*${offrange}[[:space:]]*${ag}[[:space:]]*${agrange}[[:space:]]*${total}$"
59 echo "${qstr}" >> $seqres.full
60 grep "${qstr}" $TEST_DIR/fsmap >> $seqres.full
61 found=$(grep -c "${qstr}" $TEST_DIR/fsmap)
62 test $found -eq 1 || echo "Unexpected output for offset ${offrange}."
65 echo "Check device field of FS metadata and regular file"
66 data_dev=$(grep 'static fs metadata' $TEST_DIR/fsmap | head -n 1 | awk '{print $2}')
67 rt_dev=$(grep "${ino}[[:space:]]*[0-9]*\.\.[0-9]*" $TEST_DIR/fsmap | head -n 1 | awk '{print $2}')
68 test "${data_dev}" = "${rt_dev}" || echo "data ${data_dev} realtime ${rt_dev}?"