Skip to content

Commit 440a80d

Browse files
author
Dmitry Monakhov
committed
add generic/586 quota stress test
Regression test for mark_dquot_dirty() vs dqput() race Stress test quota quota code via fchown(2) loop. In fact fchown is the best way to produce a lot of short lived dirty dquot objects. This test known to t produce non fatal dmesg error on kernel prior to v5.4 Example: "Quota error (device vdb): dqput: Can't write quota structure (error -5). Quota may get out of sync!"
1 parent b10ad23 commit 440a80d

File tree

3 files changed

+90
-0
lines changed

3 files changed

+90
-0
lines changed

tests/generic/586

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#! /bin/bash
2+
# SPDX-License-Identifier: GPL-2.0
3+
# Copyright (c) 2019 YANDEX LLC. All Rights Reserved.
4+
#
5+
# FS QA Test 586
6+
#
7+
# Stress quotasync while other tasks dirty quotas in parallel.
8+
# Run fchown(2) in a loop is the fastest way to produce dirty quotas
9+
#
10+
seq=`basename $0`
11+
seqres=$RESULT_DIR/$seq
12+
echo "QA output created by $seq"
13+
14+
here=`pwd`
15+
tmp=/tmp/$$
16+
status=1 # failure is the default!
17+
trap "_cleanup; exit \$status" 0 1 2 3 15
18+
19+
_cleanup()
20+
{
21+
cd /
22+
rm -f $tmp.*
23+
}
24+
# get standard environment, filters and checks
25+
. ./common/rc
26+
. ./common/filter
27+
. ./common/quota
28+
29+
30+
31+
32+
# real QA test starts here
33+
_supported_fs generic
34+
_supported_os Linux
35+
_require_quota
36+
_require_scratch
37+
_require_check_dmesg
38+
39+
nr_proc=$((32 * LOAD_FACTOR))
40+
runtime=$((60 * TIME_FACTOR))
41+
42+
rm -f $seqres.full
43+
_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1
44+
_scratch_mount "-o quota,user"
45+
chmod 777 $SCRATCH_MNT
46+
quotacheck -u $SCRATCH_MNT 2>/dev/null
47+
quotaon -v -u $SCRATCH_MNT >> $seqres.full 2>&1
48+
49+
# Preparation step: Create all files with uid in range
50+
# to cache quota in kernel memory
51+
#mkdir -p $SCRATCH_MNT/q
52+
#$here/src/chowner $SCRATCH_MNT/q -b 2000 -e 2010 -P
53+
54+
for ((i=0; i < nr_proc; i++))
55+
do
56+
# Spread files to isolated dirs to minimize locking contention
57+
mkdir -p $SCRATCH_MNT/chowner/$i
58+
# Performs fchown in small uid range [2019,2042] in order stress
59+
# quota code
60+
$here/src/chowner $SCRATCH_MNT/chowner/$i/test -b 2019 -e 2042 \
61+
-t $((runtime)) &
62+
pids="$pids $!"
63+
done
64+
65+
start=$(date +%s)
66+
deadline=$((start + runtime))
67+
i=0
68+
while true
69+
do
70+
quotasync -u $SCRATCH_MNT
71+
now=$(date +%s)
72+
[ $now -le $deadline ] || break
73+
i=$((i+1))
74+
done
75+
echo "Done after $i loops" >> $seqres.full
76+
77+
kill -TERM $pids 2> /dev/null
78+
wait $pids
79+
80+
# Check for error message that happed due to quota inconsistency
81+
# Example messages:
82+
# "Quota error (device vdb): dqput: Can't write quota structure (error -5). Quota may get out of sync!"
83+
_dmesg_since_test_start | egrep -e 'Quota error '
84+
echo "Silence is golden"
85+
# success, all done
86+
status=0
87+
exit

tests/generic/586.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
QA output created by 586
2+
Silence is golden

tests/generic/group

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,3 +588,4 @@
588588
583 auto quick encrypt
589589
584 auto quick encrypt
590590
585 auto quota rw stress
591+
586 auto quota rw stress

0 commit comments

Comments
 (0)