2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
7 # Check that getfsmap reports the AG metadata we're expecting.
10 _begin_fstest auto quick rmap fsmap
12 # Override the default cleanup function.
16 rm -rf "$tmp".* $TEST_DIR/fsmap $TEST_DIR/testout
19 # Import common functions.
22 # real QA test starts here
24 _require_xfs_scratch_rmapbt
25 _require_xfs_io_command "fsmap"
29 echo "Format and mount"
30 _scratch_mkfs > "$seqres.full" 2>&1
33 agcount=$(_xfs_mount_agcount $SCRATCH_MNT)
35 # mkfs lays out btree root blocks in the order bnobt, cntbt, inobt, finobt,
36 # rmapbt, refcountbt, and then allocates AGFL blocks. Since GETFSMAP has the
37 # same owner (per-AG metadata) for rmap btree blocks and blocks on the AGFL and
38 # the reverse mapping index merges records, the number of per-AG extents
39 # reported will vary depending on whether the refcount btree is enabled.
40 $XFS_INFO_PROG $SCRATCH_MNT | grep -q reflink=1
41 has_reflink=$(( 1 - $? ))
43 test $has_reflink -gt 0 && perag_metadata_exts=$((perag_metadata_exts + 1))
45 echo "Get fsmap" | tee -a $seqres.full
46 $XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT > $TEST_DIR/fsmap
47 cat $TEST_DIR/fsmap >> $seqres.full
49 echo "Check AG header" | tee -a $seqres.full
50 grep 'static fs metadata[[:space:]]*[0-9]*[[:space:]]*(0\.\.' $TEST_DIR/fsmap | tee -a $seqres.full > $TEST_DIR/testout
51 _within_tolerance "AG header count" $(wc -l < $TEST_DIR/testout) $agcount 0 -v
53 echo "Check freesp/rmap btrees" | tee -a $seqres.full
54 grep 'per-AG metadata[[:space:]]*[0-9]*[[:space:]]*([0-9]*\.\.' $TEST_DIR/fsmap | tee -a $seqres.full > $TEST_DIR/testout
55 _within_tolerance "freesp extent count" $(wc -l < $TEST_DIR/testout) $((agcount * perag_metadata_exts)) 0 999999 -v
57 echo "Check inode btrees" | tee -a $seqres.full
58 grep 'inode btree[[:space:]]*[0-9]*[[:space:]]*([0-9]*\.\.' $TEST_DIR/fsmap | tee -a $seqres.full > $TEST_DIR/testout
59 _within_tolerance "inode btree extent count" $(wc -l < $TEST_DIR/testout) $agcount 0 -v
61 echo "Check inodes" | tee -a $seqres.full
62 grep 'inodes[[:space:]]*[0-9]*[[:space:]]*([0-9]*\.\.' $TEST_DIR/fsmap | tee -a $seqres.full > $TEST_DIR/testout
63 _within_tolerance "inode extent count" $(wc -l < $TEST_DIR/testout) 1 0 999999 -v
65 echo "Check journal" | tee -a $seqres.full
66 grep 'journalling log' $TEST_DIR/fsmap | tee -a $seqres.full > $TEST_DIR/testout
67 _within_tolerance "journal extent count" $(wc -l < $TEST_DIR/testout) 1 0 -v