2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
7 # exercise xfs_db bug #789674 and other freesp functionality
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
23 trap "_cleanup" 0 1 2 3 15
27 echo "=== mkfs output ===" >>$seqres.full
28 _scratch_mkfs_xfs | tee -a $seqres.full | _filter_mkfs 2>$tmp.mkfs
31 dd if=/dev/zero of=$SCRATCH_MNT/foo count=200 bs=4096 >/dev/null 2>&1 &
32 dd if=/dev/zero of=$SCRATCH_MNT/goo count=400 bs=4096 >/dev/null 2>&1 &
33 dd if=/dev/zero of=$SCRATCH_MNT/moo count=800 bs=4096 >/dev/null 2>&1 &
35 _scratch_unmount # flush everything
36 _scratch_mount # and then remount
39 # get standard environment, filters and checks
43 # real QA test starts here
47 _require_no_large_scratch_dev
53 eval `$DF_PROG -P --block-size=512 $SCRATCH_MNT 2>&1 \
54 | tail -1 | $AWK_PROG '{ printf "blocks=%u used=%u avail=%u\n", $3, $4, $5 }'`
55 echo "df gave: blocks=$blocks used=$used avail=$avail" >>$seqres.full
56 echo "blocksize from mkfs is '$dbsize'" >>$seqres.full
58 _scratch_xfs_db -r -c "freesp -s" >$tmp.xfs_db
59 echo "xfs_db for $SCRATCH_DEV" >>$seqres.full
60 cat $tmp.xfs_db >>$seqres.full
62 eval `$XFS_IO_PROG -x -c resblks $SCRATCH_MNT 2>&1 \
63 | $AWK_PROG '/available/ { printf "resblks=%u\n", $5 }'`
64 echo "resblks gave: resblks=$resblks" >>$seqres.full
66 # check the 'blocks' field from freesp command is OK
68 BEGIN { $avail ='$avail' * 512 + ('$resblks' * '$dbsize');
69 $answer="(no xfs_db free blocks line?)" }
70 /free blocks (\d+)$/ || next;
71 $freesp = $1 * '$dbsize';
72 if ($freesp >= $avail) {
75 $answer = "no ($freesp < $avail)";
77 END { print "$answer\n" }
78 ' <$tmp.xfs_db >$tmp.ans
80 echo "Checking blocks column same as df: $ans"
83 echo "Error: $SCRATCH_DEV: freesp mismatch: $ans"
84 echo "xfs_db output ..."
89 # check the 'pct' field from freesp command is good
91 BEGIN { $percent = 0; }
92 /free/ && next; # skip over free extent size number
93 if (/\s+(\d+\.\d+)$/) {
96 END { $percent += 0.5; print int($percent), "\n" } # round up
97 ' <$tmp.xfs_db >$tmp.ans
99 echo "Checking percent column yields 100: $ans"
102 echo "Error: $SCRATCH_DEV: pct mismatch: $ans (expected 100)"
103 echo "xfs_db output ..."