5 # exercise xfs_db bug #789674 and other freesp functionality
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
10 # This program is free software; you can redistribute it and/or modify it
11 # under the terms of version 2 of the GNU General Public License as
12 # published by the Free Software Foundation.
14 # This program is distributed in the hope that it would be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 # Further, this software is distributed without any warranty that it is
19 # free of the rightful claim of any third person regarding infringement
20 # or the like. Any license provided herein, whether implied or
21 # otherwise, applies only to this software file. Patent licenses, if
22 # any, provided herein do not apply to combinations of this program with
23 # other software, or any other product whatsoever.
25 # You should have received a copy of the GNU General Public License along
26 # with this program; if not, write the Free Software Foundation, Inc., 59
27 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
29 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
30 # Mountain View, CA 94043, or:
34 # For further information regarding this notice, see:
36 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
37 #-----------------------------------------------------------------------
43 echo "QA output created by $seq"
55 trap "_cleanup" 0 1 2 3 15
59 mkfs_xfs $SCRATCH_DEV | _filter_mkfs 2>$tmp.mkfs
61 mount -t xfs $SCRATCH_DEV $SCRATCH_MNT
62 dd if=/dev/zero of=$SCRATCH_MNT/foo count=200 bs=4096 >/dev/null 2>&1 &
63 dd if=/dev/zero of=$SCRATCH_MNT/goo count=400 bs=4096 >/dev/null 2>&1 &
64 dd if=/dev/zero of=$SCRATCH_MNT/moo count=800 bs=4096 >/dev/null 2>&1 &
66 umount $SCRATCH_MNT # flush everything
67 mount -t xfs $SCRATCH_DEV $SCRATCH_MNT # and then remount
71 # get standard environment, filters and checks
78 # real QA test starts here
83 eval `df -P -T --block-size=512 $SCRATCH_MNT 2>&1 \
84 | $AWK_PROG 'END { printf "blocks=%u used=%u avail=%u\n", $3, $4, $5 }'`
85 echo "df gave: blocks=$blocks used=$used avail=$avail" >>$seq.full
86 echo "blocksize from mkfs is '$dbsize'" >>$seq.full
88 xfs_db -r -c "freesp -s" $SCRATCH_DEV >$tmp.xfs_db
89 echo "xfs_db for $SCRATCH_DEV" >>$seq.full
90 cat $tmp.xfs_db >>$seq.full
92 # check the 'blocks' field from freesp command is OK
94 BEGIN { $avail ='$avail' * 512;
95 $answer="(no xfs_db free blocks line?)" }
96 /free blocks (\d+)$/ || next;
97 $freesp = $1 * '$dbsize';
98 if ($freesp == $avail) { $answer = "yes"; }
99 else { $answer = "no ($freesp != $avail)"; }
100 END { print "$answer\n" }
101 ' <$tmp.xfs_db >$tmp.ans
103 echo "Checking blocks column same as df: $ans"
106 echo "Error: $SCRATCH_DEV: freesp mismatch: $ans"
107 echo "xfs_db output ..."
112 # check the 'pct' field from freesp command is good
114 BEGIN { $percent = 0; }
115 /free/ && next; # skip over free extent size number
116 if (/\s+(\d+\.\d+)$/) {
119 END { $percent += 0.5; print int($percent), "\n" } # round up
120 ' <$tmp.xfs_db >$tmp.ans
122 echo "Checking percent column yields 100: $ans"
125 echo "Error: $SCRATCH_DEV: pct mismatch: $ans (expected 100)"
126 echo "xfs_db output ..."