common/rc: add _scratch_{u}mount_idmapped() helpers
[xfstests-dev.git] / tests / xfs / 271
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. 271
6 #
7 # Check that getfsmap reports the AG metadata we're expecting.
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 15
17
18 _cleanup()
19 {
20         cd /
21         rm -rf "$tmp".* $TEST_DIR/fsmap $TEST_DIR/testout
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27
28 # real QA test starts here
29 _supported_fs xfs
30 _require_xfs_scratch_rmapbt
31 _require_xfs_io_command "fsmap"
32
33 rm -f "$seqres.full"
34
35 echo "Format and mount"
36 _scratch_mkfs > "$seqres.full" 2>&1
37 _scratch_mount
38
39 agcount=$(_xfs_mount_agcount $SCRATCH_MNT)
40
41 # mkfs lays out btree root blocks in the order bnobt, cntbt, inobt, finobt,
42 # rmapbt, refcountbt, and then allocates AGFL blocks.  Since GETFSMAP has the
43 # same owner (per-AG metadata) for rmap btree blocks and blocks on the AGFL and
44 # the reverse mapping index merges records, the number of per-AG extents
45 # reported will vary depending on whether the refcount btree is enabled.
46 $XFS_INFO_PROG $SCRATCH_MNT | grep -q reflink=1
47 has_reflink=$(( 1 - $? ))
48 perag_metadata_exts=2
49 test $has_reflink -gt 0 && perag_metadata_exts=$((perag_metadata_exts + 1))
50
51 echo "Get fsmap" | tee -a $seqres.full
52 $XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT > $TEST_DIR/fsmap
53 cat $TEST_DIR/fsmap >> $seqres.full
54
55 echo "Check AG header" | tee -a $seqres.full
56 grep 'static fs metadata[[:space:]]*[0-9]*[[:space:]]*(0\.\.' $TEST_DIR/fsmap | tee -a $seqres.full > $TEST_DIR/testout
57 _within_tolerance "AG header count" $(wc -l < $TEST_DIR/testout) $agcount 0 -v
58
59 echo "Check freesp/rmap btrees" | tee -a $seqres.full
60 grep 'per-AG metadata[[:space:]]*[0-9]*[[:space:]]*([0-9]*\.\.' $TEST_DIR/fsmap | tee -a $seqres.full > $TEST_DIR/testout
61 _within_tolerance "freesp extent count" $(wc -l < $TEST_DIR/testout) $((agcount * perag_metadata_exts)) 0 999999 -v
62
63 echo "Check inode btrees" | tee -a $seqres.full
64 grep 'inode btree[[:space:]]*[0-9]*[[:space:]]*([0-9]*\.\.' $TEST_DIR/fsmap | tee -a $seqres.full > $TEST_DIR/testout
65 _within_tolerance "inode btree extent count" $(wc -l < $TEST_DIR/testout) $agcount 0 -v
66
67 echo "Check inodes" | tee -a $seqres.full
68 grep 'inodes[[:space:]]*[0-9]*[[:space:]]*([0-9]*\.\.' $TEST_DIR/fsmap | tee -a $seqres.full > $TEST_DIR/testout
69 _within_tolerance "inode extent count" $(wc -l < $TEST_DIR/testout) 1 0 999999 -v
70
71 echo "Check journal" | tee -a $seqres.full
72 grep 'journalling log' $TEST_DIR/fsmap | tee -a $seqres.full > $TEST_DIR/testout
73 _within_tolerance "journal extent count" $(wc -l < $TEST_DIR/testout) 1 0 -v
74
75 # success, all done
76 status=0
77 exit