2 # FS QA Test No. xfs/011
4 # Test the xfs log reservation mechanism for leaks. Run an fsstress workload to
5 # include a variety of fs operations, freeze the filesystem and verify that
6 # there are no oustanding reservations against the log.
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2014 Red Hat, Inc. All Rights Reserved.
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #-----------------------------------------------------------------------
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
33 status=1 # failure is the default!
35 # get standard environment, filters and checks
40 $KILLALL_PROG -9 fsstress 2>/dev/null
43 _scratch_unmount 2>/dev/null
46 trap "_cleanup; exit \$status" 0 1 2 3 15
48 # Use the information exported by XFS to sysfs to determine whether the log has
49 # active reservations after a filesystem freeze.
50 _check_scratch_log_state()
52 devname=`_short_dev $SCRATCH_DEV`
53 attrpath="/sys/fs/xfs/$devname/log"
55 # freeze the fs to ensure data is synced and the log is flushed. this
56 # means no outstanding transactions, and thus no outstanding log
57 # reservations, should exist
58 xfs_freeze -f $SCRATCH_MNT
60 # the log head is exported in basic blocks and the log grant heads in
61 # bytes. convert the log head to bytes for precise comparison
62 log_head_cycle=`awk -F : '{ print $1 }' $attrpath/log_head_lsn`
63 log_head_bytes=`awk -F : '{ print $2 }' $attrpath/log_head_lsn`
64 log_head_bytes=$((log_head_bytes * 512))
66 for attr in "reserve_grant_head" "write_grant_head"; do
67 cycle=`cat $attrpath/$attr | awk -F : '{ print $1 }'`
68 bytes=`cat $attrpath/$attr | awk -F : '{ print $2 }'`
70 if [ $cycle != $log_head_cycle ] ||
71 [ $bytes != $log_head_bytes ]
73 echo "$attr ($cycle:$bytes) does not match" \
74 "log_head_lsn ($log_head_cycle:$log_head_bytes)," \
75 "possible leak detected."
79 xfs_freeze -u $SCRATCH_MNT
82 # real QA test starts here
88 _require_xfs_sysfs $(_short_dev $TEST_DEV)/log
89 _require_command "$KILLALL_PROG" killall
93 echo "Silence is golden."
95 _scratch_mkfs_xfs >> $seqres.full 2>&1
98 _check_scratch_log_state
100 $FSSTRESS_PROG -d $SCRATCH_MNT/fsstress -n 9999999 -p 2 -S t \
101 >> $seqres.full 2>&1 &
104 while [ $iters -gt 0 ]; do
106 _check_scratch_log_state
110 $KILLALL_PROG $FSSTRESS_PROG