linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcos Paulo de Souza <marcos@mpdesouza.com>
To: dsterba@suse.com, linux-btrfs@vger.kernel.org
Cc: Marcos Paulo de Souza <mpdesouza@suse.com>
Subject: [RFC PATCH 2/8] btrfs: super: Introduce fs_context ops, init and free functions
Date: Wed, 12 Aug 2020 13:36:48 -0300	[thread overview]
Message-ID: <20200812163654.17080-3-marcos@mpdesouza.com> (raw)
In-Reply-To: <20200812163654.17080-1-marcos@mpdesouza.com>

From: Marcos Paulo de Souza <mpdesouza@suse.com>

Create a btrfs_fs_context struct that will be used as fs_private between
the fs context calls, holding options to be later assigned to fs_info,
since we don't have a proper btrfs_fs_info at the parse_args phase.

fs_context is still not being used since the init function isn't being
assigned in btrfs_fs_type.

Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
 fs/btrfs/ctree.h | 27 +++++++++++++++++++++++++++
 fs/btrfs/super.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 9c7e466f27a9..b7e3962a0941 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -28,6 +28,7 @@
 #include <linux/dynamic_debug.h>
 #include <linux/refcount.h>
 #include <linux/crc32c.h>
+#include "compression.h"
 #include "extent-io-tree.h"
 #include "extent_io.h"
 #include "extent_map.h"
@@ -35,6 +36,32 @@
 #include "block-rsv.h"
 #include "locking.h"
 
+struct btrfs_fs_context {
+	char **devices;
+	char *subvol_name;
+	u64 subvolid;
+
+	int nr_devices;
+	unsigned long mount_opt;
+	unsigned long mount_opt_explicity;
+	unsigned long pending_changes;
+	enum btrfs_compression_type	compress_type;
+	unsigned int			compress_level;
+
+	u64				max_inline;
+	u32				metadata_ratio;
+	u32				thread_pool_size;
+	u32				commit_interval;
+#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY
+	u32				check_integrity_print_mask;
+#endif
+
+	struct vfsmount *root_mnt;
+	bool root;
+	bool nospace_cache;
+	bool no_compress;
+};
+
 struct btrfs_trans_handle;
 struct btrfs_transaction;
 struct btrfs_pending_snapshot;
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 4e6654af90ea..fe19ffe962c6 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -2326,6 +2326,51 @@ static void btrfs_kill_super(struct super_block *sb)
 	btrfs_free_fs_info(fs_info);
 }
 
+static void btrfs_fc_free(struct fs_context *fc)
+{
+	struct btrfs_fs_context *ctx = fc->fs_private;
+	struct btrfs_fs_info *info = fc->s_fs_info;
+
+	if (info)
+		btrfs_free_fs_info(info);
+	if (ctx) {
+		mntput(ctx->root_mnt);
+		if (ctx->devices) {
+			int i;
+
+			for (i = 0; i < ctx->nr_devices; i++)
+				kfree(ctx->devices[i]);
+			kfree(ctx->devices);
+		}
+		kfree(ctx->subvol_name);
+		kfree(ctx);
+	}
+}
+
+static const struct fs_context_operations btrfs_context_ops = {
+	.free = btrfs_fc_free,
+};
+
+static int btrfs_init_fs_context(struct fs_context *fc)
+{
+	struct btrfs_fs_context *ctx;
+
+	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+	if (!ctx)
+		return -ENOMEM;
+
+	/* currently default options */
+	btrfs_set_opt(ctx->mount_opt, SPACE_CACHE);
+#ifdef CONFIG_BTRFS_FS_POSIX_ACL
+	fc->sb_flags |= SB_POSIXACL;
+#endif
+	ctx->commit_interval = BTRFS_DEFAULT_COMMIT_INTERVAL;
+
+	fc->fs_private = ctx;
+	fc->ops = &btrfs_context_ops;
+	return 0;
+}
+
 static struct file_system_type btrfs_fs_type = {
 	.owner		= THIS_MODULE,
 	.name		= "btrfs",
-- 
2.28.0


  parent reply	other threads:[~2020-08-12 17:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-12 16:36 [RFC PATCH 0/8] btrfs: convert to fscontext Marcos Paulo de Souza
2020-08-12 16:36 ` [RFC PATCH 1/8] btrfs: fs_context: Add initial fscontext parameters Marcos Paulo de Souza
2020-08-12 16:36 ` Marcos Paulo de Souza [this message]
2020-08-17 12:50   ` [RFC PATCH 2/8] btrfs: super: Introduce fs_context ops, init and free functions David Sterba
2020-08-12 16:36 ` [RFC PATCH 3/8] btrfs: super: Introduce btrfs_fc_parse_param and btrfs_apply_configuration Marcos Paulo de Souza
2020-08-17 13:09   ` David Sterba
2020-08-12 16:36 ` [RFC PATCH 4/8] btrfs: super: Introduce btrfs_fc_validate Marcos Paulo de Souza
2020-08-12 16:36 ` [RFC PATCH 5/8] btrfs: super: Introduce btrfs_dup_fc Marcos Paulo de Souza
2020-08-12 16:36 ` [RFC PATCH 6/8] btrfs: super: Introduce btrfs_mount_root_fc Marcos Paulo de Souza
2020-08-17 13:14   ` David Sterba
2020-08-12 16:36 ` [RFC PATCH 7/8] btrfs: Convert to fs_context Marcos Paulo de Souza
2020-08-17 13:26   ` David Sterba
2020-08-12 16:36 ` [RFC PATCH 8/8] btrfs: Remove leftover code from fscontext conversion Marcos Paulo de Souza
2020-08-17 12:44 ` [RFC PATCH 0/8] btrfs: convert to fscontext 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=20200812163654.17080-3-marcos@mpdesouza.com \
    --to=marcos@mpdesouza.com \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=mpdesouza@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).