forked from amir73il/xfstests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
004
executable file
·144 lines (127 loc) · 3.9 KB
/
004
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#! /bin/bash
# FS QA Test No. 004
#
# exercise xfs_db bug #789674 and other freesp functionality
#
#-----------------------------------------------------------------------
# Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it would be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
#-----------------------------------------------------------------------
#
# creator
owner=nathans@sgi.com
seq=`basename $0`
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=0
_cleanup()
{
umount $SCRATCH_MNT
rm -f $tmp.*
exit $status
}
trap "_cleanup" 0 1 2 3 15
_populate_scratch()
{
echo "=== mkfs output ===" >>$seq.full
_scratch_mkfs_xfs | tee -a $seq.full | _filter_mkfs 2>$tmp.mkfs
. $tmp.mkfs
_scratch_mount
dd if=/dev/zero of=$SCRATCH_MNT/foo count=200 bs=4096 >/dev/null 2>&1 &
dd if=/dev/zero of=$SCRATCH_MNT/goo count=400 bs=4096 >/dev/null 2>&1 &
dd if=/dev/zero of=$SCRATCH_MNT/moo count=800 bs=4096 >/dev/null 2>&1 &
wait
umount $SCRATCH_MNT # flush everything
_scratch_mount # and then remount
}
# get standard environment, filters and checks
. ./common.rc
. ./common.filter
# real QA test starts here
_supported_fs xfs
_supported_os IRIX Linux
_need_to_be_root
_require_scratch
_require_nobigloopfs
rm -f $seq.full
_populate_scratch
[ "$HOSTOS" = "Linux" ] && DF_PROG="$DF_PROG -P --block-size=512"
eval `$DF_PROG $SCRATCH_MNT 2>&1 \
| tail -1 | $AWK_PROG '{ printf "blocks=%u used=%u avail=%u\n", $3, $4, $5 }'`
echo "df gave: blocks=$blocks used=$used avail=$avail" >>$seq.full
echo "blocksize from mkfs is '$dbsize'" >>$seq.full
xfs_db -r -c "freesp -s" $SCRATCH_DEV >$tmp.xfs_db
echo "xfs_db for $SCRATCH_DEV" >>$seq.full
cat $tmp.xfs_db >>$seq.full
eval `$XFS_IO_PROG -x -c resblks $SCRATCH_MNT 2>&1 \
| $AWK_PROG '/available/ { printf "resblks=%u\n", $5 }'`
echo "resblks gave: resblks=$resblks" >>$seq.full
# check the 'blocks' field from freesp command is OK
# since 2.6.18, df does not report the 4 blocks per AG that cannot
# be allocated, hence we check for that exact mismatch.
# since ~2.6.22, reserved blocks are used by default and df does
# not report them, hence check for an exact mismatch.
perl -ne '
BEGIN { $avail ='$avail' * 512;
$answer="(no xfs_db free blocks line?)" }
/free blocks (\d+)$/ || next;
$freesp = $1 * '$dbsize';
if ($freesp == $avail) {
$answer = "yes";
} else {
$avail = $avail + (('$agcount' + 1) * '$dbsize' * 4);
if ($freesp == $avail) {
$answer = "yes";
} else {
$avail = $avail + ('$resblks' * '$dbsize');
if ($freesp == $avail) {
$answer = "yes";
} else {
$answer = "no ($freesp != $avail)";
}
}
}
END { print "$answer\n" }
' <$tmp.xfs_db >$tmp.ans
ans="`cat $tmp.ans`"
echo "Checking blocks column same as df: $ans"
if [ "$ans" != yes ]
then
echo "Error: $SCRATCH_DEV: freesp mismatch: $ans"
echo "xfs_db output ..."
cat $tmp.xfs_db
status=1
fi
# check the 'pct' field from freesp command is good
perl -ne '
BEGIN { $percent = 0; }
/free/ && next; # skip over free extent size number
if (/\s+(\d+\.\d+)$/) {
$percent += $1;
}
END { $percent += 0.5; print int($percent), "\n" } # round up
' <$tmp.xfs_db >$tmp.ans
ans="`cat $tmp.ans`"
echo "Checking percent column yields 100: $ans"
if [ "$ans" != 100 ]
then
echo "Error: $SCRATCH_DEV: pct mismatch: $ans (expected 100)"
echo "xfs_db output ..."
cat $tmp.xfs_db
status=1
fi
exit