public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Gabriel Niebler <gniebler@suse.com>
To: fstests@vger.kernel.org
Cc: linux-btrfs@vger.kernel.org, Gabriel Niebler <gniebler@suse.com>
Subject: [PATCH] fstests: fix btrfs/255 to fail on deadlock
Date: Wed, 16 Feb 2022 10:03:40 +0100	[thread overview]
Message-ID: <20220216090340.2241-1-gniebler@suse.com> (raw)

In its current implementation, the test btrfs/255 would hang forever
on any kernel w/o patch "btrfs: fix deadlock between quota disable
and qgroup rescan worker", rather than failing, as it should.
Fix this by introducing generous timeouts.

Signed-off-by: Gabriel Niebler <gniebler@suse.com>
---
 tests/btrfs/255 | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/tests/btrfs/255 b/tests/btrfs/255
index 7e70944a..4c779458 100755
--- a/tests/btrfs/255
+++ b/tests/btrfs/255
@@ -14,6 +14,7 @@ _begin_fstest auto qgroup balance
 
 # real QA test starts here
 _supported_fs btrfs
+_require_command "$TIMEOUT_PROG" timeout
 _require_scratch
 
 _scratch_mkfs >> $seqres.full 2>&1
@@ -37,15 +38,23 @@ done
 _btrfs_stress_balance $SCRATCH_MNT >> $seqres.full &
 balance_pid=$!
 echo $balance_pid >> $seqres.full
+timeout=$((30 * 60))
 for ((i = 0; i < 20; i++)); do
-	$BTRFS_UTIL_PROG quota enable $SCRATCH_MNT
-	$BTRFS_UTIL_PROG quota disable $SCRATCH_MNT
+	$TIMEOUT_PROG -s KILL ${timeout}s $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT
+	[ $? -eq 0 ] || _fail "quota enable timed out"
+	$TIMEOUT_PROG -s KILL ${timeout}s $BTRFS_UTIL_PROG quota disable $SCRATCH_MNT
+	[ $? -eq 0 ] || _fail "quota disable timed out"
 done
 kill $balance_pid &> /dev/null
-wait
+
 # wait for the balance operation to finish
+elapsed=0
 while ps aux | grep "balance start" | grep -qv grep; do
+	if [ $elapsed -gt $timeout ]; then
+		_fail "balance not finished after $timeout seconds"
+	fi
 	sleep 1
+	elapsed=$(( ++elapsed ))
 done
 
 echo "Silence is golden"
-- 
2.35.1


             reply	other threads:[~2022-02-16  9:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-16  9:03 Gabriel Niebler [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-02-16 10:05 [PATCH] fstests: fix btrfs/255 to fail on deadlock Gabriel Niebler
2022-02-20 17:07 ` Eryu Guan
2022-02-23 17:11   ` David Sterba
2022-03-20 15:33     ` Eryu Guan

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=20220216090340.2241-1-gniebler@suse.com \
    --to=gniebler@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox