diff mbox series

[RFC,4/8] btrfs: super: Introduce btrfs_fc_validate

Message ID 20200812163654.17080-5-marcos@mpdesouza.com (mailing list archive)
State New, archived
Headers show
Series btrfs: convert to fscontext | expand

Commit Message

Marcos Paulo de Souza Aug. 12, 2020, 4:36 p.m. UTC
From: Marcos Paulo de Souza <mpdesouza@suse.com>

This function will be used in later patches in get_tree and in
remount to ensure that we don't mount btrfs using nologreplay with a
writable fs.

Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
 fs/btrfs/super.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 3425a77ecd57..88221d1d8bae 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1080,6 +1080,17 @@  static struct btrfs_flag_map btrfs_opt_map[Opt_err] = {
 	[Opt_ref_verify] = INIT_MAP(REF_VERIFY),
 };
 
+static int btrfs_fc_validate(struct fs_context *fc)
+{
+	struct btrfs_fs_context *ctx = fc->fs_private;
+
+	 /* Check for current option against current flag */
+	if (btrfs_test_opt(ctx, NOLOGREPLAY) && !(fc->sb_flags & SB_RDONLY))
+		return invalf(fc, "nologreplay must be used with ro mount option");
+
+	return 0;
+}
+
 static int btrfs_fc_parse_param(struct fs_context *fc, struct fs_parameter *param)
 {
 	int opt;