4 # exercise xfs_db bug #789674 and other freesp functionality
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #-----------------------------------------------------------------------
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
39 trap "_cleanup" 0 1 2 3 15
43 echo "=== mkfs output ===" >>$seqres.full
44 _scratch_mkfs_xfs | tee -a $seqres.full | _filter_mkfs 2>$tmp.mkfs
47 dd if=/dev/zero of=$SCRATCH_MNT/foo count=200 bs=4096 >/dev/null 2>&1 &
48 dd if=/dev/zero of=$SCRATCH_MNT/goo count=400 bs=4096 >/dev/null 2>&1 &
49 dd if=/dev/zero of=$SCRATCH_MNT/moo count=800 bs=4096 >/dev/null 2>&1 &
51 _scratch_unmount # flush everything
52 _scratch_mount # and then remount
55 # get standard environment, filters and checks
59 # real QA test starts here
64 _require_no_large_scratch_dev
70 eval `$DF_PROG -P --block-size=512 $SCRATCH_MNT 2>&1 \
71 | tail -1 | $AWK_PROG '{ printf "blocks=%u used=%u avail=%u\n", $3, $4, $5 }'`
72 echo "df gave: blocks=$blocks used=$used avail=$avail" >>$seqres.full
73 echo "blocksize from mkfs is '$dbsize'" >>$seqres.full
75 _scratch_xfs_db -r -c "freesp -s" >$tmp.xfs_db
76 echo "xfs_db for $SCRATCH_DEV" >>$seqres.full
77 cat $tmp.xfs_db >>$seqres.full
79 eval `$XFS_IO_PROG -x -c resblks $SCRATCH_MNT 2>&1 \
80 | $AWK_PROG '/available/ { printf "resblks=%u\n", $5 }'`
81 echo "resblks gave: resblks=$resblks" >>$seqres.full
83 # check the 'blocks' field from freesp command is OK
85 BEGIN { $avail ='$avail' * 512 + ('$resblks' * '$dbsize');
86 $answer="(no xfs_db free blocks line?)" }
87 /free blocks (\d+)$/ || next;
88 $freesp = $1 * '$dbsize';
89 if ($freesp >= $avail) {
92 $answer = "no ($freesp < $avail)";
94 END { print "$answer\n" }
95 ' <$tmp.xfs_db >$tmp.ans
97 echo "Checking blocks column same as df: $ans"
100 echo "Error: $SCRATCH_DEV: freesp mismatch: $ans"
101 echo "xfs_db output ..."
106 # check the 'pct' field from freesp command is good
108 BEGIN { $percent = 0; }
109 /free/ && next; # skip over free extent size number
110 if (/\s+(\d+\.\d+)$/) {
113 END { $percent += 0.5; print int($percent), "\n" } # round up
114 ' <$tmp.xfs_db >$tmp.ans
116 echo "Checking percent column yields 100: $ans"
119 echo "Error: $SCRATCH_DEV: pct mismatch: $ans (expected 100)"
120 echo "xfs_db output ..."