2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014 Red Hat, Inc. All Rights Reserved.
5 # FS QA Test No. xfs/011
7 # Test the xfs log reservation mechanism for leaks. Run an fsstress workload to
8 # include a variety of fs operations, freeze the filesystem and verify that
9 # there are no oustanding reservations against the log.
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
17 status=1 # failure is the default!
19 # get standard environment, filters and checks
24 $KILLALL_PROG -9 fsstress 2>/dev/null
27 _scratch_unmount 2>/dev/null
30 trap "_cleanup; exit \$status" 0 1 2 3 15
32 # Use the information exported by XFS to sysfs to determine whether the log has
33 # active reservations after a filesystem freeze.
34 _check_scratch_log_state()
36 devname=`_short_dev $SCRATCH_DEV`
37 attrpath="/sys/fs/xfs/$devname/log"
39 # freeze the fs to ensure data is synced and the log is flushed. this
40 # means no outstanding transactions, and thus no outstanding log
41 # reservations, should exist
42 xfs_freeze -f $SCRATCH_MNT
44 # the log head is exported in basic blocks and the log grant heads in
45 # bytes. convert the log head to bytes for precise comparison
46 log_head_cycle=`awk -F : '{ print $1 }' $attrpath/log_head_lsn`
47 log_head_bytes=`awk -F : '{ print $2 }' $attrpath/log_head_lsn`
48 log_head_bytes=$((log_head_bytes * 512))
50 for attr in "reserve_grant_head" "write_grant_head"; do
51 cycle=`cat $attrpath/$attr | awk -F : '{ print $1 }'`
52 bytes=`cat $attrpath/$attr | awk -F : '{ print $2 }'`
54 if [ $cycle != $log_head_cycle ] ||
55 [ $bytes != $log_head_bytes ]
57 echo "$attr ($cycle:$bytes) does not match" \
58 "log_head_lsn ($log_head_cycle:$log_head_bytes)," \
59 "possible leak detected."
63 xfs_freeze -u $SCRATCH_MNT
66 # real QA test starts here
71 _require_xfs_sysfs $(_short_dev $TEST_DEV)/log
72 _require_command "$KILLALL_PROG" killall
76 echo "Silence is golden."
78 _scratch_mkfs_xfs >> $seqres.full 2>&1
81 _check_scratch_log_state
83 $FSSTRESS_PROG -d $SCRATCH_MNT/fsstress -n 9999999 -p 2 -S t \
84 >> $seqres.full 2>&1 &
87 while [ $iters -gt 0 ]; do
89 _check_scratch_log_state
93 $KILLALL_PROG $FSSTRESS_PROG