linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: viro@zeniv.linux.org.uk
Cc: Mike Marshall <hubcap@omnibond.com>,
	Martin Brandenburg <martin@omnibond.com>,
	devel@lists.orangefs.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, dhowells@redhat.com
Subject: [RFC PATCH 67/68] vfs: Convert orangefs to use the new mount API
Date: Wed, 27 Mar 2019 23:49:04 +0000	[thread overview]
Message-ID: <155373054475.7602.4918098489201730987.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <155372999953.7602.13784796495137723805.stgit@warthog.procyon.org.uk>

Convert the orangefs filesystem to the new internal mount API as the old
one will be obsoleted and removed.  This allows greater flexibility in
communication of mount parameters between userspace, the VFS and the
filesystem.

See Documentation/filesystems/mount_api.txt for more information.
cc: Mike Marshall <hubcap@omnibond.com>
cc: Martin Brandenburg <martin@omnibond.com>
cc: devel@lists.orangefs.org
---

 fs/orangefs/orangefs-kernel.h |    8 +-
 fs/orangefs/orangefs-mod.c    |    3 -
 fs/orangefs/super.c           |  186 ++++++++++++++++++++++-------------------
 3 files changed, 105 insertions(+), 92 deletions(-)

diff --git a/fs/orangefs/orangefs-kernel.h b/fs/orangefs/orangefs-kernel.h
index 17b24ad6b264..5b8379a6c815 100644
--- a/fs/orangefs/orangefs-kernel.h
+++ b/fs/orangefs/orangefs-kernel.h
@@ -32,6 +32,8 @@
 #include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/fs.h>
+#include <linux/fs_context.h>
+#include <linux/fs_parser.h>
 #include <linux/vmalloc.h>
 
 #include <linux/aio.h>
@@ -314,11 +316,9 @@ void purge_waiting_ops(void);
  * defined in super.c
  */
 extern uint64_t orangefs_features;
+extern const struct fs_parameter_description orangefs_fs_parameters;
 
-struct dentry *orangefs_mount(struct file_system_type *fst,
-			   int flags,
-			   const char *devname,
-			   void *data);
+int orangefs_init_fs_context(struct fs_context *fc);
 
 void orangefs_kill_sb(struct super_block *sb);
 int orangefs_remount(struct orangefs_sb_info_s *);
diff --git a/fs/orangefs/orangefs-mod.c b/fs/orangefs/orangefs-mod.c
index 85ef87245a87..f65cf0dd0f7e 100644
--- a/fs/orangefs/orangefs-mod.c
+++ b/fs/orangefs/orangefs-mod.c
@@ -44,7 +44,8 @@ MODULE_PARM_DESC(hash_table_size,
 
 static struct file_system_type orangefs_fs_type = {
 	.name = "pvfs2",
-	.mount = orangefs_mount,
+	.init_fs_context	= orangefs_init_fs_context,
+	.parameters		= &orangefs_fs_parameters,
 	.kill_sb = orangefs_kill_sb,
 	.owner = THIS_MODULE,
 };
diff --git a/fs/orangefs/super.c b/fs/orangefs/super.c
index dfaee90d30bd..f69d568818ce 100644
--- a/fs/orangefs/super.c
+++ b/fs/orangefs/super.c
@@ -9,8 +9,6 @@
 #include "orangefs-kernel.h"
 #include "orangefs-bufmap.h"
 
-#include <linux/parser.h>
-
 /* a cache for orangefs-inode objects (i.e. orangefs inode private data) */
 static struct kmem_cache *orangefs_inode_cache;
 
@@ -19,19 +17,22 @@ LIST_HEAD(orangefs_superblocks);
 
 DEFINE_SPINLOCK(orangefs_superblocks_lock);
 
-enum {
-	Opt_intr,
+enum orangefs_param {
 	Opt_acl,
+	Opt_intr,
 	Opt_local_lock,
+};
 
-	Opt_err
+static const struct fs_parameter_spec orangefs_param_specs[] = {
+	fsparam_flag	("acl",			Opt_acl),
+	fsparam_flag	("intr",		Opt_intr),
+	fsparam_flag	("local_lock",		Opt_local_lock),
+	{}
 };
 
-static const match_table_t tokens = {
-	{ Opt_acl,		"acl" },
-	{ Opt_intr,		"intr" },
-	{ Opt_local_lock,	"local_lock" },
-	{ Opt_err,	NULL }
+const struct fs_parameter_description orangefs_fs_parameters = {
+	.name		= "orangefs",
+	.specs		= orangefs_param_specs,
 };
 
 uint64_t orangefs_features;
@@ -49,48 +50,29 @@ static int orangefs_show_options(struct seq_file *m, struct dentry *root)
 	return 0;
 }
 
-static int parse_mount_options(struct super_block *sb, char *options,
-		int silent)
+static int orangefs_parse_param(struct fs_context *fc, struct fs_parameter *param)
 {
-	struct orangefs_sb_info_s *orangefs_sb = ORANGEFS_SB(sb);
-	substring_t args[MAX_OPT_ARGS];
-	char *p;
-
-	/*
-	 * Force any potential flags that might be set from the mount
-	 * to zero, ie, initialize to unset.
-	 */
-	sb->s_flags &= ~SB_POSIXACL;
-	orangefs_sb->flags &= ~ORANGEFS_OPT_INTR;
-	orangefs_sb->flags &= ~ORANGEFS_OPT_LOCAL_LOCK;
-
-	while ((p = strsep(&options, ",")) != NULL) {
-		int token;
-
-		if (!*p)
-			continue;
-
-		token = match_token(p, tokens, args);
-		switch (token) {
-		case Opt_acl:
-			sb->s_flags |= SB_POSIXACL;
-			break;
-		case Opt_intr:
-			orangefs_sb->flags |= ORANGEFS_OPT_INTR;
-			break;
-		case Opt_local_lock:
-			orangefs_sb->flags |= ORANGEFS_OPT_LOCAL_LOCK;
-			break;
-		default:
-			goto fail;
-		}
+	struct orangefs_sb_info_s *orangefs_sb = fc->s_fs_info;
+	struct fs_parse_result result;
+	int opt;
+
+	opt = fs_parse(fc, &orangefs_fs_parameters, param, &result);
+	if (opt < 0)
+		return opt;
+
+	switch (opt) {
+	case Opt_acl:
+		fc->sb_flags |= SB_POSIXACL;
+		break;
+	case Opt_intr:
+		orangefs_sb->flags |= ORANGEFS_OPT_INTR;
+		break;
+	case Opt_local_lock:
+		orangefs_sb->flags |= ORANGEFS_OPT_LOCAL_LOCK;
+		break;
 	}
 
 	return 0;
-fail:
-	if (!silent)
-		gossip_err("Error: mount option [%s] is not supported.\n", p);
-	return -EINVAL;
 }
 
 static void orangefs_inode_cache_ctor(void *req)
@@ -207,10 +189,20 @@ static int orangefs_statfs(struct dentry *dentry, struct kstatfs *buf)
  * Remount as initiated by VFS layer.  We just need to reparse the mount
  * options, no need to signal pvfs2-client-core about it.
  */
-static int orangefs_remount_fs(struct super_block *sb, int *flags, char *data)
+static int orangefs_reconfigure(struct fs_context *fc)
 {
-	gossip_debug(GOSSIP_SUPER_DEBUG, "orangefs_remount_fs: called\n");
-	return parse_mount_options(sb, data, 1);
+	struct super_block *sb = fc->root->d_sb;
+	struct orangefs_sb_info_s *orangefs_sb = ORANGEFS_SB(sb);
+	struct orangefs_sb_info_s *revised = fc->s_fs_info;
+	unsigned int flags;
+
+	flags = orangefs_sb->flags;
+	flags &= ~(ORANGEFS_OPT_INTR | ORANGEFS_OPT_LOCAL_LOCK);
+	flags |= revised->flags;
+	WRITE_ONCE(orangefs_sb->flags, flags);
+
+	gossip_debug(GOSSIP_SUPER_DEBUG, "orangefs_reconfigure: called\n");
+	return 0;
 }
 
 /*
@@ -302,7 +294,6 @@ static const struct super_operations orangefs_s_ops = {
 	.destroy_inode = orangefs_destroy_inode,
 	.drop_inode = generic_delete_inode,
 	.statfs = orangefs_statfs,
-	.remount_fs = orangefs_remount_fs,
 	.show_options = orangefs_show_options,
 };
 
@@ -394,10 +385,9 @@ static int orangefs_unmount(int id, __s32 fs_id, const char *devname)
 }
 
 static int orangefs_fill_sb(struct super_block *sb,
-		struct orangefs_fs_mount_response *fs_mount,
-		void *data, int silent)
+			    struct fs_context *fc,
+			    struct orangefs_fs_mount_response *fs_mount)
 {
-	int ret = -EINVAL;
 	struct inode *root = NULL;
 	struct dentry *root_dentry = NULL;
 	struct orangefs_object_kref root_object;
@@ -412,12 +402,6 @@ static int orangefs_fill_sb(struct super_block *sb,
 	ORANGEFS_SB(sb)->fs_id = fs_mount->fs_id;
 	ORANGEFS_SB(sb)->id = fs_mount->id;
 
-	if (data) {
-		ret = parse_mount_options(sb, data, silent);
-		if (ret)
-			return ret;
-	}
-
 	/* Hang the xattr handlers off the superblock */
 	sb->s_xattr = orangefs_xattr_handlers;
 	sb->s_magic = ORANGEFS_SUPER_MAGIC;
@@ -454,31 +438,25 @@ static int orangefs_fill_sb(struct super_block *sb,
 	return 0;
 }
 
-struct dentry *orangefs_mount(struct file_system_type *fst,
-			   int flags,
-			   const char *devname,
-			   void *data)
+static int orangefs_get_tree(struct fs_context *fc)
 {
 	int ret = -EINVAL;
 	struct super_block *sb = ERR_PTR(-EINVAL);
 	struct orangefs_kernel_op_s *new_op;
-	struct dentry *d = ERR_PTR(-EINVAL);
+
+	if (!fc->source)
+		return invalf(fc, "Device name not specified.\n");
 
 	gossip_debug(GOSSIP_SUPER_DEBUG,
 		     "orangefs_mount: called with devname %s\n",
-		     devname);
-
-	if (!devname) {
-		gossip_err("ERROR: device name not specified.\n");
-		return ERR_PTR(-EINVAL);
-	}
+		     fc->source);
 
 	new_op = op_alloc(ORANGEFS_VFS_OP_FS_MOUNT);
 	if (!new_op)
-		return ERR_PTR(-ENOMEM);
+		return -ENOMEM;
 
 	strncpy(new_op->upcall.req.fs_mount.orangefs_config_server,
-		devname,
+		fc->source,
 		ORANGEFS_MAX_SERVER_ADDR_LEN - 1);
 
 	gossip_debug(GOSSIP_SUPER_DEBUG,
@@ -497,30 +475,27 @@ struct dentry *orangefs_mount(struct file_system_type *fst,
 		goto free_op;
 	}
 
-	sb = sget(fst, NULL, set_anon_super, flags, NULL);
+	sb = sget_fc(fc, NULL, set_anon_super_fc);
 
 	if (IS_ERR(sb)) {
-		d = ERR_CAST(sb);
+		ret = PTR_ERR(sb);
 		orangefs_unmount(new_op->downcall.resp.fs_mount.id,
-		    new_op->downcall.resp.fs_mount.fs_id, devname);
+				 new_op->downcall.resp.fs_mount.fs_id,
+				 fc->source);
 		goto free_op;
 	}
 
-	ret = orangefs_fill_sb(sb,
-	      &new_op->downcall.resp.fs_mount, data,
-	      flags & SB_SILENT ? 1 : 0);
+	ret = orangefs_fill_sb(sb, fc, &new_op->downcall.resp.fs_mount);
 
-	if (ret) {
-		d = ERR_PTR(ret);
+	if (ret)
 		goto free_sb_and_op;
-	}
 
 	/*
 	 * on successful mount, store the devname and data
 	 * used
 	 */
 	strncpy(ORANGEFS_SB(sb)->devname,
-		devname,
+		fc->source,
 		ORANGEFS_MAX_SERVER_ADDR_LEN - 1);
 
 	/* mount_pending must be cleared */
@@ -544,7 +519,7 @@ struct dentry *orangefs_mount(struct file_system_type *fst,
 	if (orangefs_userspace_version >= 20906) {
 		new_op = op_alloc(ORANGEFS_VFS_OP_FEATURES);
 		if (!new_op)
-			return ERR_PTR(-ENOMEM);
+			return -ENOMEM;
 		new_op->upcall.req.features.features = 0;
 		ret = service_operation(new_op, "orangefs_features", 0);
 		orangefs_features = new_op->downcall.resp.features.features;
@@ -553,7 +528,8 @@ struct dentry *orangefs_mount(struct file_system_type *fst,
 		orangefs_features = 0;
 	}
 
-	return dget(sb->s_root);
+	fc->root = dget(sb->s_root);
+	return 0;
 
 free_sb_and_op:
 	/* Will call orangefs_kill_sb with sb not in list. */
@@ -569,7 +545,43 @@ struct dentry *orangefs_mount(struct file_system_type *fst,
 
 	op_release(new_op);
 
-	return d;
+	return ret;
+}
+
+static void orangefs_free_fc(struct fs_context *fc)
+{
+	kfree(fc->s_fs_info);
+}
+
+static const struct fs_context_operations orangefs_context_ops = {
+	.free		= orangefs_free_fc,
+	.parse_param	= orangefs_parse_param,
+	.get_tree	= orangefs_get_tree,
+	.reconfigure	= orangefs_reconfigure,
+};
+
+/*
+ * Set up the filesystem mount context.
+ */
+int orangefs_init_fs_context(struct fs_context *fc)
+{
+	struct orangefs_sb_info_s *osi;
+
+	osi = kzalloc(sizeof(struct orangefs_sb_info_s), GFP_KERNEL);
+	if (!osi)
+		return -ENOMEM;
+
+	/*
+	 * Force any potential flags that might be set from the mount
+	 * to zero, ie, initialize to unset.
+	 */
+	fc->sb_flags_mask |= SB_POSIXACL;
+	osi->flags &= ~ORANGEFS_OPT_INTR;
+	osi->flags &= ~ORANGEFS_OPT_LOCAL_LOCK;
+
+	fc->s_fs_info = osi;
+	fc->ops = &orangefs_context_ops;
+	return 0;
 }
 
 void orangefs_kill_sb(struct super_block *sb)


  parent reply	other threads:[~2019-03-27 23:49 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <155372999953.7602.13784796495137723805.stgit@warthog.procyon.org.uk>
2019-03-27 23:40 ` [RFC PATCH 01/68] kbuild: skip sub-make for in-tree build with GNU Make 4.x David Howells
2019-03-28  0:53   ` Masahiro Yamada
2019-03-30 12:11     ` Masahiro Yamada
2019-04-10  9:54   ` David Howells
2019-03-27 23:40 ` [RFC PATCH 02/68] vfs: Update mount API docs David Howells
2019-03-27 23:40 ` [RFC PATCH 03/68] vfs: Fix refcounting of filenames in fs_parser David Howells
2019-03-27 23:41 ` [RFC PATCH 04/68] vfs: Provide sb->s_iflags settings in fs_context struct David Howells
2019-03-27 23:41 ` [RFC PATCH 05/68] vfs: Provide a mount_pseudo-replacement for the new mount API David Howells
2019-03-27 23:41 ` [RFC PATCH 06/68] vfs: Convert aio to use " David Howells
2019-03-27 23:41 ` [RFC PATCH 07/68] vfs: Convert anon_inodes " David Howells
2019-03-27 23:41 ` [RFC PATCH 08/68] vfs: Convert bdev " David Howells
2019-03-27 23:41 ` [RFC PATCH 09/68] vfs: Convert nsfs " David Howells
2019-03-27 23:41 ` [RFC PATCH 10/68] vfs: Convert pipe " David Howells
2019-03-27 23:41 ` [RFC PATCH 11/68] vfs: Convert zsmalloc " David Howells
2019-03-27 23:42 ` [RFC PATCH 12/68] vfs: Convert sockfs " David Howells
2019-03-27 23:42 ` [RFC PATCH 13/68] vfs: Convert dax " David Howells
2019-03-27 23:42 ` [RFC PATCH 14/68] vfs: Convert drm " David Howells
2019-03-28  7:47   ` Daniel Vetter
2019-04-10  9:59   ` David Howells
2019-03-27 23:42 ` [RFC PATCH 15/68] vfs: Convert ia64 perfmon " David Howells
2019-03-27 23:42 ` [RFC PATCH 16/68] vfs: Convert cxl " David Howells
2019-03-27 23:42 ` [RFC PATCH 17/68] vfs: Convert ocxlflash " David Howells
2019-03-27 23:42 ` [RFC PATCH 18/68] vfs: Convert virtio_balloon " David Howells
2019-03-27 23:42 ` [RFC PATCH 19/68] vfs: Convert btrfs_test " David Howells
2019-03-27 23:43 ` [RFC PATCH 20/68] vfs: Kill off mount_pseudo() and mount_pseudo_xattr() David Howells
2019-03-27 23:43 ` [RFC PATCH 21/68] vfs: Use sget_fc() for pseudo-filesystems David Howells
2019-03-27 23:43 ` [RFC PATCH 22/68] vfs: Convert binderfs to use the new mount API David Howells
2019-03-28 14:45   ` Dan Carpenter
2019-04-10 10:01   ` David Howells
2019-03-27 23:43 ` [RFC PATCH 23/68] vfs: Convert nfsctl " David Howells
2019-03-27 23:43 ` [RFC PATCH 24/68] vfs: Convert rpc_pipefs " David Howells
2019-03-27 23:43 ` [RFC PATCH 25/68] vfs: Kill mount_ns() David Howells
2019-03-27 23:43 ` [RFC PATCH 26/68] vfs: Kill sget_userns() David Howells
2019-03-27 23:43 ` [RFC PATCH 27/68] vfs: Convert binfmt_misc to use the new mount API David Howells
2019-03-27 23:44 ` [RFC PATCH 28/68] vfs: Convert configfs " David Howells
2019-03-27 23:44 ` [RFC PATCH 29/68] vfs: Convert efivarfs " David Howells
2019-03-27 23:44 ` [RFC PATCH 30/68] vfs: Convert fusectl " David Howells
2019-04-24 13:49   ` Miklos Szeredi
2019-04-24 15:16   ` David Howells
2019-03-27 23:44 ` [RFC PATCH 31/68] vfs: Convert qib_fs/ipathfs " David Howells
2019-04-09 17:14   ` Dennis Dalessandro
2019-03-27 23:44 ` [RFC PATCH 32/68] vfs: Convert ibmasmfs " David Howells
2019-03-27 23:44 ` [RFC PATCH 33/68] vfs: Convert oprofilefs " David Howells
2019-03-27 23:44 ` [RFC PATCH 34/68] vfs: Convert gadgetfs " David Howells
2019-03-27 23:44 ` [RFC PATCH 35/68] vfs: Convert xenfs " David Howells
2019-04-02  7:38   ` Juergen Gross
2019-03-27 23:45 ` [RFC PATCH 36/68] vfs: Convert openpromfs " David Howells
2019-03-27 23:45 ` [RFC PATCH 37/68] vfs: Convert apparmorfs " David Howells
2019-03-27 23:45 ` [RFC PATCH 38/68] vfs: Convert securityfs " David Howells
2019-03-27 23:45 ` [RFC PATCH 39/68] vfs: Convert selinuxfs " David Howells
2019-03-27 23:45 ` [RFC PATCH 40/68] vfs: Convert smackfs " David Howells
2019-03-27 23:45 ` [RFC PATCH 41/68] vfs: Convert ramfs, shmem, tmpfs, devtmpfs, rootfs " David Howells
2019-03-27 23:45 ` [RFC PATCH 42/68] vfs: Create fs_context-aware mount_bdev() replacement David Howells
2019-03-27 23:45 ` [RFC PATCH 43/68] vfs: Make fs_parse() handle fs_param_is_fd-type params better David Howells
2019-03-27 23:46 ` [RFC PATCH 44/68] vfs: Convert fuse to use the new mount API David Howells
2019-04-24 13:53   ` Miklos Szeredi
2019-04-24 15:22   ` David Howells
2019-04-24 17:28     ` Miklos Szeredi
2019-03-27 23:46 ` [RFC PATCH 45/68] vfs: Move the subtype parameter into fuse David Howells
2019-03-27 23:46 ` [RFC PATCH 46/68] mtd: Provide fs_context-aware mount_mtd() replacement David Howells
2019-03-27 23:46 ` [RFC PATCH 47/68] vfs: Convert romfs to use the new mount API David Howells
2019-03-27 23:46 ` [RFC PATCH 48/68] vfs: Convert cramfs " David Howells
2019-04-01 15:25   ` Nicolas Pitre
2019-03-27 23:46 ` [RFC PATCH 49/68] vfs: Convert jffs2 " David Howells
2019-03-27 23:46 ` [RFC PATCH 50/68] mtd: Kill mount_mtd() David Howells
2019-03-27 23:47 ` [RFC PATCH 51/68] vfs: Convert squashfs to use the new mount API David Howells
2019-03-27 23:47 ` [RFC PATCH 52/68] vfs: Convert ceph " David Howells
2019-04-27 12:27   ` Jeff Layton
2019-03-27 23:47 ` [RFC PATCH 53/68] vfs: Convert functionfs " David Howells
2019-03-28 10:43   ` Michał Nazarewicz
2019-03-27 23:47 ` [RFC PATCH 54/68] vfs: Add a single-or-reconfig keying to vfs_get_super() David Howells
2019-03-27 23:47 ` [RFC PATCH 55/68] vfs: Convert debugfs to use the new mount API David Howells
2019-03-27 23:47 ` [RFC PATCH 56/68] vfs: Convert tracefs " David Howells
2019-03-27 23:47 ` [RFC PATCH 57/68] vfs: Convert pstore " David Howells
2019-03-28  0:24   ` Kees Cook
2019-03-27 23:47 ` [RFC PATCH 58/68] hypfs: Fix error number left in struct pointer member David Howells
2019-03-27 23:48 ` [RFC PATCH 59/68] vfs: Convert hypfs to use the new mount API David Howells
2019-03-27 23:48 ` [RFC PATCH 60/68] vfs: Convert spufs " David Howells
2019-03-27 23:48 ` [RFC PATCH 61/68] vfs: Kill mount_single() David Howells
2019-03-27 23:48 ` [RFC PATCH 62/68] vfs: Convert coda to use the new mount API David Howells
2019-03-27 23:48 ` [RFC PATCH 63/68] vfs: Convert autofs " David Howells
2019-03-27 23:48 ` [RFC PATCH 64/68] vfs: Convert devpts " David Howells
2019-04-05 12:52   ` Christian Brauner
2019-03-27 23:48 ` [RFC PATCH 65/68] vfs: Convert bpf " David Howells
2019-03-27 23:48 ` [RFC PATCH 66/68] vfs: Convert ubifs " David Howells
2019-03-27 23:49 ` David Howells [this message]
2019-03-27 23:49 ` [RFC PATCH 68/68] gfs2: Convert gfs2 to fs_context David Howells

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=155373054475.7602.4918098489201730987.stgit@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=devel@lists.orangefs.org \
    --cc=hubcap@omnibond.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin@omnibond.com \
    --cc=viro@zeniv.linux.org.uk \
    /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).