Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: fstests@vger.kernel.org, linux-btrfs@vger.kernel.org
Subject: [PATCH v2] fstests: btrfs: new test case for leaking BTRFS_FS_STATE_REMOUNTING flag
Date: Tue,  7 Jul 2026 21:10:30 +0930	[thread overview]
Message-ID: <20260707114030.120393-1-wqu@suse.com> (raw)

This is a regression test for the patch "btrfs: fix leaking
BTRFS_FS_STATE_REMOUNTING flag", where conflicting mount options can
cause btrfs leave BTRFS_FS_STATE_REMOUNTING set.

Such set BTRFS_FS_STATE_REMOUNTING will interrupt several features, and
the test case will use "btrfs qgroup rescan" to catch the
BTRFS_FS_STATE_REMOUNTING flag.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
Changelog:
v2:
- Use _require_btrfs_fs_feature to replace open-coded check
  Although the file content check still requires a open-coded check.
  I do not think there will be another user to check supported rescue
  options any time soon.
---
 tests/btrfs/352     | 50 +++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/352.out |  2 ++
 2 files changed, 52 insertions(+)
 create mode 100755 tests/btrfs/352
 create mode 100644 tests/btrfs/352.out

diff --git a/tests/btrfs/352 b/tests/btrfs/352
new file mode 100755
index 00000000..1d40c09c
--- /dev/null
+++ b/tests/btrfs/352
@@ -0,0 +1,50 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 SUSE S.A.  All Rights Reserved.
+#
+# FS QA Test 352
+#
+# A regression test to make sure failed remount won't leave
+# BTRFS_FS_STATE_REMOUNTING flag set, which can interrupt several features,
+# one of them is btrfs qgroup rescan.
+#
+. ./common/preamble
+_begin_fstest auto quick remount
+
+_fixed_by_kernel_commit XXXXXXXXXXXX \
+	"btrfs: fix leaking BTRFS_FS_STATE_REMOUNTING flag"
+
+_require_btrfs_fs_feature supported_rescue_options
+
+if ! grep -q "ignorebadroots" "/sys/fs/btrfs/features/supported_rescue_options"; then
+	_notrun "\"rescue=ignorebadroots\" mount option not supported"
+fi
+
+_require_btrfs_command quota rescan -w
+_require_scratch
+_scratch_mkfs >> $seqres.full
+_scratch_mount
+
+# Enable regular quota mode, and do a rescan.
+# Although the regression is affecting multiple features, qgroup rescan is the
+# easiest to verify.
+_btrfs quota enable $SCRATCH_MNT
+_btrfs quota rescan -w $SCRATCH_MNT
+
+# The following mount must fail, as the following rescue mount option requires
+# a full RO mount, thus it can not be set for the existing RW mount.
+_scratch_remount "rescue=ignorebadroots" >> $seqres.full 2>&1
+if [ $? -eq 0 ]; then
+	_fail "\"rescue=ignorebadroots\" is applied to RW mount unexpectedly"
+fi
+
+# For unpatched kernel, qgroup rescan will be interrupted immediately.
+_btrfs quota rescan -w $SCRATCH_MNT
+
+# We want capture the stderr output, so use $BTRFS_UTIL_PROG instead of _btrfs
+$BTRFS_UTIL_PROG qgroup show $SCRATCH_MNT >> $seqres.full
+
+echo "Silence is golden"
+
+# success, all done
+_exit 0
diff --git a/tests/btrfs/352.out b/tests/btrfs/352.out
new file mode 100644
index 00000000..11826ba5
--- /dev/null
+++ b/tests/btrfs/352.out
@@ -0,0 +1,2 @@
+QA output created by 352
+Silence is golden
-- 
2.51.2


             reply	other threads:[~2026-07-07 11:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07 11:40 Qu Wenruo [this message]
2026-07-07 21:52 ` [PATCH v2] fstests: btrfs: new test case for leaking BTRFS_FS_STATE_REMOUNTING flag Anand Suveer Jain

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=20260707114030.120393-1-wqu@suse.com \
    --to=wqu@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