All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: linux-btrfs@vger.kernel.org, fstests@vger.kernel.org
Cc: Nikolay Borisov <nborisov@suse.com>
Subject: [PATCH] btrfs: Add simple stress test when qgroup limits are reached
Date: Tue, 23 Feb 2021 17:50:42 +0200	[thread overview]
Message-ID: <20210223155042.1208106-1-nborisov@suse.com> (raw)

This test uncovered 2 deadlocks with qgroups when their limit was
reached.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 tests/btrfs/231     | 72 +++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/231.out |  2 ++
 tests/btrfs/group   |  1 +
 3 files changed, 75 insertions(+)
 create mode 100755 tests/btrfs/231
 create mode 100644 tests/btrfs/231.out

diff --git a/tests/btrfs/231 b/tests/btrfs/231
new file mode 100755
index 000000000000..d2026b55485f
--- /dev/null
+++ b/tests/btrfs/231
@@ -0,0 +1,72 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2021 SUSE Linux Products GmbH. All Rights Reserved.
+#
+# FS QA Test 231
+#
+# Test that performing io and exhausting qgroup limit won't deadlock. This
+# exercises issues fixed by the following kernel commits:
+#
+# btrfs: Unlock extents in btrfs_zero_range in case of errors
+# btrfs: Don't flush from btrfs_delayed_inode_reserve_metadata
+#
+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.*
+}
+
+writer() {
+	while [ 1 ]
+	do
+		args=`_scale_fsstress_args -p 20 -n 1000 $FSSTRESS_AVOID -d $SCRATCH_MNT/stressdir`
+		$FSSTRESS_PROG $args >/dev/null 2>&1
+	done
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+
+_supported_fs btrfs
+
+_require_scratch_size $((2 * 1024 * 1024))
+_scratch_mkfs > /dev/null 2>&1
+_scratch_mount
+
+_pwrite_byte 0xcd 0 900m $SCRATCH_MNT/file >> $seqres.full
+# Make sure the data reach disk so later qgroup scan can see it
+sync
+
+$BTRFS_UTIL_PROG quota enable $SCRATCH_MNT
+$BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT >> $seqres.full
+# set the limit to 1 g, leaving us just 100mb of slack space
+$BTRFS_UTIL_PROG qgroup limit 1G 0/5 $SCRATCH_MNT
+
+writer &
+writer_pid=$!
+
+# Give time for the background thread to generate some load
+sleep 30
+
+kill $writer_pid
+wait
+
+# success, all done
+echo "Silence is golden"
+status=0
+exit
diff --git a/tests/btrfs/231.out b/tests/btrfs/231.out
new file mode 100644
index 000000000000..a31b87a289bf
--- /dev/null
+++ b/tests/btrfs/231.out
@@ -0,0 +1,2 @@
+QA output created by 231
+Silence is golden
diff --git a/tests/btrfs/group b/tests/btrfs/group
index a7c6598326c4..db3d20fb5bb8 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -233,3 +233,4 @@
 228 auto quick volume
 229 auto quick send clone
 230 auto quick qgroup limit
+231 auto quick qgroup limit
-- 
2.17.1


                 reply	other threads:[~2021-02-23 15:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20210223155042.1208106-1-nborisov@suse.com \
    --to=nborisov@suse.com \
    --cc=fstests@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.