4 # exercise xfs_db bug #789674 and other freesp functionality
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
8 #-----------------------------------------------------------------------
14 echo "QA output created by $seq"
26 trap "_cleanup" 0 1 2 3 15
30 echo "=== mkfs output ===" >>$seq.full
31 _scratch_mkfs_xfs | tee -a $seq.full | _filter_mkfs 2>$tmp.mkfs
34 dd if=/dev/zero of=$SCRATCH_MNT/foo count=200 bs=4096 >/dev/null 2>&1 &
35 dd if=/dev/zero of=$SCRATCH_MNT/goo count=400 bs=4096 >/dev/null 2>&1 &
36 dd if=/dev/zero of=$SCRATCH_MNT/moo count=800 bs=4096 >/dev/null 2>&1 &
38 umount $SCRATCH_MNT # flush everything
39 _scratch_mount # and then remount
43 # get standard environment, filters and checks
47 # real QA test starts here
49 _supported_os IRIX Linux
59 [ "$HOSTOS" = "Linux" ] && DF_PROG="$DF_PROG -P --block-size=512"
61 eval `$DF_PROG $SCRATCH_MNT 2>&1 \
62 | tail -1 | $AWK_PROG '{ printf "blocks=%u used=%u avail=%u\n", $3, $4, $5 }'`
63 echo "df gave: blocks=$blocks used=$used avail=$avail" >>$seq.full
64 echo "blocksize from mkfs is '$dbsize'" >>$seq.full
66 xfs_db -r -c "freesp -s" $SCRATCH_DEV >$tmp.xfs_db
67 echo "xfs_db for $SCRATCH_DEV" >>$seq.full
68 cat $tmp.xfs_db >>$seq.full
70 eval `$XFS_IO_PROG -x -c resblks $SCRATCH_MNT 2>&1 \
71 | $AWK_PROG '/available/ { printf "resblks=%u\n", $5 }'`
72 echo "resblks gave: resblks=$resblks" >>$seq.full
74 # check the 'blocks' field from freesp command is OK
75 # since 2.6.18, df does not report the 4 blocks per AG that cannot
76 # be allocated, hence we check for that exact mismatch.
77 # since ~2.6.22, reserved blocks are used by default and df does
78 # not report them, hence check for an exact mismatch.
80 BEGIN { $avail ='$avail' * 512;
81 $answer="(no xfs_db free blocks line?)" }
82 /free blocks (\d+)$/ || next;
83 $freesp = $1 * '$dbsize';
84 if ($freesp == $avail) {
87 $avail = $avail + (('$agcount' + 1) * '$dbsize' * 4);
88 if ($freesp == $avail) {
91 $avail = $avail + ('$resblks' * '$dbsize');
92 if ($freesp == $avail) {
95 $answer = "no ($freesp != $avail)";
99 END { print "$answer\n" }
100 ' <$tmp.xfs_db >$tmp.ans
102 echo "Checking blocks column same as df: $ans"
105 echo "Error: $SCRATCH_DEV: freesp mismatch: $ans"
106 echo "xfs_db output ..."
111 # check the 'pct' field from freesp command is good
113 BEGIN { $percent = 0; }
114 /free/ && next; # skip over free extent size number
115 if (/\s+(\d+\.\d+)$/) {
118 END { $percent += 0.5; print int($percent), "\n" } # round up
119 ' <$tmp.xfs_db >$tmp.ans
121 echo "Checking percent column yields 100: $ans"
124 echo "Error: $SCRATCH_DEV: pct mismatch: $ans (expected 100)"
125 echo "xfs_db output ..."