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 _begin_fstest auto quick rmap fsmap
12 # Override the default cleanup function.
16 rm -rf "$tmp".* $TEST_DIR/fsmap $TEST_DIR/bmap
19 # Import common functions.
22 # real QA test starts here
24 _require_xfs_scratch_rmapbt
25 _require_xfs_io_command "fsmap"
26 _require_test_program "punch-alternating"
30 echo "Format and mount"
31 _scratch_mkfs > "$seqres.full" 2>&1
34 # Make sure everything is on the data device
35 _xfs_force_bdev data $SCRATCH_MNT
37 _pwrite_byte 0x80 0 737373 $SCRATCH_MNT/urk >> $seqres.full
39 $here/src/punch-alternating $SCRATCH_MNT/urk >> $seqres.full
40 ino=$(stat -c '%i' $SCRATCH_MNT/urk)
42 echo "Get fsmap" | tee -a $seqres.full
43 $XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT >> $seqres.full
44 $XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT | tr '[]()' ' ' > $TEST_DIR/fsmap
46 echo "Get bmap" | tee -a $seqres.full
47 $XFS_IO_PROG -c 'bmap -v' $SCRATCH_MNT/urk >> $seqres.full
48 $XFS_IO_PROG -c 'bmap -v' $SCRATCH_MNT/urk | grep '^[[:space:]]*[0-9]*:' | grep -v 'hole' | tr '[]()' ' ' > $TEST_DIR/bmap
50 echo "Check bmap and fsmap" | tee -a $seqres.full
51 cat $TEST_DIR/bmap | while read ext offrange colon blockrange ag agrange total crap; do
52 qstr="^[[:space:]]*[0-9]*:[[:space:]]*[0-9]*:[0-9]*[[:space:]]*${blockrange} :[[:space:]]*${ino}[[:space:]]*${offrange}[[:space:]]*${ag}[[:space:]]*${agrange}[[:space:]]*${total}$"
53 echo "${qstr}" >> $seqres.full
54 grep "${qstr}" $TEST_DIR/fsmap >> $seqres.full
55 found=$(grep -c "${qstr}" $TEST_DIR/fsmap)
56 test $found -eq 1 || echo "Unexpected output for offset ${offrange}."
59 echo "Check device field of FS metadata and regular file"
60 data_dev=$(grep 'static fs metadata' $TEST_DIR/fsmap | head -n 1 | awk '{print $2}')
61 rt_dev=$(grep "${ino}[[:space:]]*[0-9]*\.\.[0-9]*" $TEST_DIR/fsmap | head -n 1 | awk '{print $2}')
62 test "${data_dev}" = "${rt_dev}" || echo "data ${data_dev} realtime ${rt_dev}?"