blob: ed44d074b55925fcc3a7513813b0b2554e9895c6 (
plain)
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
|
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2014 Red Hat, Inc. All Rights Reserved.
#
# FS QA Test No. xfs/011
#
# Test the xfs log reservation mechanism for leaks. Run an fsstress workload to
# include a variety of fs operations, freeze the filesystem and verify that
# there are no oustanding reservations against the log.
#
. ./common/preamble
_begin_fstest auto freeze log metadata quick
# Import common functions.
# Override the default cleanup function.
_cleanup()
{
# Make sure $SCRATCH_MNT is unfreezed
xfs_freeze -u $SCRATCH_MNT 2>/dev/null
$KILLALL_PROG -9 fsstress 2>/dev/null
wait
cd /
rm -f $tmp.*
}
# Use the information exported by XFS to sysfs to determine whether the log has
# active reservations after a filesystem freeze.
_check_scratch_log_state()
{
devname=`_short_dev $SCRATCH_DEV`
attrpath="/sys/fs/xfs/$devname/log"
# freeze the fs to ensure data is synced and the log is flushed. this
# means no outstanding transactions, and thus no outstanding log
# reservations, should exist
xfs_freeze -f $SCRATCH_MNT
# the log head is exported in basic blocks and the log grant heads in
# bytes. convert the log head to bytes for precise comparison
log_head_cycle=`awk -F : '{ print $1 }' $attrpath/log_head_lsn`
log_head_bytes=`awk -F : '{ print $2 }' $attrpath/log_head_lsn`
log_head_bytes=$((log_head_bytes * 512))
for attr in "reserve_grant_head" "write_grant_head"; do
cycle=`cat $attrpath/$attr | awk -F : '{ print $1 }'`
bytes=`cat $attrpath/$attr | awk -F : '{ print $2 }'`
if [ $cycle != $log_head_cycle ] ||
[ $bytes != $log_head_bytes ]
then
echo "$attr ($cycle:$bytes) does not match" \
"log_head_lsn ($log_head_cycle:$log_head_bytes)," \
"possible leak detected."
fi
done
xfs_freeze -u $SCRATCH_MNT
}
# real QA test starts here
_supported_fs xfs
_require_scratch
_require_freeze
_require_xfs_sysfs $(_short_dev $TEST_DEV)/log
_require_command "$KILLALL_PROG" killall
echo "Silence is golden."
_scratch_mkfs_xfs >> $seqres.full 2>&1
_scratch_mount
_check_scratch_log_state
$FSSTRESS_PROG -d $SCRATCH_MNT/fsstress -n 9999999 -p 2 -S t \
>> $seqres.full 2>&1 &
iters=5
while [ $iters -gt 0 ]; do
sleep 3
_check_scratch_log_state
iters=$((iters - 1))
done
$KILLALL_PROG $FSSTRESS_PROG
wait
_scratch_unmount
status=0
exit
|