fstests.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Monakhov <dmonakhov@openvz.org>
To: fstests@vger.kernel.org
Cc: jack@suse.cz, Dmitry Monakhov <dmtrmonakhov@yandex-team.ru>
Subject: [PATCH 2/2] add generic/586 quota stress test
Date: Thu, 31 Oct 2019 10:36:39 +0000	[thread overview]
Message-ID: <20191031103639.3786-2-dmonakhov@openvz.org> (raw)
In-Reply-To: <20191031103639.3786-1-dmonakhov@openvz.org>

From: Dmitry Monakhov <dmtrmonakhov@yandex-team.ru>

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!"

Signed-off-by: Dmitry Monakhov <dmtrmonakhov@yandex-team.ru>
---
 tests/generic/586     | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/586.out |  2 ++
 tests/generic/group   |  1 +
 3 files changed, 90 insertions(+)
 create mode 100755 tests/generic/586
 create mode 100755 tests/generic/586.out

diff --git a/tests/generic/586 b/tests/generic/586
new file mode 100755
index 0000000..279eb55
--- /dev/null
+++ b/tests/generic/586
@@ -0,0 +1,87 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019 YANDEX LLC.  All Rights Reserved.
+#
+# FS QA Test 586
+#
+# Stress quotasync while other tasks dirty quotas in parallel.
+# Run fchown(2) in a loop is the fastest way to produce dirty quotas
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/quota
+
+
+
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_quota
+_require_scratch
+_require_check_dmesg
+
+nr_proc=$((32 * LOAD_FACTOR))
+runtime=$((60 * TIME_FACTOR))
+
+rm -f $seqres.full
+_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mount "-o quota,user"
+chmod 777 $SCRATCH_MNT
+quotacheck -u $SCRATCH_MNT 2>/dev/null
+quotaon -v -u $SCRATCH_MNT >> $seqres.full 2>&1
+
+# Preparation step: Create all files with uid in range
+# to cache quota in kernel memory
+#mkdir -p $SCRATCH_MNT/q
+#$here/src/chowner $SCRATCH_MNT/q -b 2000 -e 2010 -P
+
+for ((i=0; i < nr_proc; i++))
+do
+    # Spread files to isolated dirs to minimize locking contention
+    mkdir -p $SCRATCH_MNT/chowner/$i
+    # Performs fchown in small uid range [2019,2042] in order stress
+    # quota code
+    $here/src/chowner $SCRATCH_MNT/chowner/$i/test -b 2019 -e 2042 \
+		      -t $((runtime)) &
+    pids="$pids $!"
+done
+
+start=$(date +%s)
+deadline=$((start + runtime))
+i=0
+while true
+do
+    quotasync -u $SCRATCH_MNT
+    now=$(date +%s)
+    [ $now -le $deadline ] || break
+    i=$((i+1))
+done
+echo "Done after $i loops" >> $seqres.full
+
+kill -TERM $pids 2> /dev/null
+wait $pids
+
+# Check for error message that happed due to quota inconsistency
+# Example messages:
+#  "Quota error (device vdb): dqput: Can't write quota structure (error -5). Quota may get out of sync!"
+_dmesg_since_test_start | egrep -e 'Quota error '
+echo "Silence is golden"
+# success, all done
+status=0
+exit
diff --git a/tests/generic/586.out b/tests/generic/586.out
new file mode 100755
index 0000000..3d36442
--- /dev/null
+++ b/tests/generic/586.out
@@ -0,0 +1,2 @@
+QA output created by 586
+Silence is golden
diff --git a/tests/generic/group b/tests/generic/group
index 703a1b4..76d7d4f 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -588,3 +588,4 @@
 583 auto quick encrypt
 584 auto quick encrypt
 585 auto quota rw stress
+586 auto quota rw stress
-- 
2.7.4


  reply	other threads:[~2019-10-31 10:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-31 10:36 [PATCH 1/2] add generic/585 Dmitry Monakhov
2019-10-31 10:36 ` Dmitry Monakhov [this message]
2019-11-10 16:33 ` Eryu Guan
2019-11-11  7:20   ` Dmitry Monakhov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191031103639.3786-2-dmonakhov@openvz.org \
    --to=dmonakhov@openvz.org \
    --cc=dmtrmonakhov@yandex-team.ru \
    --cc=fstests@vger.kernel.org \
    --cc=jack@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).