All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com>,
	Qu Wenruo <wqu@suse.com>
Subject: [PATCH v4 1/8] btrfs: unify the ro checking for mount options
Date: Fri, 16 Oct 2020 11:29:13 -0400	[thread overview]
Message-ID: <4e8692bf3f8e37824710e91a8a13f3ea20b3cdcc.1602862052.git.josef@toxicpanda.com> (raw)
In-Reply-To: <cover.1602862052.git.josef@toxicpanda.com>

We're going to be adding more options that require RDONLY, so add a
helper to do the check and error out if we don't have RDONLY set.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/super.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 8840a4fa81eb..f99e89ec46b2 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -458,6 +458,17 @@ static const match_table_t rescue_tokens = {
 	{Opt_err, NULL},
 };
 
+static bool check_ro_option(struct btrfs_fs_info *fs_info, unsigned long opt,
+			    const char *opt_name)
+{
+	if (fs_info->mount_opt & opt) {
+		btrfs_err(fs_info, "%s must be used with ro mount option",
+			  opt_name);
+		return true;
+	}
+	return false;
+}
+
 static int parse_rescue_options(struct btrfs_fs_info *info, const char *options)
 {
 	char *opts;
@@ -968,14 +979,12 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
 		}
 	}
 check:
-	/*
-	 * Extra check for current option against current flag
-	 */
-	if (btrfs_test_opt(info, NOLOGREPLAY) && !(new_flags & SB_RDONLY)) {
-		btrfs_err(info,
-			  "nologreplay must be used with ro mount option");
+	/* We're read-only, don't have to check. */
+	if (new_flags & SB_RDONLY)
+		goto out;
+
+	if (check_ro_option(info, BTRFS_MOUNT_NOLOGREPLAY, "nologreplay"))
 		ret = -EINVAL;
-	}
 out:
 	if (btrfs_fs_compat_ro(info, FREE_SPACE_TREE) &&
 	    !btrfs_test_opt(info, FREE_SPACE_TREE) &&
-- 
2.26.2


  reply	other threads:[~2020-10-16 15:29 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-16 15:29 [PATCH v4 0/8] New rescue mount options Josef Bacik
2020-10-16 15:29 ` Josef Bacik [this message]
2020-10-16 15:29 ` [PATCH v4 2/8] btrfs: push the NODATASUM check into btrfs_lookup_bio_sums Josef Bacik
2020-10-16 15:29 ` [PATCH v4 3/8] btrfs: add a supported_rescue_options file to sysfs Josef Bacik
2020-10-16 15:29 ` [PATCH v4 4/8] btrfs: add a helper to print out rescue= options Josef Bacik
2020-10-19  8:18   ` Johannes Thumshirn
2020-10-16 15:29 ` [PATCH v4 5/8] btrfs: show rescue=usebackuproot in /proc/mounts Josef Bacik
2020-10-19  8:18   ` Johannes Thumshirn
2020-10-20 16:03   ` David Sterba
2020-10-21 14:02     ` Josef Bacik
2020-10-16 15:29 ` [PATCH v4 6/8] btrfs: introduce rescue=ignorebadroots Josef Bacik
2020-10-16 15:29 ` [PATCH v4 7/8] btrfs: introduce rescue=ignoredatacsums Josef Bacik
2020-10-16 15:29 ` [PATCH v4 8/8] btrfs: introduce rescue=all Josef Bacik
2020-10-20 16:33   ` David Sterba

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=4e8692bf3f8e37824710e91a8a13f3ea20b3cdcc.1602862052.git.josef@toxicpanda.com \
    --to=josef@toxicpanda.com \
    --cc=johannes.thumshirn@wdc.com \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@suse.com \
    /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.