linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/38] vfs: Provide sb->s_iflags settings in fs_context struct
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
@ 2019-03-14 16:09 ` David Howells
  2019-03-14 16:09 ` [PATCH 02/38] vfs: Provide a mount_pseudo-replacement for fs_context David Howells
                   ` (36 subsequent siblings)
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:09 UTC (permalink / raw)
  To: viro; +Cc: linux-fsdevel, dhowells, linux-fsdevel, linux-kernel

Provide a field in the fs_context struct through which bits in the
sb->s_iflags superblock field can be set.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: linux-fsdevel@vger.kernel.org
---

 fs/super.c                 |    1 +
 include/linux/fs_context.h |    1 +
 2 files changed, 2 insertions(+)

diff --git a/fs/super.c b/fs/super.c
index 583a0124bc39..6c3acd633cca 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -543,6 +543,7 @@ struct super_block *sget_fc(struct fs_context *fc,
 	}
 	fc->s_fs_info = NULL;
 	s->s_type = fc->fs_type;
+	s->s_iflags |= fc->s_iflags;
 	strlcpy(s->s_id, s->s_type->name, sizeof(s->s_id));
 	list_add_tail(&s->s_list, &super_blocks);
 	hlist_add_head(&s->s_instances, &s->s_type->fs_supers);
diff --git a/include/linux/fs_context.h b/include/linux/fs_context.h
index eaca452088fa..98b44ad89378 100644
--- a/include/linux/fs_context.h
+++ b/include/linux/fs_context.h
@@ -86,6 +86,7 @@ struct fs_context {
 	void			*s_fs_info;	/* Proposed s_fs_info */
 	unsigned int		sb_flags;	/* Proposed superblock flags (SB_*) */
 	unsigned int		sb_flags_mask;	/* Superblock flags that were changed */
+	unsigned int		s_iflags;	/* OR'd with sb->s_iflags */
 	unsigned int		lsm_flags;	/* Information flags from the fs to the LSM */
 	enum fs_context_purpose	purpose:8;
 	bool			need_free:1;	/* Need to call ops->free() */


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 02/38] vfs: Provide a mount_pseudo-replacement for fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
  2019-03-14 16:09 ` [PATCH 01/38] vfs: Provide sb->s_iflags settings in fs_context struct David Howells
@ 2019-03-14 16:09 ` David Howells
  2019-03-14 16:09 ` [PATCH 03/38] vfs: Convert aio to fs_context David Howells
                   ` (35 subsequent siblings)
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:09 UTC (permalink / raw)
  To: viro; +Cc: linux-fsdevel, dhowells, linux-fsdevel, linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: linux-fsdevel@vger.kernel.org
---

 fs/libfs.c                 |   93 ++++++++++++++++++++++++++++++++++++++++++++
 include/linux/fs_context.h |    7 +++
 2 files changed, 100 insertions(+)

diff --git a/fs/libfs.c b/fs/libfs.c
index 0fb590d79f30..ceaf69c885c2 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -16,6 +16,7 @@
 #include <linux/exportfs.h>
 #include <linux/writeback.h>
 #include <linux/buffer_head.h> /* sync_mapping_buffers */
+#include <linux/fs_context.h>
 
 #include <linux/uaccess.h>
 
@@ -233,6 +234,98 @@ static const struct super_operations simple_super_operations = {
 	.statfs		= simple_statfs,
 };
 
+struct pseudo_fs_context {
+	struct qstr d_name;
+	const struct super_operations *ops;
+	const struct xattr_handler **xattr;
+	const struct dentry_operations *dops;
+	unsigned long magic;
+};
+
+static int pseudo_fs_get_tree(struct fs_context *fc)
+{
+	struct pseudo_fs_context *ctx = fc->fs_private;
+	struct super_block *s;
+	struct dentry *dentry;
+	struct inode *root;
+
+	s = sget_userns(fc->fs_type, NULL, set_anon_super, SB_KERNMOUNT|SB_NOUSER,
+			&init_user_ns, NULL);
+	if (IS_ERR(s))
+		return PTR_ERR(s);
+
+	s->s_maxbytes = MAX_LFS_FILESIZE;
+	s->s_blocksize = PAGE_SIZE;
+	s->s_blocksize_bits = PAGE_SHIFT;
+	s->s_magic = ctx->magic;
+	s->s_op = ctx->ops ?: &simple_super_operations;
+	s->s_xattr = ctx->xattr;
+	s->s_time_gran = 1;
+	root = new_inode(s);
+	if (!root)
+		goto Enomem;
+	/*
+	 * since this is the first inode, make it number 1. New inodes created
+	 * after this must take care not to collide with it (by passing
+	 * max_reserved of 1 to iunique).
+	 */
+	root->i_ino = 1;
+	root->i_mode = S_IFDIR | S_IRUSR | S_IWUSR;
+	root->i_atime = root->i_mtime = root->i_ctime = current_time(root);
+	dentry = __d_alloc(s, &ctx->d_name);
+	if (!dentry) {
+		iput(root);
+		goto Enomem;
+	}
+	d_instantiate(dentry, root);
+	s->s_root = dentry;
+	s->s_d_op = ctx->dops;
+	s->s_flags |= SB_ACTIVE;
+	fc->root = dget(s->s_root);
+	return 0;
+
+Enomem:
+	deactivate_locked_super(s);
+	return -ENOMEM;
+}
+
+static void pseudo_fs_free(struct fs_context *fc)
+{
+	kfree(fc->fs_private);
+}
+
+static const struct fs_context_operations pseudo_fs_context_ops = {
+	.free		= pseudo_fs_free,
+	.get_tree	= pseudo_fs_get_tree,
+};
+
+/*
+ * Common helper for pseudo-filesystems (sockfs, pipefs, bdev - stuff that
+ * will never be mountable)
+ */
+int vfs_init_pseudo_fs_context(struct fs_context *fc,
+			       const char *name,
+			       const struct super_operations *ops,
+			       const struct xattr_handler **xattr,
+			       const struct dentry_operations *dops,
+			       unsigned long magic)
+{
+	struct pseudo_fs_context *ctx;
+
+	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+	if (!ctx)
+		return -ENOMEM;
+	ctx->d_name = (struct qstr)QSTR_INIT(name, strlen(name));
+	ctx->ops = ops;
+	ctx->xattr = xattr;
+	ctx->dops = dops;
+	ctx->magic = magic;
+	fc->fs_private = ctx;
+	fc->ops = &pseudo_fs_context_ops;
+	return 0;
+}
+EXPORT_SYMBOL(vfs_init_pseudo_fs_context);
+
 /*
  * Common helper for pseudo-filesystems (sockfs, pipefs, bdev - stuff that
  * will never be mountable)
diff --git a/include/linux/fs_context.h b/include/linux/fs_context.h
index 98b44ad89378..a779022d06f5 100644
--- a/include/linux/fs_context.h
+++ b/include/linux/fs_context.h
@@ -121,6 +121,13 @@ extern int generic_parse_monolithic(struct fs_context *fc, void *data);
 extern int vfs_get_tree(struct fs_context *fc);
 extern void put_fs_context(struct fs_context *fc);
 
+extern int vfs_init_pseudo_fs_context(struct fs_context *fc,
+				      const char *name,
+				      const struct super_operations *ops,
+				      const struct xattr_handler **xattr,
+				      const struct dentry_operations *dops,
+				      unsigned long magic);
+
 /*
  * sget() wrapper to be called from the ->get_tree() op.
  */


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 03/38] vfs: Convert aio to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
  2019-03-14 16:09 ` [PATCH 01/38] vfs: Provide sb->s_iflags settings in fs_context struct David Howells
  2019-03-14 16:09 ` [PATCH 02/38] vfs: Provide a mount_pseudo-replacement for fs_context David Howells
@ 2019-03-14 16:09 ` David Howells
  2019-03-14 16:09 ` [PATCH 04/38] vfs: Convert anon_inodes " David Howells
                   ` (34 subsequent siblings)
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:09 UTC (permalink / raw)
  To: viro; +Cc: Benjamin LaHaise, linux-aio, dhowells, linux-fsdevel, linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Benjamin LaHaise <bcrl@kvack.org>
cc: linux-aio@kvack.org
---

 fs/aio.c |   15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/fs/aio.c b/fs/aio.c
index 38b741aef0bf..42bf0c83da66 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -42,6 +42,7 @@
 #include <linux/ramfs.h>
 #include <linux/percpu-refcount.h>
 #include <linux/mount.h>
+#include <linux/fs_context.h>
 
 #include <asm/kmap_types.h>
 #include <linux/uaccess.h>
@@ -250,15 +251,11 @@ static struct file *aio_private_file(struct kioctx *ctx, loff_t nr_pages)
 	return file;
 }
 
-static struct dentry *aio_mount(struct file_system_type *fs_type,
-				int flags, const char *dev_name, void *data)
+static int aio_init_fs_context(struct fs_context *fc)
 {
-	struct dentry *root = mount_pseudo(fs_type, "aio:", NULL, NULL,
-					   AIO_RING_MAGIC);
-
-	if (!IS_ERR(root))
-		root->d_sb->s_iflags |= SB_I_NOEXEC;
-	return root;
+	fc->s_iflags |= SB_I_NOEXEC;
+	return vfs_init_pseudo_fs_context(fc, "aio:",
+					  NULL, NULL, NULL, AIO_RING_MAGIC);
 }
 
 /* aio_setup
@@ -269,7 +266,7 @@ static int __init aio_setup(void)
 {
 	static struct file_system_type aio_fs = {
 		.name		= "aio",
-		.mount		= aio_mount,
+		.init_fs_context = aio_init_fs_context,
 		.kill_sb	= kill_anon_super,
 	};
 	aio_mnt = kern_mount(&aio_fs);


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 04/38] vfs: Convert anon_inodes to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (2 preceding siblings ...)
  2019-03-14 16:09 ` [PATCH 03/38] vfs: Convert aio to fs_context David Howells
@ 2019-03-14 16:09 ` David Howells
  2019-03-14 16:09 ` [PATCH 05/38] vfs: Convert bdev " David Howells
                   ` (33 subsequent siblings)
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:09 UTC (permalink / raw)
  To: viro; +Cc: linux-fsdevel, dhowells, linux-fsdevel, linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: linux-fsdevel@vger.kernel.org
---

 fs/anon_inodes.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c
index 91262c34b797..e05d01e5b28f 100644
--- a/fs/anon_inodes.c
+++ b/fs/anon_inodes.c
@@ -19,6 +19,7 @@
 #include <linux/kernel.h>
 #include <linux/magic.h>
 #include <linux/anon_inodes.h>
+#include <linux/fs_context.h>
 
 #include <linux/uaccess.h>
 
@@ -38,16 +39,17 @@ static const struct dentry_operations anon_inodefs_dentry_operations = {
 	.d_dname	= anon_inodefs_dname,
 };
 
-static struct dentry *anon_inodefs_mount(struct file_system_type *fs_type,
-				int flags, const char *dev_name, void *data)
+static int anon_inodefs_init_fs_context(struct fs_context *fc)
 {
-	return mount_pseudo(fs_type, "anon_inode:", NULL,
-			&anon_inodefs_dentry_operations, ANON_INODE_FS_MAGIC);
+	return vfs_init_pseudo_fs_context(fc, "anon_inode:",
+					  NULL, NULL,
+					  &anon_inodefs_dentry_operations,
+					  ANON_INODE_FS_MAGIC);
 }
 
 static struct file_system_type anon_inode_fs_type = {
 	.name		= "anon_inodefs",
-	.mount		= anon_inodefs_mount,
+	.init_fs_context = anon_inodefs_init_fs_context,
 	.kill_sb	= kill_anon_super,
 };
 


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 05/38] vfs: Convert bdev to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (3 preceding siblings ...)
  2019-03-14 16:09 ` [PATCH 04/38] vfs: Convert anon_inodes " David Howells
@ 2019-03-14 16:09 ` David Howells
  2019-03-14 16:09 ` [PATCH 06/38] vfs: Convert nsfs " David Howells
                   ` (32 subsequent siblings)
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:09 UTC (permalink / raw)
  To: viro; +Cc: Jens Axboe, linux-fsdevel, dhowells, linux-fsdevel, linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Jens Axboe <axboe@kernel.dk>
cc: linux-fsdevel@vger.kernel.org
---

 fs/block_dev.c |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index e9faa52bb489..2846970b5415 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -25,6 +25,7 @@
 #include <linux/writeback.h>
 #include <linux/mpage.h>
 #include <linux/mount.h>
+#include <linux/fs_context.h>
 #include <linux/uio.h>
 #include <linux/namei.h>
 #include <linux/log2.h>
@@ -842,19 +843,16 @@ static const struct super_operations bdev_sops = {
 	.evict_inode = bdev_evict_inode,
 };
 
-static struct dentry *bd_mount(struct file_system_type *fs_type,
-	int flags, const char *dev_name, void *data)
+static int bd_init_fs_context(struct fs_context *fc)
 {
-	struct dentry *dent;
-	dent = mount_pseudo(fs_type, "bdev:", &bdev_sops, NULL, BDEVFS_MAGIC);
-	if (!IS_ERR(dent))
-		dent->d_sb->s_iflags |= SB_I_CGROUPWB;
-	return dent;
+	fc->s_iflags |= SB_I_CGROUPWB;
+	return vfs_init_pseudo_fs_context(fc, "bdev:",
+					  &bdev_sops, NULL, NULL, BDEVFS_MAGIC);
 }
 
 static struct file_system_type bd_type = {
 	.name		= "bdev",
-	.mount		= bd_mount,
+	.init_fs_context = bd_init_fs_context,
 	.kill_sb	= kill_anon_super,
 };
 


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 06/38] vfs: Convert nsfs to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (4 preceding siblings ...)
  2019-03-14 16:09 ` [PATCH 05/38] vfs: Convert bdev " David Howells
@ 2019-03-14 16:09 ` David Howells
  2019-03-14 16:09 ` [PATCH 07/38] vfs: Convert pipe " David Howells
                   ` (31 subsequent siblings)
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:09 UTC (permalink / raw)
  To: viro
  Cc: Eric W. Biederman, linux-fsdevel, dhowells, linux-fsdevel, linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Eric W. Biederman <ebiederm@xmission.com>
cc: linux-fsdevel@vger.kernel.org
---

 fs/nsfs.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/fs/nsfs.c b/fs/nsfs.c
index 60702d677bd4..1a86ab9abaf7 100644
--- a/fs/nsfs.c
+++ b/fs/nsfs.c
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <linux/mount.h>
+#include <linux/fs_context.h>
 #include <linux/file.h>
 #include <linux/fs.h>
 #include <linux/proc_ns.h>
@@ -262,15 +263,17 @@ static const struct super_operations nsfs_ops = {
 	.evict_inode = nsfs_evict,
 	.show_path = nsfs_show_path,
 };
-static struct dentry *nsfs_mount(struct file_system_type *fs_type,
-			int flags, const char *dev_name, void *data)
+
+static int nsfs_init_fs_context(struct fs_context *fc)
 {
-	return mount_pseudo(fs_type, "nsfs:", &nsfs_ops,
-			&ns_dentry_operations, NSFS_MAGIC);
+	return vfs_init_pseudo_fs_context(fc, "nsfs:",
+					  &nsfs_ops, NULL,
+					  &ns_dentry_operations, NSFS_MAGIC);
 }
+
 static struct file_system_type nsfs = {
 	.name = "nsfs",
-	.mount = nsfs_mount,
+	.init_fs_context = nsfs_init_fs_context,
 	.kill_sb = kill_anon_super,
 };
 


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 07/38] vfs: Convert pipe to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (5 preceding siblings ...)
  2019-03-14 16:09 ` [PATCH 06/38] vfs: Convert nsfs " David Howells
@ 2019-03-14 16:09 ` David Howells
  2019-03-14 16:09 ` [PATCH 08/38] vfs: Convert zsmalloc " David Howells
                   ` (30 subsequent siblings)
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:09 UTC (permalink / raw)
  To: viro; +Cc: linux-fsdevel, dhowells, linux-fsdevel, linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: linux-fsdevel@vger.kernel.org
---

 fs/pipe.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/fs/pipe.c b/fs/pipe.c
index 070aad543382..14f029d1897f 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -14,6 +14,7 @@
 #include <linux/fs.h>
 #include <linux/log2.h>
 #include <linux/mount.h>
+#include <linux/fs_context.h>
 #include <linux/magic.h>
 #include <linux/pipe_fs_i.h>
 #include <linux/uio.h>
@@ -1182,16 +1183,17 @@ static const struct super_operations pipefs_ops = {
  * any operations on the root directory. However, we need a non-trivial
  * d_name - pipe: will go nicely and kill the special-casing in procfs.
  */
-static struct dentry *pipefs_mount(struct file_system_type *fs_type,
-			 int flags, const char *dev_name, void *data)
+
+static int pipefs_init_fs_context(struct fs_context *fc)
 {
-	return mount_pseudo(fs_type, "pipe:", &pipefs_ops,
-			&pipefs_dentry_operations, PIPEFS_MAGIC);
+	return vfs_init_pseudo_fs_context(fc, "pipe:",
+					  &pipefs_ops, NULL,
+					  &pipefs_dentry_operations, PIPEFS_MAGIC);
 }
 
 static struct file_system_type pipe_fs_type = {
 	.name		= "pipefs",
-	.mount		= pipefs_mount,
+	.init_fs_context = pipefs_init_fs_context,
 	.kill_sb	= kill_anon_super,
 };
 


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 08/38] vfs: Convert zsmalloc to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (6 preceding siblings ...)
  2019-03-14 16:09 ` [PATCH 07/38] vfs: Convert pipe " David Howells
@ 2019-03-14 16:09 ` David Howells
  2019-03-14 16:10 ` [PATCH 09/38] vfs: Convert sockfs " David Howells
                   ` (29 subsequent siblings)
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:09 UTC (permalink / raw)
  To: viro
  Cc: Minchan Kim, Nitin Gupta, Sergey Senozhatsky, linux-mm, dhowells,
	linux-fsdevel, linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Minchan Kim <minchan@kernel.org>
cc: Nitin Gupta <ngupta@vflare.org>
cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
cc: linux-mm@kvack.org
---

 mm/zsmalloc.c |   19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 0787d33b80d8..02bfc7f70fab 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -52,6 +52,7 @@
 #include <linux/zsmalloc.h>
 #include <linux/zpool.h>
 #include <linux/mount.h>
+#include <linux/fs_context.h>
 #include <linux/migrate.h>
 #include <linux/pagemap.h>
 #include <linux/fs.h>
@@ -1814,19 +1815,21 @@ static void lock_zspage(struct zspage *zspage)
 	} while ((page = get_next_page(page)) != NULL);
 }
 
-static struct dentry *zs_mount(struct file_system_type *fs_type,
-				int flags, const char *dev_name, void *data)
-{
-	static const struct dentry_operations ops = {
-		.d_dname = simple_dname,
-	};
+static const struct dentry_operations zs_dentry_operations = {
+	.d_dname = simple_dname,
+};
 
-	return mount_pseudo(fs_type, "zsmalloc:", NULL, &ops, ZSMALLOC_MAGIC);
+
+static int zs_init_fs_context(struct fs_context *fc)
+{
+	return vfs_init_pseudo_fs_context(fc, "zsmalloc:",
+					  NULL, NULL,
+					  &zs_dentry_operations, ZSMALLOC_MAGIC);
 }
 
 static struct file_system_type zsmalloc_fs = {
 	.name		= "zsmalloc",
-	.mount		= zs_mount,
+	.init_fs_context = zs_init_fs_context,
 	.kill_sb	= kill_anon_super,
 };
 


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 09/38] vfs: Convert sockfs to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (7 preceding siblings ...)
  2019-03-14 16:09 ` [PATCH 08/38] vfs: Convert zsmalloc " David Howells
@ 2019-03-14 16:10 ` David Howells
  2019-03-14 16:10 ` [PATCH 10/38] vfs: Convert dax " David Howells
                   ` (28 subsequent siblings)
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:10 UTC (permalink / raw)
  To: viro; +Cc: netdev, dhowells, linux-fsdevel, linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: netdev@vger.kernel.org
---

 net/socket.c |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/net/socket.c b/net/socket.c
index 3c176a12fe48..40d0ed85d61a 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -79,6 +79,7 @@
 #include <linux/module.h>
 #include <linux/highmem.h>
 #include <linux/mount.h>
+#include <linux/fs_context.h>
 #include <linux/security.h>
 #include <linux/syscalls.h>
 #include <linux/compat.h>
@@ -351,19 +352,20 @@ static const struct xattr_handler *sockfs_xattr_handlers[] = {
 	NULL
 };
 
-static struct dentry *sockfs_mount(struct file_system_type *fs_type,
-			 int flags, const char *dev_name, void *data)
+static int sockfs_init_fs_context(struct fs_context *fc)
 {
-	return mount_pseudo_xattr(fs_type, "socket:", &sockfs_ops,
-				  sockfs_xattr_handlers,
-				  &sockfs_dentry_operations, SOCKFS_MAGIC);
+	return vfs_init_pseudo_fs_context(fc, "socket:",
+					  &sockfs_ops,
+					  sockfs_xattr_handlers,
+					  &sockfs_dentry_operations,
+					  SOCKFS_MAGIC);
 }
 
 static struct vfsmount *sock_mnt __read_mostly;
 
 static struct file_system_type sock_fs_type = {
 	.name =		"sockfs",
-	.mount =	sockfs_mount,
+	.init_fs_context = sockfs_init_fs_context,
 	.kill_sb =	kill_anon_super,
 };
 


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 10/38] vfs: Convert dax to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (8 preceding siblings ...)
  2019-03-14 16:10 ` [PATCH 09/38] vfs: Convert sockfs " David Howells
@ 2019-03-14 16:10 ` David Howells
  2019-03-14 16:10 ` [PATCH 11/38] vfs: Convert drm " David Howells
                   ` (27 subsequent siblings)
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:10 UTC (permalink / raw)
  To: viro
  Cc: Dan Williams, Vishal Verma, Keith Busch, Dave Jiang,
	linux-nvdimm, dhowells, linux-fsdevel, linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Dan Williams <dan.j.williams@intel.com>
cc: Vishal Verma <vishal.l.verma@intel.com>
cc: Keith Busch <keith.busch@intel.com>
cc: Dave Jiang <dave.jiang@intel.com>
cc: linux-nvdimm@lists.01.org
---

 drivers/dax/super.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/dax/super.c b/drivers/dax/super.c
index 0cb8c30ea278..40a9e665be32 100644
--- a/drivers/dax/super.c
+++ b/drivers/dax/super.c
@@ -13,6 +13,7 @@
 #include <linux/pagemap.h>
 #include <linux/module.h>
 #include <linux/mount.h>
+#include <linux/fs_context.h>
 #include <linux/magic.h>
 #include <linux/genhd.h>
 #include <linux/pfn_t.h>
@@ -435,16 +436,16 @@ static const struct super_operations dax_sops = {
 	.drop_inode = generic_delete_inode,
 };
 
-static struct dentry *dax_mount(struct file_system_type *fs_type,
-		int flags, const char *dev_name, void *data)
+static int dax_init_fs_context(struct fs_context *fc)
 {
-	return mount_pseudo(fs_type, "dax:", &dax_sops, NULL, DAXFS_MAGIC);
+	return vfs_init_pseudo_fs_context(fc, "dax:",
+					  &dax_sops, NULL, NULL, DAXFS_MAGIC);
 }
 
 static struct file_system_type dax_fs_type = {
-	.name = "dax",
-	.mount = dax_mount,
-	.kill_sb = kill_anon_super,
+	.name		= "dax",
+	.init_fs_context = dax_init_fs_context,
+	.kill_sb	= kill_anon_super,
 };
 
 static int dax_test(struct inode *inode, void *data)


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 11/38] vfs: Convert drm to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (9 preceding siblings ...)
  2019-03-14 16:10 ` [PATCH 10/38] vfs: Convert dax " David Howells
@ 2019-03-14 16:10 ` David Howells
  2019-03-14 16:10 ` [PATCH 12/38] vfs: Convert ia64 perfmon " David Howells
                   ` (26 subsequent siblings)
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:10 UTC (permalink / raw)
  To: viro
  Cc: David Airlie, Daniel Vetter, dri-devel, dhowells, linux-fsdevel,
	linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: David Airlie <airlied@linux.ie>
cc: Daniel Vetter <daniel@ffwll.ch>
cc: dri-devel@lists.freedesktop.org
---

 drivers/gpu/drm/drm_drv.c |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 381581b01d48..9eead5a478de 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -31,6 +31,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/mount.h>
+#include <linux/fs_context.h>
 #include <linux/slab.h>
 #include <linux/srcu.h>
 
@@ -413,20 +414,17 @@ static const struct super_operations drm_fs_sops = {
 	.statfs		= simple_statfs,
 };
 
-static struct dentry *drm_fs_mount(struct file_system_type *fs_type, int flags,
-				   const char *dev_name, void *data)
+static int drm_fs_init_fs_context(struct fs_context *fc)
 {
-	return mount_pseudo(fs_type,
-			    "drm:",
-			    &drm_fs_sops,
-			    &drm_fs_dops,
-			    0x010203ff);
+	return vfs_init_pseudo_fs_context(fc, "drm:",
+					  &drm_fs_sops, NULL,
+					  &drm_fs_dops, 0x010203ff);
 }
 
 static struct file_system_type drm_fs_type = {
 	.name		= "drm",
 	.owner		= THIS_MODULE,
-	.mount		= drm_fs_mount,
+	.init_fs_context = drm_fs_init_fs_context,
 	.kill_sb	= kill_anon_super,
 };
 


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 12/38] vfs: Convert ia64 perfmon to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (10 preceding siblings ...)
  2019-03-14 16:10 ` [PATCH 11/38] vfs: Convert drm " David Howells
@ 2019-03-14 16:10 ` David Howells
  2019-03-14 16:10 ` [PATCH 13/38] vfs: Convert cxl " David Howells
                   ` (25 subsequent siblings)
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:10 UTC (permalink / raw)
  To: viro
  Cc: Tony Luck, Fenghua Yu, linux-ia64, dhowells, linux-fsdevel, linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Tony Luck <tony.luck@intel.com>
cc: Fenghua Yu <fenghua.yu@intel.com>
cc: linux-ia64@vger.kernel.org
---

 arch/ia64/kernel/perfmon.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index 7a969f4c3534..4b5770736ac5 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -38,6 +38,7 @@
 #include <linux/smp.h>
 #include <linux/pagemap.h>
 #include <linux/mount.h>
+#include <linux/fs_context.h>
 #include <linux/bitops.h>
 #include <linux/capability.h>
 #include <linux/rcupdate.h>
@@ -599,17 +600,16 @@ pfm_unprotect_ctx_ctxsw(pfm_context_t *x, unsigned long f)
 /* forward declaration */
 static const struct dentry_operations pfmfs_dentry_operations;
 
-static struct dentry *
-pfmfs_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *data)
+static int pfmfs_init_fs_context(struct fs_context *fc)
 {
-	return mount_pseudo(fs_type, "pfm:", NULL, &pfmfs_dentry_operations,
-			PFMFS_MAGIC);
+	return vfs_init_pseudo_fs_context(fc, "pfm:", NULL, NULL,
+					  &pfmfs_dentry_operations, PFMFS_MAGIC);
 }
 
 static struct file_system_type pfm_fs_type = {
-	.name     = "pfmfs",
-	.mount    = pfmfs_mount,
-	.kill_sb  = kill_anon_super,
+	.name			= "pfmfs",
+	.init_fs_context	= pfmfs_init_fs_context,
+	.kill_sb		= kill_anon_super,
 };
 MODULE_ALIAS_FS("pfmfs");
 


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 13/38] vfs: Convert cxl to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (11 preceding siblings ...)
  2019-03-14 16:10 ` [PATCH 12/38] vfs: Convert ia64 perfmon " David Howells
@ 2019-03-14 16:10 ` David Howells
  2019-03-15  0:22   ` Andrew Donnellan
  2019-03-22  7:42   ` Frederic Barrat
  2019-03-14 16:10 ` [PATCH 14/38] vfs: Convert ocxlflash " David Howells
                   ` (24 subsequent siblings)
  37 siblings, 2 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:10 UTC (permalink / raw)
  To: viro
  Cc: Frederic Barrat, Andrew Donnellan, linuxppc-dev, dhowells,
	linux-fsdevel, linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Frederic Barrat <fbarrat@linux.ibm.com>
cc: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
cc: linuxppc-dev@lists.ozlabs.org
---

 drivers/misc/cxl/api.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c
index 750470ef2049..395e9a88e6ba 100644
--- a/drivers/misc/cxl/api.c
+++ b/drivers/misc/cxl/api.c
@@ -13,6 +13,7 @@
 #include <misc/cxl.h>
 #include <linux/module.h>
 #include <linux/mount.h>
+#include <linux/fs_context.h>
 #include <linux/sched/mm.h>
 #include <linux/mmu_context.h>
 
@@ -41,17 +42,16 @@ static const struct dentry_operations cxl_fs_dops = {
 	.d_dname	= simple_dname,
 };
 
-static struct dentry *cxl_fs_mount(struct file_system_type *fs_type, int flags,
-				const char *dev_name, void *data)
+static int cxl_fs_init_fs_context(struct fs_context *fc)
 {
-	return mount_pseudo(fs_type, "cxl:", NULL, &cxl_fs_dops,
-			CXL_PSEUDO_FS_MAGIC);
+	return vfs_init_pseudo_fs_context(fc, "cxl:", NULL, NULL,
+					  &cxl_fs_dops, CXL_PSEUDO_FS_MAGIC);
 }
 
 static struct file_system_type cxl_fs_type = {
 	.name		= "cxl",
 	.owner		= THIS_MODULE,
-	.mount		= cxl_fs_mount,
+	.init_fs_context = cxl_fs_init_fs_context,
 	.kill_sb	= kill_anon_super,
 };
 


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 14/38] vfs: Convert ocxlflash to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (12 preceding siblings ...)
  2019-03-14 16:10 ` [PATCH 13/38] vfs: Convert cxl " David Howells
@ 2019-03-14 16:10 ` David Howells
  2019-03-19 14:53   ` Matthew R. Ochs
  2019-03-14 16:10 ` [PATCH 15/38] vfs: Convert virtio_balloon " David Howells
                   ` (23 subsequent siblings)
  37 siblings, 1 reply; 46+ messages in thread
From: David Howells @ 2019-03-14 16:10 UTC (permalink / raw)
  To: viro
  Cc: Manoj N. Kumar, Matthew R. Ochs, Uma Krishnan,
	James E.J. Bottomley, Martin K. Petersen, linux-scsi, dhowells,
	linux-fsdevel, linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: "Manoj N. Kumar" <manoj@linux.ibm.com>
cc: "Matthew R. Ochs" <mrochs@linux.ibm.com>
cc: Uma Krishnan <ukrishn@linux.ibm.com>
cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
cc: "Martin K. Petersen" <martin.petersen@oracle.com>
cc: linux-scsi@vger.kernel.org
---

 drivers/scsi/cxlflash/ocxl_hw.c |   21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/cxlflash/ocxl_hw.c b/drivers/scsi/cxlflash/ocxl_hw.c
index 37b8dc60f5f6..a8d2cc6390c7 100644
--- a/drivers/scsi/cxlflash/ocxl_hw.c
+++ b/drivers/scsi/cxlflash/ocxl_hw.c
@@ -16,6 +16,7 @@
 #include <linux/idr.h>
 #include <linux/module.h>
 #include <linux/mount.h>
+#include <linux/fs_context.h>
 #include <linux/poll.h>
 #include <linux/sched/signal.h>
 
@@ -39,27 +40,17 @@ static const struct dentry_operations ocxlflash_fs_dops = {
 	.d_dname	= simple_dname,
 };
 
-/*
- * ocxlflash_fs_mount() - mount the pseudo-filesystem
- * @fs_type:	File system type.
- * @flags:	Flags for the filesystem.
- * @dev_name:	Device name associated with the filesystem.
- * @data:	Data pointer.
- *
- * Return: pointer to the directory entry structure
- */
-static struct dentry *ocxlflash_fs_mount(struct file_system_type *fs_type,
-					 int flags, const char *dev_name,
-					 void *data)
+static int ocxlflash_fs_init_fs_context(struct fs_context *fc)
 {
-	return mount_pseudo(fs_type, "ocxlflash:", NULL, &ocxlflash_fs_dops,
-			    OCXLFLASH_FS_MAGIC);
+	return vfs_init_pseudo_fs_context(fc, "ocxlflash:",
+					  NULL, NULL,
+					  &ocxlflash_fs_dops, OCXLFLASH_FS_MAGIC);
 }
 
 static struct file_system_type ocxlflash_fs_type = {
 	.name		= "ocxlflash",
 	.owner		= THIS_MODULE,
-	.mount		= ocxlflash_fs_mount,
+	.init_fs_context = ocxlflash_fs_init_fs_context,
 	.kill_sb	= kill_anon_super,
 };
 


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 15/38] vfs: Convert virtio_balloon to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (13 preceding siblings ...)
  2019-03-14 16:10 ` [PATCH 14/38] vfs: Convert ocxlflash " David Howells
@ 2019-03-14 16:10 ` David Howells
  2019-03-14 16:11 ` [PATCH 16/38] vfs: Convert btrfs_test " David Howells
                   ` (22 subsequent siblings)
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:10 UTC (permalink / raw)
  To: viro
  Cc: Michael S. Tsirkin, Jason Wang, virtualization, dhowells,
	linux-fsdevel, linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: "Michael S. Tsirkin" <mst@redhat.com>
cc: Jason Wang <jasowang@redhat.com>
cc: virtualization@lists.linux-foundation.org
---

 drivers/virtio/virtio_balloon.c |   19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index f19061b585a4..89d67c8aa719 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -757,21 +757,22 @@ static int virtballoon_migratepage(struct balloon_dev_info *vb_dev_info,
 
 	return MIGRATEPAGE_SUCCESS;
 }
+#include <linux/fs_context.h>
 
-static struct dentry *balloon_mount(struct file_system_type *fs_type,
-		int flags, const char *dev_name, void *data)
-{
-	static const struct dentry_operations ops = {
-		.d_dname = simple_dname,
-	};
+static const struct dentry_operations balloon_dops = {
+	.d_dname = simple_dname,
+};
 
-	return mount_pseudo(fs_type, "balloon-kvm:", NULL, &ops,
-				BALLOON_KVM_MAGIC);
+static int balloon_init_fs_context(struct fs_context *fc)
+{
+	return vfs_init_pseudo_fs_context(fc, "balloon-kvm:",
+					  NULL, NULL,
+					  &balloon_dops, BALLOON_KVM_MAGIC);
 }
 
 static struct file_system_type balloon_fs = {
 	.name           = "balloon-kvm",
-	.mount          = balloon_mount,
+	.init_fs_context = balloon_init_fs_context,
 	.kill_sb        = kill_anon_super,
 };
 


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 16/38] vfs: Convert btrfs_test to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (14 preceding siblings ...)
  2019-03-14 16:10 ` [PATCH 15/38] vfs: Convert virtio_balloon " David Howells
@ 2019-03-14 16:11 ` David Howells
  2019-03-14 18:24   ` David Sterba
  2019-03-14 16:11 ` [PATCH 17/38] vfs: Kill off mount_pseudo() and mount_pseudo_xattr() David Howells
                   ` (21 subsequent siblings)
  37 siblings, 1 reply; 46+ messages in thread
From: David Howells @ 2019-03-14 16:11 UTC (permalink / raw)
  To: viro
  Cc: Chris Mason, Josef Bacik, David Sterba, linux-btrfs, dhowells,
	linux-fsdevel, linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Chris Mason <clm@fb.com>
cc: Josef Bacik <josef@toxicpanda.com>
cc: David Sterba <dsterba@suse.com>
cc: linux-btrfs@vger.kernel.org
---

 fs/btrfs/tests/btrfs-tests.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/fs/btrfs/tests/btrfs-tests.c b/fs/btrfs/tests/btrfs-tests.c
index 8a59597f1883..dabd43a37414 100644
--- a/fs/btrfs/tests/btrfs-tests.c
+++ b/fs/btrfs/tests/btrfs-tests.c
@@ -5,6 +5,7 @@
 
 #include <linux/fs.h>
 #include <linux/mount.h>
+#include <linux/fs_context.h>
 #include <linux/magic.h>
 #include "btrfs-tests.h"
 #include "../ctree.h"
@@ -22,17 +23,17 @@ static const struct super_operations btrfs_test_super_ops = {
 	.destroy_inode	= btrfs_test_destroy_inode,
 };
 
-static struct dentry *btrfs_test_mount(struct file_system_type *fs_type,
-				       int flags, const char *dev_name,
-				       void *data)
+
+static int btrfs_test_init_fs_context(struct fs_context *fc)
 {
-	return mount_pseudo(fs_type, "btrfs_test:", &btrfs_test_super_ops,
-			    NULL, BTRFS_TEST_MAGIC);
+	return vfs_init_pseudo_fs_context(fc, "btrfs_test:",
+					  &btrfs_test_super_ops, NULL,
+					  NULL, BTRFS_TEST_MAGIC);
 }
 
 static struct file_system_type test_type = {
 	.name		= "btrfs_test_fs",
-	.mount		= btrfs_test_mount,
+	.init_fs_context = btrfs_test_init_fs_context,
 	.kill_sb	= kill_anon_super,
 };
 


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 17/38] vfs: Kill off mount_pseudo() and mount_pseudo_xattr()
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (15 preceding siblings ...)
  2019-03-14 16:11 ` [PATCH 16/38] vfs: Convert btrfs_test " David Howells
@ 2019-03-14 16:11 ` David Howells
  2019-03-14 16:11 ` [PATCH 18/38] vfs: Use sget_fc() for pseudo-filesystems David Howells
                   ` (20 subsequent siblings)
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:11 UTC (permalink / raw)
  To: viro; +Cc: linux-fsdevel, dhowells, linux-fsdevel, linux-kernel

Kill off mount_pseudo() and mount_pseudo_xattr() as they're replaced with
vfs_init_pseudo_fs_context().

Signed-off-by: David Howells <dhowells@redhat.com>
cc: linux-fsdevel@vger.kernel.org
---

 fs/libfs.c         |   53 ----------------------------------------------------
 include/linux/fs.h |   13 -------------
 2 files changed, 66 deletions(-)

diff --git a/fs/libfs.c b/fs/libfs.c
index ceaf69c885c2..9a15590b65da 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -326,59 +326,6 @@ int vfs_init_pseudo_fs_context(struct fs_context *fc,
 }
 EXPORT_SYMBOL(vfs_init_pseudo_fs_context);
 
-/*
- * Common helper for pseudo-filesystems (sockfs, pipefs, bdev - stuff that
- * will never be mountable)
- */
-struct dentry *mount_pseudo_xattr(struct file_system_type *fs_type, char *name,
-	const struct super_operations *ops, const struct xattr_handler **xattr,
-	const struct dentry_operations *dops, unsigned long magic)
-{
-	struct super_block *s;
-	struct dentry *dentry;
-	struct inode *root;
-	struct qstr d_name = QSTR_INIT(name, strlen(name));
-
-	s = sget_userns(fs_type, NULL, set_anon_super, SB_KERNMOUNT|SB_NOUSER,
-			&init_user_ns, NULL);
-	if (IS_ERR(s))
-		return ERR_CAST(s);
-
-	s->s_maxbytes = MAX_LFS_FILESIZE;
-	s->s_blocksize = PAGE_SIZE;
-	s->s_blocksize_bits = PAGE_SHIFT;
-	s->s_magic = magic;
-	s->s_op = ops ? ops : &simple_super_operations;
-	s->s_xattr = xattr;
-	s->s_time_gran = 1;
-	root = new_inode(s);
-	if (!root)
-		goto Enomem;
-	/*
-	 * since this is the first inode, make it number 1. New inodes created
-	 * after this must take care not to collide with it (by passing
-	 * max_reserved of 1 to iunique).
-	 */
-	root->i_ino = 1;
-	root->i_mode = S_IFDIR | S_IRUSR | S_IWUSR;
-	root->i_atime = root->i_mtime = root->i_ctime = current_time(root);
-	dentry = __d_alloc(s, &d_name);
-	if (!dentry) {
-		iput(root);
-		goto Enomem;
-	}
-	d_instantiate(dentry, root);
-	s->s_root = dentry;
-	s->s_d_op = dops;
-	s->s_flags |= SB_ACTIVE;
-	return dget(s->s_root);
-
-Enomem:
-	deactivate_locked_super(s);
-	return ERR_PTR(-ENOMEM);
-}
-EXPORT_SYMBOL(mount_pseudo_xattr);
-
 int simple_open(struct inode *inode, struct file *file)
 {
 	if (inode->i_private)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 8b42df09b04c..b738e8e5b096 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2245,19 +2245,6 @@ struct super_block *sget(struct file_system_type *type,
 			int (*test)(struct super_block *,void *),
 			int (*set)(struct super_block *,void *),
 			int flags, void *data);
-extern struct dentry *mount_pseudo_xattr(struct file_system_type *, char *,
-					 const struct super_operations *ops,
-					 const struct xattr_handler **xattr,
-					 const struct dentry_operations *dops,
-					 unsigned long);
-
-static inline struct dentry *
-mount_pseudo(struct file_system_type *fs_type, char *name,
-	     const struct super_operations *ops,
-	     const struct dentry_operations *dops, unsigned long magic)
-{
-	return mount_pseudo_xattr(fs_type, name, ops, NULL, dops, magic);
-}
 
 /* Alas, no aliases. Too much hassle with bringing module.h everywhere */
 #define fops_get(fops) \


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 18/38] vfs: Use sget_fc() for pseudo-filesystems
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (16 preceding siblings ...)
  2019-03-14 16:11 ` [PATCH 17/38] vfs: Kill off mount_pseudo() and mount_pseudo_xattr() David Howells
@ 2019-03-14 16:11 ` David Howells
  2019-03-14 16:11 ` [PATCH 19/38] vfs: Convert binderfs to fs_context David Howells
                   ` (19 subsequent siblings)
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:11 UTC (permalink / raw)
  To: viro; +Cc: linux-fsdevel, dhowells, linux-fsdevel, linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: linux-fsdevel@vger.kernel.org
---

 fs/libfs.c |   25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/fs/libfs.c b/fs/libfs.c
index 9a15590b65da..f6710316de00 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -242,18 +242,12 @@ struct pseudo_fs_context {
 	unsigned long magic;
 };
 
-static int pseudo_fs_get_tree(struct fs_context *fc)
+static int pseudo_fs_fill_super(struct super_block *s, struct fs_context *fc)
 {
 	struct pseudo_fs_context *ctx = fc->fs_private;
-	struct super_block *s;
 	struct dentry *dentry;
 	struct inode *root;
 
-	s = sget_userns(fc->fs_type, NULL, set_anon_super, SB_KERNMOUNT|SB_NOUSER,
-			&init_user_ns, NULL);
-	if (IS_ERR(s))
-		return PTR_ERR(s);
-
 	s->s_maxbytes = MAX_LFS_FILESIZE;
 	s->s_blocksize = PAGE_SIZE;
 	s->s_blocksize_bits = PAGE_SHIFT;
@@ -263,7 +257,8 @@ static int pseudo_fs_get_tree(struct fs_context *fc)
 	s->s_time_gran = 1;
 	root = new_inode(s);
 	if (!root)
-		goto Enomem;
+		return -ENOMEM;
+
 	/*
 	 * since this is the first inode, make it number 1. New inodes created
 	 * after this must take care not to collide with it (by passing
@@ -275,18 +270,17 @@ static int pseudo_fs_get_tree(struct fs_context *fc)
 	dentry = __d_alloc(s, &ctx->d_name);
 	if (!dentry) {
 		iput(root);
-		goto Enomem;
+		return -ENOMEM;
 	}
 	d_instantiate(dentry, root);
 	s->s_root = dentry;
 	s->s_d_op = ctx->dops;
-	s->s_flags |= SB_ACTIVE;
-	fc->root = dget(s->s_root);
 	return 0;
+}
 
-Enomem:
-	deactivate_locked_super(s);
-	return -ENOMEM;
+static int pseudo_fs_get_tree(struct fs_context *fc)
+{
+	return vfs_get_super(fc, vfs_get_independent_super, pseudo_fs_fill_super);
 }
 
 static void pseudo_fs_free(struct fs_context *fc)
@@ -320,6 +314,9 @@ int vfs_init_pseudo_fs_context(struct fs_context *fc,
 	ctx->xattr = xattr;
 	ctx->dops = dops;
 	ctx->magic = magic;
+
+	fc->sb_flags = SB_KERNMOUNT | SB_NOUSER;
+	fc->global = true;
 	fc->fs_private = ctx;
 	fc->ops = &pseudo_fs_context_ops;
 	return 0;


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 19/38] vfs: Convert binderfs to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (17 preceding siblings ...)
  2019-03-14 16:11 ` [PATCH 18/38] vfs: Use sget_fc() for pseudo-filesystems David Howells
@ 2019-03-14 16:11 ` David Howells
  2019-03-14 16:11 ` [PATCH 20/38] vfs: Convert nfsctl " David Howells
                   ` (18 subsequent siblings)
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:11 UTC (permalink / raw)
  To: viro
  Cc: Christian Brauner, Greg Kroah-Hartman, Arve Hjønnevåg,
	Todd Kjos, Martijn Coenen, Joel Fernandes, devel, dhowells,
	linux-fsdevel, linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Christian Brauner <christian@brauner.io>
cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
cc: "Arve Hjønnevåg" <arve@android.com>
cc: Todd Kjos <tkjos@android.com>
cc: Martijn Coenen <maco@android.com>
cc: Joel Fernandes <joel@joelfernandes.org>
cc: devel@driverdev.osuosl.org
---

 drivers/android/binderfs.c |  173 ++++++++++++++++++++++++--------------------
 1 file changed, 96 insertions(+), 77 deletions(-)

diff --git a/drivers/android/binderfs.c b/drivers/android/binderfs.c
index e773f45d19d9..0a16ecc9594f 100644
--- a/drivers/android/binderfs.c
+++ b/drivers/android/binderfs.c
@@ -18,7 +18,8 @@
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/mount.h>
-#include <linux/parser.h>
+#include <linux/fs_context.h>
+#include <linux/fs_parser.h>
 #include <linux/radix-tree.h>
 #include <linux/sched.h>
 #include <linux/seq_file.h>
@@ -48,22 +49,18 @@ static dev_t binderfs_dev;
 static DEFINE_MUTEX(binderfs_minors_mutex);
 static DEFINE_IDA(binderfs_minors);
 
-/**
- * binderfs_mount_opts - mount options for binderfs
- * @max: maximum number of allocatable binderfs binder devices
- */
-struct binderfs_mount_opts {
-	int max;
-};
-
 enum {
 	Opt_max,
-	Opt_err
 };
 
-static const match_table_t tokens = {
-	{ Opt_max, "max=%d" },
-	{ Opt_err, NULL     }
+static const struct fs_parameter_spec binderfs_param_specs[] = {
+	fsparam_s32   ("max",	Opt_max),
+	{}
+};
+
+static const struct fs_parameter_description binderfs_fs_parameters = {
+	.name		= "binderfs",
+	.specs		= binderfs_param_specs,
 };
 
 /**
@@ -75,7 +72,7 @@ static const match_table_t tokens = {
  *                  created.
  * @root_gid:       gid that needs to be used when a new binder device is
  *                  created.
- * @mount_opts:     The mount options in use.
+ * @max:	    Maximum number of allocatable binderfs binder devices.
  * @device_count:   The current number of allocated binder devices.
  */
 struct binderfs_info {
@@ -83,7 +80,7 @@ struct binderfs_info {
 	struct dentry *control_dentry;
 	kuid_t root_uid;
 	kgid_t root_gid;
-	struct binderfs_mount_opts mount_opts;
+	int max;
 	int device_count;
 };
 
@@ -138,7 +135,7 @@ static int binderfs_binder_device_create(struct inode *ref_inode,
 
 	/* Reserve new minor number for the new device. */
 	mutex_lock(&binderfs_minors_mutex);
-	if (++info->device_count <= info->mount_opts.max)
+	if (++info->device_count <= info->max)
 		minor = ida_alloc_max(&binderfs_minors,
 				      use_reserve ? BINDERFS_MAX_MINOR :
 						    BINDERFS_MAX_MINOR_CAPPED,
@@ -285,46 +282,36 @@ static void binderfs_evict_inode(struct inode *inode)
 }
 
 /**
- * binderfs_parse_mount_opts - parse binderfs mount options
- * @data: options to set (can be NULL in which case defaults are used)
+ * binderfs_parse_param - parse a binderfs mount option
+ * @fc: The context to be configured
+ * @param: The parameter to apply
  */
-static int binderfs_parse_mount_opts(char *data,
-				     struct binderfs_mount_opts *opts)
+static int binderfs_parse_param(struct fs_context *fc, struct fs_parameter *param)
 {
-	char *p;
-	opts->max = BINDERFS_MAX_MINOR;
-
-	while ((p = strsep(&data, ",")) != NULL) {
-		substring_t args[MAX_OPT_ARGS];
-		int token;
-		int max_devices;
-
-		if (!*p)
-			continue;
-
-		token = match_token(p, tokens, args);
-		switch (token) {
-		case Opt_max:
-			if (match_int(&args[0], &max_devices) ||
-			    (max_devices < 0 ||
-			     (max_devices > BINDERFS_MAX_MINOR)))
-				return -EINVAL;
-
-			opts->max = max_devices;
-			break;
-		default:
-			pr_err("Invalid mount options\n");
-			return -EINVAL;
-		}
+	struct fs_parse_result result;
+	struct binderfs_info *info = fc->s_fs_info;
+	int opt;
+
+	opt = fs_parse(fc, &binderfs_fs_parameters, param, &result);
+	if (opt < 0)
+		return opt;
+
+	switch (opt) {
+	case Opt_max:
+		info->max = result.int_32;
+		break;
 	}
 
 	return 0;
 }
 
-static int binderfs_remount(struct super_block *sb, int *flags, char *data)
+static int binderfs_reconfigure(struct fs_context *fc)
 {
-	struct binderfs_info *info = sb->s_fs_info;
-	return binderfs_parse_mount_opts(data, &info->mount_opts);
+	struct binderfs_info *info = fc->root->d_sb->s_fs_info;
+	struct binderfs_info *cfg = fc->s_fs_info;
+
+	info->max = cfg->max;
+	return 0;
 }
 
 static int binderfs_show_mount_opts(struct seq_file *seq, struct dentry *root)
@@ -332,15 +319,14 @@ static int binderfs_show_mount_opts(struct seq_file *seq, struct dentry *root)
 	struct binderfs_info *info;
 
 	info = root->d_sb->s_fs_info;
-	if (info->mount_opts.max <= BINDERFS_MAX_MINOR)
-		seq_printf(seq, ",max=%d", info->mount_opts.max);
+	if (info->max <= BINDERFS_MAX_MINOR)
+		seq_printf(seq, ",max=%d", info->max);
 
 	return 0;
 }
 
 static const struct super_operations binderfs_super_ops = {
 	.evict_inode    = binderfs_evict_inode,
-	.remount_fs	= binderfs_remount,
 	.show_options	= binderfs_show_mount_opts,
 	.statfs         = simple_statfs,
 };
@@ -462,10 +448,8 @@ static const struct inode_operations binderfs_dir_inode_operations = {
 	.unlink = binderfs_unlink,
 };
 
-static int binderfs_fill_super(struct super_block *sb, void *data, int silent)
+static int binderfs_fill_super(struct super_block *sb, struct fs_context *fc)
 {
-	int ret;
-	struct binderfs_info *info;
 	struct inode *inode = NULL;
 
 	sb->s_blocksize = PAGE_SIZE;
@@ -488,24 +472,6 @@ static int binderfs_fill_super(struct super_block *sb, void *data, int silent)
 	sb->s_op = &binderfs_super_ops;
 	sb->s_time_gran = 1;
 
-	sb->s_fs_info = kzalloc(sizeof(struct binderfs_info), GFP_KERNEL);
-	if (!sb->s_fs_info)
-		return -ENOMEM;
-	info = sb->s_fs_info;
-
-	info->ipc_ns = get_ipc_ns(current->nsproxy->ipc_ns);
-
-	ret = binderfs_parse_mount_opts(data, &info->mount_opts);
-	if (ret)
-		return ret;
-
-	info->root_gid = make_kgid(sb->s_user_ns, 0);
-	if (!gid_valid(info->root_gid))
-		info->root_gid = GLOBAL_ROOT_GID;
-	info->root_uid = make_kuid(sb->s_user_ns, 0);
-	if (!uid_valid(info->root_uid))
-		info->root_uid = GLOBAL_ROOT_UID;
-
 	inode = new_inode(sb);
 	if (!inode)
 		return -ENOMEM;
@@ -524,11 +490,63 @@ static int binderfs_fill_super(struct super_block *sb, void *data, int silent)
 	return binderfs_binder_ctl_create(sb);
 }
 
-static struct dentry *binderfs_mount(struct file_system_type *fs_type,
-				     int flags, const char *dev_name,
-				     void *data)
+static int binderfs_get_tree(struct fs_context *fc)
+{
+	if (!ns_capable(fc->user_ns, CAP_SYS_ADMIN))
+		return -EPERM;
+
+	return vfs_get_super(fc, vfs_get_independent_super, binderfs_fill_super);
+}
+
+static void binderfs_free_fc(struct fs_context *fc)
+{
+	struct binderfs_info *info = fc->s_fs_info;
+
+	if (info) {
+		struct ipc_namespace *ipc_ns = fc->s_fs_info;
+		put_ipc_ns(ipc_ns);
+		kfree(info);
+	}
+}
+
+static const struct fs_context_operations binderfs_context_ops = {
+	.free		= binderfs_free_fc,
+	.parse_param	= binderfs_parse_param,
+	.get_tree	= binderfs_get_tree,
+	.reconfigure	= binderfs_reconfigure,
+};
+
+static int binderfs_init_fs_context(struct fs_context *fc)
 {
-	return mount_nodev(fs_type, flags, data, binderfs_fill_super);
+	struct binderfs_info *info;
+	struct ipc_namespace *ipc_ns = current->nsproxy->ipc_ns;
+	struct user_namespace *user_ns = ipc_ns->user_ns;
+
+	info = kzalloc(sizeof(struct binderfs_info), GFP_KERNEL);
+	if (!info)
+		return -ENOMEM;
+
+	switch (fc->purpose) {
+	case FS_CONTEXT_FOR_MOUNT:
+		put_user_ns(fc->user_ns);
+		fc->user_ns = get_user_ns(user_ns);
+		info->ipc_ns = get_ipc_ns(ipc_ns);
+
+		info->root_gid = make_kgid(user_ns, 0);
+		if (!gid_valid(info->root_gid))
+			info->root_gid = GLOBAL_ROOT_GID;
+		info->root_uid = make_kuid(user_ns, 0);
+		if (!uid_valid(info->root_uid))
+			info->root_uid = GLOBAL_ROOT_UID;
+		break;
+
+	default:
+		break;
+	}
+
+	fc->s_fs_info = info;
+	fc->ops = &binderfs_context_ops;
+	return 0;
 }
 
 static void binderfs_kill_super(struct super_block *sb)
@@ -545,7 +563,8 @@ static void binderfs_kill_super(struct super_block *sb)
 
 static struct file_system_type binder_fs_type = {
 	.name		= "binder",
-	.mount		= binderfs_mount,
+	.init_fs_context = binderfs_init_fs_context,
+	.parameters	= &binderfs_fs_parameters,
 	.kill_sb	= binderfs_kill_super,
 	.fs_flags	= FS_USERNS_MOUNT,
 };


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 20/38] vfs: Convert nfsctl to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (18 preceding siblings ...)
  2019-03-14 16:11 ` [PATCH 19/38] vfs: Convert binderfs to fs_context David Howells
@ 2019-03-14 16:11 ` David Howells
  2019-03-14 17:29   ` J. Bruce Fields
  2019-03-14 16:11 ` [PATCH 21/38] vfs: Convert rpc_pipefs " David Howells
                   ` (17 subsequent siblings)
  37 siblings, 1 reply; 46+ messages in thread
From: David Howells @ 2019-03-14 16:11 UTC (permalink / raw)
  To: viro
  Cc: J. Bruce Fields, Jeff Layton, linux-nfs, dhowells, linux-fsdevel,
	linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: "J. Bruce Fields" <bfields@fieldses.org>
cc: Jeff Layton <jlayton@kernel.org>
cc: linux-nfs@vger.kernel.org
---

 fs/nfsd/nfsctl.c |   33 ++++++++++++++++++++++++++-------
 1 file changed, 26 insertions(+), 7 deletions(-)

diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index f2feb2d11bae..d4eb4f34a94c 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -7,6 +7,7 @@
 #include <linux/slab.h>
 #include <linux/namei.h>
 #include <linux/ctype.h>
+#include <linux/fs_context.h>
 
 #include <linux/sunrpc/svcsock.h>
 #include <linux/lockd/lockd.h>
@@ -1146,7 +1147,7 @@ static ssize_t write_v4_end_grace(struct file *file, char *buf, size_t size)
  *	populating the filesystem.
  */
 
-static int nfsd_fill_super(struct super_block * sb, void * data, int silent)
+static int nfsd_fill_super(struct super_block *sb, struct fs_context *fc)
 {
 	static const struct tree_descr nfsd_files[] = {
 		[NFSD_List] = {"exports", &exports_nfsd_operations, S_IRUGO},
@@ -1176,15 +1177,33 @@ static int nfsd_fill_super(struct super_block * sb, void * data, int silent)
 #endif
 		/* last one */ {""}
 	};
-	get_net(sb->s_fs_info);
+
 	return simple_fill_super(sb, 0x6e667364, nfsd_files);
 }
 
-static struct dentry *nfsd_mount(struct file_system_type *fs_type,
-	int flags, const char *dev_name, void *data)
+static int nfsd_fs_get_tree(struct fs_context *fc)
+{
+	fc->s_fs_info = get_net(fc->net_ns);
+	return vfs_get_super(fc, vfs_get_keyed_super, nfsd_fill_super);
+}
+
+static void nfsd_fs_free_fc(struct fs_context *fc)
+{
+	if (fc->s_fs_info)
+		put_net(fc->s_fs_info);
+}
+
+static const struct fs_context_operations nfsd_fs_context_ops = {
+	.free		= nfsd_fs_free_fc,
+	.get_tree	= nfsd_fs_get_tree,
+};
+
+static int nfsd_init_fs_context(struct fs_context *fc)
 {
-	struct net *net = current->nsproxy->net_ns;
-	return mount_ns(fs_type, flags, data, net, net->user_ns, nfsd_fill_super);
+	put_user_ns(fc->user_ns);
+	fc->user_ns = get_user_ns(fc->net_ns->user_ns);
+	fc->ops = &nfsd_fs_context_ops;
+	return 0;
 }
 
 static void nfsd_umount(struct super_block *sb)
@@ -1198,7 +1217,7 @@ static void nfsd_umount(struct super_block *sb)
 static struct file_system_type nfsd_fs_type = {
 	.owner		= THIS_MODULE,
 	.name		= "nfsd",
-	.mount		= nfsd_mount,
+	.init_fs_context = nfsd_init_fs_context,
 	.kill_sb	= nfsd_umount,
 };
 MODULE_ALIAS_FS("nfsd");


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 21/38] vfs: Convert rpc_pipefs to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (19 preceding siblings ...)
  2019-03-14 16:11 ` [PATCH 20/38] vfs: Convert nfsctl " David Howells
@ 2019-03-14 16:11 ` David Howells
  2019-03-14 16:11 ` [PATCH 22/38] vfs: Kill off mount_ns() David Howells
                   ` (16 subsequent siblings)
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:11 UTC (permalink / raw)
  To: viro
  Cc: Trond Myklebust, Anna Schumaker, J. Bruce Fields, Jeff Layton,
	linux-nfs, dhowells, linux-fsdevel, linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Trond Myklebust <trond.myklebust@hammerspace.com>
cc: Anna Schumaker <anna.schumaker@netapp.com>
cc: "J. Bruce Fields" <bfields@fieldses.org>
cc: Jeff Layton <jlayton@kernel.org>
cc: linux-nfs@vger.kernel.org
---

 net/sunrpc/rpc_pipe.c |   34 ++++++++++++++++++++++++++--------
 1 file changed, 26 insertions(+), 8 deletions(-)

diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 69663681bf9d..2d697861d49a 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -13,6 +13,7 @@
 #include <linux/string.h>
 #include <linux/pagemap.h>
 #include <linux/mount.h>
+#include <linux/fs_context.h>
 #include <linux/namei.h>
 #include <linux/fsnotify.h>
 #include <linux/kernel.h>
@@ -1354,11 +1355,11 @@ rpc_gssd_dummy_depopulate(struct dentry *pipe_dentry)
 }
 
 static int
-rpc_fill_super(struct super_block *sb, void *data, int silent)
+rpc_fill_super(struct super_block *sb, struct fs_context *fc)
 {
 	struct inode *inode;
 	struct dentry *root, *gssd_dentry;
-	struct net *net = get_net(sb->s_fs_info);
+	struct net *net = sb->s_fs_info;
 	struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
 	int err;
 
@@ -1415,12 +1416,29 @@ gssd_running(struct net *net)
 }
 EXPORT_SYMBOL_GPL(gssd_running);
 
-static struct dentry *
-rpc_mount(struct file_system_type *fs_type,
-		int flags, const char *dev_name, void *data)
+static int rpc_fs_get_tree(struct fs_context *fc)
+{
+	fc->s_fs_info = get_net(fc->net_ns);
+	return vfs_get_super(fc, vfs_get_keyed_super, rpc_fill_super);
+}
+
+static void rpc_fs_free_fc(struct fs_context *fc)
 {
-	struct net *net = current->nsproxy->net_ns;
-	return mount_ns(fs_type, flags, data, net, net->user_ns, rpc_fill_super);
+	if (fc->s_fs_info)
+		put_net(fc->s_fs_info);
+}
+
+static const struct fs_context_operations rpc_fs_context_ops = {
+	.free		= rpc_fs_free_fc,
+	.get_tree	= rpc_fs_get_tree,
+};
+
+static int rpc_init_fs_context(struct fs_context *fc)
+{
+	put_user_ns(fc->user_ns);
+	fc->user_ns = get_user_ns(fc->net_ns->user_ns);
+	fc->ops = &rpc_fs_context_ops;
+	return 0;
 }
 
 static void rpc_kill_sb(struct super_block *sb)
@@ -1448,7 +1466,7 @@ static void rpc_kill_sb(struct super_block *sb)
 static struct file_system_type rpc_pipe_fs_type = {
 	.owner		= THIS_MODULE,
 	.name		= "rpc_pipefs",
-	.mount		= rpc_mount,
+	.init_fs_context = rpc_init_fs_context,
 	.kill_sb	= rpc_kill_sb,
 };
 MODULE_ALIAS_FS("rpc_pipefs");


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 22/38] vfs: Kill off mount_ns()
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (20 preceding siblings ...)
  2019-03-14 16:11 ` [PATCH 21/38] vfs: Convert rpc_pipefs " David Howells
@ 2019-03-14 16:11 ` David Howells
  2019-03-14 16:11 ` [PATCH 23/38] vfs: Kill sget_userns() David Howells
                   ` (15 subsequent siblings)
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:11 UTC (permalink / raw)
  To: viro; +Cc: linux-fsdevel, dhowells, linux-fsdevel, linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: linux-fsdevel@vger.kernel.org
---

 fs/super.c         |   44 --------------------------------------------
 include/linux/fs.h |    3 ---
 2 files changed, 47 deletions(-)

diff --git a/fs/super.c b/fs/super.c
index 6c3acd633cca..3b5275298f7c 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -1148,50 +1148,6 @@ void kill_litter_super(struct super_block *sb)
 }
 EXPORT_SYMBOL(kill_litter_super);
 
-static int ns_test_super(struct super_block *sb, void *data)
-{
-	return sb->s_fs_info == data;
-}
-
-static int ns_set_super(struct super_block *sb, void *data)
-{
-	sb->s_fs_info = data;
-	return set_anon_super(sb, NULL);
-}
-
-struct dentry *mount_ns(struct file_system_type *fs_type,
-	int flags, void *data, void *ns, struct user_namespace *user_ns,
-	int (*fill_super)(struct super_block *, void *, int))
-{
-	struct super_block *sb;
-
-	/* Don't allow mounting unless the caller has CAP_SYS_ADMIN
-	 * over the namespace.
-	 */
-	if (!(flags & SB_KERNMOUNT) && !ns_capable(user_ns, CAP_SYS_ADMIN))
-		return ERR_PTR(-EPERM);
-
-	sb = sget_userns(fs_type, ns_test_super, ns_set_super, flags,
-			 user_ns, ns);
-	if (IS_ERR(sb))
-		return ERR_CAST(sb);
-
-	if (!sb->s_root) {
-		int err;
-		err = fill_super(sb, data, flags & SB_SILENT ? 1 : 0);
-		if (err) {
-			deactivate_locked_super(sb);
-			return ERR_PTR(err);
-		}
-
-		sb->s_flags |= SB_ACTIVE;
-	}
-
-	return dget(sb->s_root);
-}
-
-EXPORT_SYMBOL(mount_ns);
-
 int set_anon_super_fc(struct super_block *sb, struct fs_context *fc)
 {
 	return set_anon_super(sb, NULL);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index b738e8e5b096..20c15794c2ac 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2194,9 +2194,6 @@ struct file_system_type {
 
 #define MODULE_ALIAS_FS(NAME) MODULE_ALIAS("fs-" NAME)
 
-extern struct dentry *mount_ns(struct file_system_type *fs_type,
-	int flags, void *data, void *ns, struct user_namespace *user_ns,
-	int (*fill_super)(struct super_block *, void *, int));
 #ifdef CONFIG_BLOCK
 extern struct dentry *mount_bdev(struct file_system_type *fs_type,
 	int flags, const char *dev_name, void *data,


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 23/38] vfs: Kill sget_userns()
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (21 preceding siblings ...)
  2019-03-14 16:11 ` [PATCH 22/38] vfs: Kill off mount_ns() David Howells
@ 2019-03-14 16:11 ` David Howells
  2019-03-14 16:12 ` [PATCH 24/38] vfs: Convert binfmt_misc to fs_context David Howells
                   ` (14 subsequent siblings)
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:11 UTC (permalink / raw)
  To: viro; +Cc: linux-fsdevel, dhowells, linux-fsdevel, linux-kernel

Kill sget_userns(), folding it into sget() as that's the only remaining
user.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: linux-fsdevel@vger.kernel.org
---

 fs/super.c         |   61 +++++++++++++++++-----------------------------------
 include/linux/fs.h |    5 ----
 2 files changed, 20 insertions(+), 46 deletions(-)

diff --git a/fs/super.c b/fs/super.c
index 3b5275298f7c..f27ee08fb26f 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -566,24 +566,35 @@ struct super_block *sget_fc(struct fs_context *fc,
 EXPORT_SYMBOL(sget_fc);
 
 /**
- *	sget_userns -	find or create a superblock
- *	@type:	filesystem type superblock should belong to
- *	@test:	comparison callback
- *	@set:	setup callback
- *	@flags:	mount flags
- *	@user_ns: User namespace for the super_block
- *	@data:	argument to each of them
+ *	sget	-	find or create a superblock
+ *	@type:	  filesystem type superblock should belong to
+ *	@test:	  comparison callback
+ *	@set:	  setup callback
+ *	@flags:	  mount flags
+ *	@data:	  argument to each of them
  */
-struct super_block *sget_userns(struct file_system_type *type,
+struct super_block *sget(struct file_system_type *type,
 			int (*test)(struct super_block *,void *),
 			int (*set)(struct super_block *,void *),
-			int flags, struct user_namespace *user_ns,
+			int flags,
 			void *data)
 {
+	struct user_namespace *user_ns = current_user_ns();
 	struct super_block *s = NULL;
 	struct super_block *old;
 	int err;
 
+	/* We don't yet pass the user namespace of the parent
+	 * mount through to here so always use &init_user_ns
+	 * until that changes.
+	 */
+	if (flags & SB_SUBMOUNT)
+		user_ns = &init_user_ns;
+
+	/* Ensure the requestor has permissions over the target filesystem */
+	if (!(flags & (SB_KERNMOUNT|SB_SUBMOUNT)) && !ns_capable(user_ns, CAP_SYS_ADMIN))
+		return ERR_PTR(-EPERM);
+
 	if (!(flags & (SB_KERNMOUNT|SB_SUBMOUNT)) &&
 	    !(type->fs_flags & FS_USERNS_MOUNT) &&
 	    !capable(CAP_SYS_ADMIN))
@@ -629,38 +640,6 @@ struct super_block *sget_userns(struct file_system_type *type,
 	return s;
 }
 
-EXPORT_SYMBOL(sget_userns);
-
-/**
- *	sget	-	find or create a superblock
- *	@type:	  filesystem type superblock should belong to
- *	@test:	  comparison callback
- *	@set:	  setup callback
- *	@flags:	  mount flags
- *	@data:	  argument to each of them
- */
-struct super_block *sget(struct file_system_type *type,
-			int (*test)(struct super_block *,void *),
-			int (*set)(struct super_block *,void *),
-			int flags,
-			void *data)
-{
-	struct user_namespace *user_ns = current_user_ns();
-
-	/* We don't yet pass the user namespace of the parent
-	 * mount through to here so always use &init_user_ns
-	 * until that changes.
-	 */
-	if (flags & SB_SUBMOUNT)
-		user_ns = &init_user_ns;
-
-	/* Ensure the requestor has permissions over the target filesystem */
-	if (!(flags & (SB_KERNMOUNT|SB_SUBMOUNT)) && !ns_capable(user_ns, CAP_SYS_ADMIN))
-		return ERR_PTR(-EPERM);
-
-	return sget_userns(type, test, set, flags, user_ns, data);
-}
-
 EXPORT_SYMBOL(sget);
 
 void drop_super(struct super_block *sb)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 20c15794c2ac..646f4ccaeee9 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2233,11 +2233,6 @@ void free_anon_bdev(dev_t);
 struct super_block *sget_fc(struct fs_context *fc,
 			    int (*test)(struct super_block *, struct fs_context *),
 			    int (*set)(struct super_block *, struct fs_context *));
-struct super_block *sget_userns(struct file_system_type *type,
-			int (*test)(struct super_block *,void *),
-			int (*set)(struct super_block *,void *),
-			int flags, struct user_namespace *user_ns,
-			void *data);
 struct super_block *sget(struct file_system_type *type,
 			int (*test)(struct super_block *,void *),
 			int (*set)(struct super_block *,void *),


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 24/38] vfs: Convert binfmt_misc to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (22 preceding siblings ...)
  2019-03-14 16:11 ` [PATCH 23/38] vfs: Kill sget_userns() David Howells
@ 2019-03-14 16:12 ` David Howells
  2019-03-14 16:12 ` [PATCH 25/38] vfs: Convert configfs " David Howells
                   ` (13 subsequent siblings)
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:12 UTC (permalink / raw)
  To: viro; +Cc: linux-fsdevel, dhowells, linux-fsdevel, linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Alexander Viro <viro@zeniv.linux.org.uk>
cc: linux-fsdevel@vger.kernel.org
---

 fs/binfmt_misc.c |   20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index aa4a7a23ff99..0c32e59bfd20 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -22,6 +22,7 @@
 #include <linux/pagemap.h>
 #include <linux/namei.h>
 #include <linux/mount.h>
+#include <linux/fs_context.h>
 #include <linux/syscalls.h>
 #include <linux/fs.h>
 #include <linux/uaccess.h>
@@ -820,7 +821,7 @@ static const struct super_operations s_ops = {
 	.evict_inode	= bm_evict_inode,
 };
 
-static int bm_fill_super(struct super_block *sb, void *data, int silent)
+static int bm_fill_super(struct super_block *sb, struct fs_context *fc)
 {
 	int err;
 	static const struct tree_descr bm_files[] = {
@@ -835,10 +836,19 @@ static int bm_fill_super(struct super_block *sb, void *data, int silent)
 	return err;
 }
 
-static struct dentry *bm_mount(struct file_system_type *fs_type,
-	int flags, const char *dev_name, void *data)
+static int bm_get_tree(struct fs_context *fc)
 {
-	return mount_single(fs_type, flags, data, bm_fill_super);
+	return vfs_get_super(fc, vfs_get_single_super, bm_fill_super);
+}
+
+static const struct fs_context_operations bm_context_ops = {
+	.get_tree	= bm_get_tree,
+};
+
+static int bm_init_fs_context(struct fs_context *fc)
+{
+	fc->ops = &bm_context_ops;
+	return 0;
 }
 
 static struct linux_binfmt misc_format = {
@@ -849,7 +859,7 @@ static struct linux_binfmt misc_format = {
 static struct file_system_type bm_fs_type = {
 	.owner		= THIS_MODULE,
 	.name		= "binfmt_misc",
-	.mount		= bm_mount,
+	.init_fs_context = bm_init_fs_context,
 	.kill_sb	= kill_litter_super,
 };
 MODULE_ALIAS_FS("binfmt_misc");


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 25/38] vfs: Convert configfs to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (23 preceding siblings ...)
  2019-03-14 16:12 ` [PATCH 24/38] vfs: Convert binfmt_misc to fs_context David Howells
@ 2019-03-14 16:12 ` David Howells
  2019-03-14 16:12 ` [PATCH 26/38] vfs: Convert efivarfs " David Howells
                   ` (12 subsequent siblings)
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:12 UTC (permalink / raw)
  To: viro
  Cc: Joel Becker, Christoph Hellwig, dhowells, linux-fsdevel, linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Joel Becker <jlbec@evilplan.org>
cc: Christoph Hellwig <hch@lst.de>
---

 fs/configfs/mount.c |   20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/fs/configfs/mount.c b/fs/configfs/mount.c
index cfd91320e869..af4db09f46b4 100644
--- a/fs/configfs/mount.c
+++ b/fs/configfs/mount.c
@@ -27,6 +27,7 @@
 #include <linux/fs.h>
 #include <linux/module.h>
 #include <linux/mount.h>
+#include <linux/fs_context.h>
 #include <linux/pagemap.h>
 #include <linux/init.h>
 #include <linux/slab.h>
@@ -66,7 +67,7 @@ static struct configfs_dirent configfs_root = {
 	.s_iattr	= NULL,
 };
 
-static int configfs_fill_super(struct super_block *sb, void *data, int silent)
+static int configfs_fill_super(struct super_block *sb, struct fs_context *fc)
 {
 	struct inode *inode;
 	struct dentry *root;
@@ -102,16 +103,25 @@ static int configfs_fill_super(struct super_block *sb, void *data, int silent)
 	return 0;
 }
 
-static struct dentry *configfs_do_mount(struct file_system_type *fs_type,
-	int flags, const char *dev_name, void *data)
+static int configfs_get_tree(struct fs_context *fc)
 {
-	return mount_single(fs_type, flags, data, configfs_fill_super);
+	return vfs_get_super(fc, vfs_get_single_super, configfs_fill_super);
+}
+
+static const struct fs_context_operations configfs_context_ops = {
+	.get_tree	= configfs_get_tree,
+};
+
+static int configfs_init_fs_context(struct fs_context *fc)
+{
+	fc->ops = &configfs_context_ops;
+	return 0;
 }
 
 static struct file_system_type configfs_fs_type = {
 	.owner		= THIS_MODULE,
 	.name		= "configfs",
-	.mount		= configfs_do_mount,
+	.init_fs_context = configfs_init_fs_context,
 	.kill_sb	= kill_litter_super,
 };
 MODULE_ALIAS_FS("configfs");


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 26/38] vfs: Convert efivarfs to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (24 preceding siblings ...)
  2019-03-14 16:12 ` [PATCH 25/38] vfs: Convert configfs " David Howells
@ 2019-03-14 16:12 ` David Howells
  2019-03-14 16:12 ` [PATCH 27/38] vfs: Convert fusectl " David Howells
                   ` (11 subsequent siblings)
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:12 UTC (permalink / raw)
  To: viro
  Cc: Matthew Garrett, Jeremy Kerr, Ard Biesheuvel, linux-efi,
	dhowells, linux-fsdevel, linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Matthew Garrett <matthew.garrett@nebula.com>
cc: Jeremy Kerr <jk@ozlabs.org>
cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
cc: linux-efi@vger.kernel.org
---

 fs/efivarfs/super.c |   20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c
index 5b68e4294faa..1ea25c7a329a 100644
--- a/fs/efivarfs/super.c
+++ b/fs/efivarfs/super.c
@@ -10,6 +10,7 @@
 #include <linux/ctype.h>
 #include <linux/efi.h>
 #include <linux/fs.h>
+#include <linux/fs_context.h>
 #include <linux/module.h>
 #include <linux/pagemap.h>
 #include <linux/ucs2_string.h>
@@ -191,7 +192,7 @@ static int efivarfs_destroy(struct efivar_entry *entry, void *data)
 	return 0;
 }
 
-static int efivarfs_fill_super(struct super_block *sb, void *data, int silent)
+static int efivarfs_fill_super(struct super_block *sb, struct fs_context *fc)
 {
 	struct inode *inode = NULL;
 	struct dentry *root;
@@ -226,10 +227,19 @@ static int efivarfs_fill_super(struct super_block *sb, void *data, int silent)
 	return err;
 }
 
-static struct dentry *efivarfs_mount(struct file_system_type *fs_type,
-				    int flags, const char *dev_name, void *data)
+static int efivarfs_get_tree(struct fs_context *fc)
 {
-	return mount_single(fs_type, flags, data, efivarfs_fill_super);
+	return vfs_get_super(fc, vfs_get_single_super, efivarfs_fill_super);
+}
+
+static const struct fs_context_operations efivarfs_context_ops = {
+	.get_tree	= efivarfs_get_tree,
+};
+
+static int efivarfs_init_fs_context(struct fs_context *fc)
+{
+	fc->ops = &efivarfs_context_ops;
+	return 0;
 }
 
 static void efivarfs_kill_sb(struct super_block *sb)
@@ -244,7 +254,7 @@ static void efivarfs_kill_sb(struct super_block *sb)
 static struct file_system_type efivarfs_type = {
 	.owner   = THIS_MODULE,
 	.name    = "efivarfs",
-	.mount   = efivarfs_mount,
+	.init_fs_context = efivarfs_init_fs_context,
 	.kill_sb = efivarfs_kill_sb,
 };
 


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 27/38] vfs: Convert fusectl to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (25 preceding siblings ...)
  2019-03-14 16:12 ` [PATCH 26/38] vfs: Convert efivarfs " David Howells
@ 2019-03-14 16:12 ` David Howells
  2019-03-14 16:12 ` [PATCH 28/38] vfs: Convert qib_fs/ipathfs " David Howells
                   ` (10 subsequent siblings)
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:12 UTC (permalink / raw)
  To: viro; +Cc: Miklos Szeredi, linux-fsdevel, dhowells, linux-fsdevel, linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Miklos Szeredi <miklos@szeredi.hu>
cc: linux-fsdevel@vger.kernel.org
---

 fs/fuse/control.c |   20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/fs/fuse/control.c b/fs/fuse/control.c
index fe80bea4ad89..14ce1e47f980 100644
--- a/fs/fuse/control.c
+++ b/fs/fuse/control.c
@@ -10,6 +10,7 @@
 
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/fs_context.h>
 
 #define FUSE_CTL_SUPER_MAGIC 0x65735543
 
@@ -317,7 +318,7 @@ void fuse_ctl_remove_conn(struct fuse_conn *fc)
 	drop_nlink(d_inode(fuse_control_sb->s_root));
 }
 
-static int fuse_ctl_fill_super(struct super_block *sb, void *data, int silent)
+static int fuse_ctl_fill_super(struct super_block *sb, struct fs_context *fctx)
 {
 	static const struct tree_descr empty_descr = {""};
 	struct fuse_conn *fc;
@@ -343,10 +344,19 @@ static int fuse_ctl_fill_super(struct super_block *sb, void *data, int silent)
 	return 0;
 }
 
-static struct dentry *fuse_ctl_mount(struct file_system_type *fs_type,
-			int flags, const char *dev_name, void *raw_data)
+static int fuse_ctl_get_tree(struct fs_context *fc)
 {
-	return mount_single(fs_type, flags, raw_data, fuse_ctl_fill_super);
+	return vfs_get_super(fc, vfs_get_single_super, fuse_ctl_fill_super);
+}
+
+static const struct fs_context_operations fuse_ctl_context_ops = {
+	.get_tree	= fuse_ctl_get_tree,
+};
+
+static int fuse_ctl_init_fs_context(struct fs_context *fc)
+{
+	fc->ops = &fuse_ctl_context_ops;
+	return 0;
 }
 
 static void fuse_ctl_kill_sb(struct super_block *sb)
@@ -365,7 +375,7 @@ static void fuse_ctl_kill_sb(struct super_block *sb)
 static struct file_system_type fuse_ctl_fs_type = {
 	.owner		= THIS_MODULE,
 	.name		= "fusectl",
-	.mount		= fuse_ctl_mount,
+	.init_fs_context = fuse_ctl_init_fs_context,
 	.kill_sb	= fuse_ctl_kill_sb,
 };
 MODULE_ALIAS_FS("fusectl");


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 28/38] vfs: Convert qib_fs/ipathfs to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (26 preceding siblings ...)
  2019-03-14 16:12 ` [PATCH 27/38] vfs: Convert fusectl " David Howells
@ 2019-03-14 16:12 ` David Howells
  2019-03-14 16:12 ` [PATCH 29/38] vfs: Convert ibmasmfs " David Howells
                   ` (9 subsequent siblings)
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:12 UTC (permalink / raw)
  To: viro
  Cc: Dennis Dalessandro, Mike Marciniszyn, linux-rdma, dhowells,
	linux-fsdevel, linux-kernel

[Q] Can qib_remove() race with qibfs_kill_super()?  Should qib_super
    accesses be serialised with some sort of lock?

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Dennis Dalessandro <dennis.dalessandro@intel.com>
cc: Mike Marciniszyn <mike.marciniszyn@intel.com>
cc: linux-rdma@vger.kernel.org
---

 drivers/infiniband/hw/qib/qib_fs.c |   26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/drivers/infiniband/hw/qib/qib_fs.c b/drivers/infiniband/hw/qib/qib_fs.c
index 1d940a2885c9..fc4f62a248a1 100644
--- a/drivers/infiniband/hw/qib/qib_fs.c
+++ b/drivers/infiniband/hw/qib/qib_fs.c
@@ -34,6 +34,7 @@
 
 #include <linux/module.h>
 #include <linux/fs.h>
+#include <linux/fs_context.h>
 #include <linux/mount.h>
 #include <linux/pagemap.h>
 #include <linux/init.h>
@@ -506,7 +507,7 @@ static int remove_device_files(struct super_block *sb,
  * after device init.  The direct add_cntr_files() call handles adding
  * them from the init code, when the fs is already mounted.
  */
-static int qibfs_fill_super(struct super_block *sb, void *data, int silent)
+static int qibfs_fill_super(struct super_block *sb, struct fs_context *fc)
 {
 	struct qib_devdata *dd, *tmp;
 	unsigned long flags;
@@ -540,17 +541,26 @@ static int qibfs_fill_super(struct super_block *sb, void *data, int silent)
 	return ret;
 }
 
-static struct dentry *qibfs_mount(struct file_system_type *fs_type, int flags,
-			const char *dev_name, void *data)
+static int qibfs_get_tree(struct fs_context *fc)
 {
-	struct dentry *ret;
+	int ret;
 
-	ret = mount_single(fs_type, flags, data, qibfs_fill_super);
-	if (!IS_ERR(ret))
-		qib_super = ret->d_sb;
+	ret = vfs_get_super(fc, vfs_get_single_super, qibfs_fill_super);
+	if (ret == 0)
+		qib_super = fc->root->d_sb;
 	return ret;
 }
 
+static const struct fs_context_operations qibfs_context_ops = {
+	.get_tree	= qibfs_get_tree,
+};
+
+static int qibfs_init_fs_context(struct fs_context *fc)
+{
+	fc->ops = &qibfs_context_ops;
+	return 0;
+}
+
 static void qibfs_kill_super(struct super_block *s)
 {
 	kill_litter_super(s);
@@ -589,7 +599,7 @@ int qibfs_remove(struct qib_devdata *dd)
 static struct file_system_type qibfs_fs_type = {
 	.owner =        THIS_MODULE,
 	.name =         "ipathfs",
-	.mount =        qibfs_mount,
+	.init_fs_context = qibfs_init_fs_context,
 	.kill_sb =      qibfs_kill_super,
 };
 MODULE_ALIAS_FS("ipathfs");


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 29/38] vfs: Convert ibmasmfs to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (27 preceding siblings ...)
  2019-03-14 16:12 ` [PATCH 28/38] vfs: Convert qib_fs/ipathfs " David Howells
@ 2019-03-14 16:12 ` David Howells
  2019-03-14 16:12 ` [PATCH 30/38] vfs: Convert oprofilefs " David Howells
                   ` (8 subsequent siblings)
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:12 UTC (permalink / raw)
  To: viro
  Cc: Arnd Bergmann, Greg Kroah-Hartman, dhowells, linux-fsdevel, linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Arnd Bergmann <arnd@arndb.de>
cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---

 drivers/misc/ibmasm/ibmasmfs.c |   21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/misc/ibmasm/ibmasmfs.c b/drivers/misc/ibmasm/ibmasmfs.c
index fa840666bdd1..e615f335db99 100644
--- a/drivers/misc/ibmasm/ibmasmfs.c
+++ b/drivers/misc/ibmasm/ibmasmfs.c
@@ -74,6 +74,7 @@
  */
 
 #include <linux/fs.h>
+#include <linux/fs_context.h>
 #include <linux/pagemap.h>
 #include <linux/slab.h>
 #include <linux/uaccess.h>
@@ -88,13 +89,21 @@ static LIST_HEAD(service_processors);
 
 static struct inode *ibmasmfs_make_inode(struct super_block *sb, int mode);
 static void ibmasmfs_create_files (struct super_block *sb);
-static int ibmasmfs_fill_super (struct super_block *sb, void *data, int silent);
+static int ibmasmfs_fill_super(struct super_block *sb, struct fs_context *fc);
 
+static int ibmasmfs_get_tree(struct fs_context *fc)
+{
+	return vfs_get_super(fc, vfs_get_single_super, ibmasmfs_fill_super);
+}
 
-static struct dentry *ibmasmfs_mount(struct file_system_type *fst,
-			int flags, const char *name, void *data)
+static const struct fs_context_operations ibmasmfs_context_ops = {
+	.get_tree	= ibmasmfs_get_tree,
+};
+
+static int ibmasmfs_init_fs_context(struct fs_context *fc)
 {
-	return mount_single(fst, flags, data, ibmasmfs_fill_super);
+	fc->ops = &ibmasmfs_context_ops;
+	return 0;
 }
 
 static const struct super_operations ibmasmfs_s_ops = {
@@ -107,12 +116,12 @@ static const struct file_operations *ibmasmfs_dir_ops = &simple_dir_operations;
 static struct file_system_type ibmasmfs_type = {
 	.owner          = THIS_MODULE,
 	.name           = "ibmasmfs",
-	.mount          = ibmasmfs_mount,
+	.init_fs_context = ibmasmfs_init_fs_context,
 	.kill_sb        = kill_litter_super,
 };
 MODULE_ALIAS_FS("ibmasmfs");
 
-static int ibmasmfs_fill_super (struct super_block *sb, void *data, int silent)
+static int ibmasmfs_fill_super(struct super_block *sb, struct fs_context *fc)
 {
 	struct inode *root;
 


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 30/38] vfs: Convert oprofilefs to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (28 preceding siblings ...)
  2019-03-14 16:12 ` [PATCH 29/38] vfs: Convert ibmasmfs " David Howells
@ 2019-03-14 16:12 ` David Howells
  2019-03-14 16:13 ` [PATCH 31/38] vfs: Convert gadgetfs " David Howells
                   ` (7 subsequent siblings)
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:12 UTC (permalink / raw)
  To: viro; +Cc: Robert Richter, oprofile-list, dhowells, linux-fsdevel, linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Robert Richter <rric@kernel.org>
cc: oprofile-list@lists.sf.net
---

 drivers/oprofile/oprofilefs.c |   20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
index 4ea08979312c..d83fcd39ee55 100644
--- a/drivers/oprofile/oprofilefs.c
+++ b/drivers/oprofile/oprofilefs.c
@@ -14,6 +14,7 @@
 #include <linux/module.h>
 #include <linux/oprofile.h>
 #include <linux/fs.h>
+#include <linux/fs_context.h>
 #include <linux/pagemap.h>
 #include <linux/uaccess.h>
 
@@ -238,7 +239,7 @@ struct dentry *oprofilefs_mkdir(struct dentry *parent, char const *name)
 }
 
 
-static int oprofilefs_fill_super(struct super_block *sb, void *data, int silent)
+static int oprofilefs_fill_super(struct super_block *sb, struct fs_context *fc)
 {
 	struct inode *root_inode;
 
@@ -263,18 +264,25 @@ static int oprofilefs_fill_super(struct super_block *sb, void *data, int silent)
 	return 0;
 }
 
-
-static struct dentry *oprofilefs_mount(struct file_system_type *fs_type,
-	int flags, const char *dev_name, void *data)
+static int oprofilefs_get_tree(struct fs_context *fc)
 {
-	return mount_single(fs_type, flags, data, oprofilefs_fill_super);
+	return vfs_get_super(fc, vfs_get_single_super, oprofilefs_fill_super);
 }
 
+static const struct fs_context_operations oprofilefs_context_ops = {
+	.get_tree	= oprofilefs_get_tree,
+};
+
+static int oprofilefs_init_fs_context(struct fs_context *fc)
+{
+	fc->ops = &oprofilefs_context_ops;
+	return 0;
+}
 
 static struct file_system_type oprofilefs_type = {
 	.owner		= THIS_MODULE,
 	.name		= "oprofilefs",
-	.mount		= oprofilefs_mount,
+	.init_fs_context = oprofilefs_init_fs_context,
 	.kill_sb	= kill_litter_super,
 };
 MODULE_ALIAS_FS("oprofilefs");


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 31/38] vfs: Convert gadgetfs to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (29 preceding siblings ...)
  2019-03-14 16:12 ` [PATCH 30/38] vfs: Convert oprofilefs " David Howells
@ 2019-03-14 16:13 ` David Howells
  2019-03-20  6:57   ` Felipe Balbi
  2019-03-20  7:42   ` David Howells
  2019-03-14 16:13 ` [PATCH 32/38] vfs: Convert xenfs " David Howells
                   ` (6 subsequent siblings)
  37 siblings, 2 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:13 UTC (permalink / raw)
  To: viro; +Cc: Felipe Balbi, linux-usb, dhowells, linux-fsdevel, linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Felipe Balbi <balbi@kernel.org>
cc: linux-usb@vger.kernel.org
---

 drivers/usb/gadget/legacy/inode.c |   21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
index 249277d0e53f..441da16ffc39 100644
--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -12,6 +12,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/fs.h>
+#include <linux/fs_context.h>
 #include <linux/pagemap.h>
 #include <linux/uts.h>
 #include <linux/wait.h>
@@ -1990,7 +1991,7 @@ static const struct super_operations gadget_fs_operations = {
 };
 
 static int
-gadgetfs_fill_super (struct super_block *sb, void *opts, int silent)
+gadgetfs_fill_super (struct super_block *sb, struct fs_context *fc)
 {
 	struct inode	*inode;
 	struct dev_data	*dev;
@@ -2044,11 +2045,19 @@ gadgetfs_fill_super (struct super_block *sb, void *opts, int silent)
 }
 
 /* "mount -t gadgetfs path /dev/gadget" ends up here */
-static struct dentry *
-gadgetfs_mount (struct file_system_type *t, int flags,
-		const char *path, void *opts)
+static int gadgetfs_get_tree(struct fs_context *fc)
 {
-	return mount_single (t, flags, opts, gadgetfs_fill_super);
+	return vfs_get_super(fc, vfs_get_single_super, gadgetfs_fill_super);
+}
+
+static const struct fs_context_operations gadgetfs_context_ops = {
+	.get_tree	= gadgetfs_get_tree,
+};
+
+static int gadgetfs_init_fs_context(struct fs_context *fc)
+{
+	fc->ops = &gadgetfs_context_ops;
+	return 0;
 }
 
 static void
@@ -2068,7 +2077,7 @@ gadgetfs_kill_sb (struct super_block *sb)
 static struct file_system_type gadgetfs_type = {
 	.owner		= THIS_MODULE,
 	.name		= shortname,
-	.mount		= gadgetfs_mount,
+	.init_fs_context = gadgetfs_init_fs_context,
 	.kill_sb	= gadgetfs_kill_sb,
 };
 MODULE_ALIAS_FS("gadgetfs");


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 32/38] vfs: Convert xenfs to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (30 preceding siblings ...)
  2019-03-14 16:13 ` [PATCH 31/38] vfs: Convert gadgetfs " David Howells
@ 2019-03-14 16:13 ` David Howells
  2019-03-14 16:13 ` [PATCH 33/38] vfs: Convert openpromfs " David Howells
                   ` (5 subsequent siblings)
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:13 UTC (permalink / raw)
  To: viro
  Cc: Boris Ostrovsky, Juergen Gross, Stefano Stabellini, xen-devel,
	dhowells, linux-fsdevel, linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
cc: Juergen Gross <jgross@suse.com>
cc: Stefano Stabellini <sstabellini@kernel.org>
cc: xen-devel@lists.xenproject.org
---

 drivers/xen/xenfs/super.c |   21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/xen/xenfs/super.c b/drivers/xen/xenfs/super.c
index 71ddfb4cf61c..2e16214e9c7f 100644
--- a/drivers/xen/xenfs/super.c
+++ b/drivers/xen/xenfs/super.c
@@ -13,6 +13,7 @@
 #include <linux/errno.h>
 #include <linux/module.h>
 #include <linux/fs.h>
+#include <linux/fs_context.h>
 #include <linux/magic.h>
 
 #include <xen/xen.h>
@@ -42,7 +43,7 @@ static const struct file_operations capabilities_file_ops = {
 	.llseek = default_llseek,
 };
 
-static int xenfs_fill_super(struct super_block *sb, void *data, int silent)
+static int xenfs_fill_super(struct super_block *sb, struct fs_context *fc)
 {
 	static const struct tree_descr xenfs_files[] = {
 		[2] = { "xenbus", &xen_xenbus_fops, S_IRUSR|S_IWUSR },
@@ -67,17 +68,25 @@ static int xenfs_fill_super(struct super_block *sb, void *data, int silent)
 			xen_initial_domain() ? xenfs_init_files : xenfs_files);
 }
 
-static struct dentry *xenfs_mount(struct file_system_type *fs_type,
-				  int flags, const char *dev_name,
-				  void *data)
+static int xenfs_get_tree(struct fs_context *fc)
 {
-	return mount_single(fs_type, flags, data, xenfs_fill_super);
+	return vfs_get_super(fc, vfs_get_single_super, xenfs_fill_super);
+}
+
+static const struct fs_context_operations xenfs_context_ops = {
+	.get_tree	= xenfs_get_tree,
+};
+
+static int xenfs_init_fs_context(struct fs_context *fc)
+{
+	fc->ops = &xenfs_context_ops;
+	return 0;
 }
 
 static struct file_system_type xenfs_type = {
 	.owner =	THIS_MODULE,
 	.name =		"xenfs",
-	.mount =	xenfs_mount,
+	.init_fs_context = xenfs_init_fs_context,
 	.kill_sb =	kill_litter_super,
 };
 MODULE_ALIAS_FS("xenfs");


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 33/38] vfs: Convert openpromfs to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (31 preceding siblings ...)
  2019-03-14 16:13 ` [PATCH 32/38] vfs: Convert xenfs " David Howells
@ 2019-03-14 16:13 ` David Howells
  2019-03-14 16:13 ` [PATCH 34/38] vfs: Convert apparmorfs " David Howells
                   ` (4 subsequent siblings)
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:13 UTC (permalink / raw)
  To: viro; +Cc: dhowells, linux-fsdevel, linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
---

 fs/openpromfs/inode.c |   20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/fs/openpromfs/inode.c b/fs/openpromfs/inode.c
index 1b2d0d2fe2ee..7ec384df0109 100644
--- a/fs/openpromfs/inode.c
+++ b/fs/openpromfs/inode.c
@@ -8,6 +8,7 @@
 #include <linux/types.h>
 #include <linux/string.h>
 #include <linux/fs.h>
+#include <linux/fs_context.h>
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/seq_file.h>
@@ -380,7 +381,7 @@ static const struct super_operations openprom_sops = {
 	.remount_fs	= openprom_remount,
 };
 
-static int openprom_fill_super(struct super_block *s, void *data, int silent)
+static int openprom_fill_super(struct super_block *s, struct fs_context *fc)
 {
 	struct inode *root_inode;
 	struct op_inode_info *oi;
@@ -414,16 +415,25 @@ static int openprom_fill_super(struct super_block *s, void *data, int silent)
 	return ret;
 }
 
-static struct dentry *openprom_mount(struct file_system_type *fs_type,
-	int flags, const char *dev_name, void *data)
+static int openpromfs_get_tree(struct fs_context *fc)
 {
-	return mount_single(fs_type, flags, data, openprom_fill_super);
+	return vfs_get_super(fc, vfs_get_single_super, openprom_fill_super);
+}
+
+static const struct fs_context_operations openpromfs_context_ops = {
+	.get_tree	= openpromfs_get_tree,
+};
+
+static int openpromfs_init_fs_context(struct fs_context *fc)
+{
+	fc->ops = &openpromfs_context_ops;
+	return 0;
 }
 
 static struct file_system_type openprom_fs_type = {
 	.owner		= THIS_MODULE,
 	.name		= "openpromfs",
-	.mount		= openprom_mount,
+	.init_fs_context = openpromfs_init_fs_context,
 	.kill_sb	= kill_anon_super,
 };
 MODULE_ALIAS_FS("openpromfs");


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 34/38] vfs: Convert apparmorfs to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (32 preceding siblings ...)
  2019-03-14 16:13 ` [PATCH 33/38] vfs: Convert openpromfs " David Howells
@ 2019-03-14 16:13 ` David Howells
  2019-03-14 16:13 ` [PATCH 35/38] vfs: Convert securityfs " David Howells
                   ` (3 subsequent siblings)
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:13 UTC (permalink / raw)
  To: viro
  Cc: John Johansen, apparmor, linux-security-module, dhowells,
	linux-fsdevel, linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: John Johansen <john.johansen@canonical.com>
cc: apparmor@lists.ubuntu.com
cc: linux-security-module@vger.kernel.org
---

 security/apparmor/apparmorfs.c |   20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
index fefee040bf79..75f7da0e5ec1 100644
--- a/security/apparmor/apparmorfs.c
+++ b/security/apparmor/apparmorfs.c
@@ -23,6 +23,7 @@
 #include <linux/capability.h>
 #include <linux/rcupdate.h>
 #include <linux/fs.h>
+#include <linux/fs_context.h>
 #include <linux/poll.h>
 #include <uapi/linux/major.h>
 #include <uapi/linux/magic.h>
@@ -137,7 +138,7 @@ static const struct super_operations aafs_super_ops = {
 	.show_path = aafs_show_path,
 };
 
-static int fill_super(struct super_block *sb, void *data, int silent)
+static int apparmorfs_fill_super(struct super_block *sb, struct fs_context *fc)
 {
 	static struct tree_descr files[] = { {""} };
 	int error;
@@ -150,16 +151,25 @@ static int fill_super(struct super_block *sb, void *data, int silent)
 	return 0;
 }
 
-static struct dentry *aafs_mount(struct file_system_type *fs_type,
-				 int flags, const char *dev_name, void *data)
+static int apparmorfs_get_tree(struct fs_context *fc)
 {
-	return mount_single(fs_type, flags, data, fill_super);
+	return vfs_get_super(fc, vfs_get_single_super, apparmorfs_fill_super);
+}
+
+static const struct fs_context_operations apparmorfs_context_ops = {
+	.get_tree	= apparmorfs_get_tree,
+};
+
+static int apparmorfs_init_fs_context(struct fs_context *fc)
+{
+	fc->ops = &apparmorfs_context_ops;
+	return 0;
 }
 
 static struct file_system_type aafs_ops = {
 	.owner = THIS_MODULE,
 	.name = AAFS_NAME,
-	.mount = aafs_mount,
+	.init_fs_context = apparmorfs_init_fs_context,
 	.kill_sb = kill_anon_super,
 };
 


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 35/38] vfs: Convert securityfs to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (33 preceding siblings ...)
  2019-03-14 16:13 ` [PATCH 34/38] vfs: Convert apparmorfs " David Howells
@ 2019-03-14 16:13 ` David Howells
  2019-03-14 16:13 ` [PATCH 36/38] vfs: Convert selinuxfs " David Howells
                   ` (2 subsequent siblings)
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:13 UTC (permalink / raw)
  To: viro; +Cc: linux-security-module, dhowells, linux-fsdevel, linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: linux-security-module@vger.kernel.org
---

 security/inode.c |   21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/security/inode.c b/security/inode.c
index b7772a9b315e..4fecbc8b072a 100644
--- a/security/inode.c
+++ b/security/inode.c
@@ -16,6 +16,7 @@
 #include <linux/sysfs.h>
 #include <linux/kobject.h>
 #include <linux/fs.h>
+#include <linux/fs_context.h>
 #include <linux/mount.h>
 #include <linux/pagemap.h>
 #include <linux/init.h>
@@ -40,7 +41,7 @@ static const struct super_operations securityfs_super_operations = {
 	.evict_inode	= securityfs_evict_inode,
 };
 
-static int fill_super(struct super_block *sb, void *data, int silent)
+static int securityfs_fill_super(struct super_block *sb, struct fs_context *fc)
 {
 	static const struct tree_descr files[] = {{""}};
 	int error;
@@ -54,17 +55,25 @@ static int fill_super(struct super_block *sb, void *data, int silent)
 	return 0;
 }
 
-static struct dentry *get_sb(struct file_system_type *fs_type,
-		  int flags, const char *dev_name,
-		  void *data)
+static int securityfs_get_tree(struct fs_context *fc)
 {
-	return mount_single(fs_type, flags, data, fill_super);
+	return vfs_get_super(fc, vfs_get_single_super, securityfs_fill_super);
+}
+
+static const struct fs_context_operations securityfs_context_ops = {
+	.get_tree	= securityfs_get_tree,
+};
+
+static int securityfs_init_fs_context(struct fs_context *fc)
+{
+	fc->ops = &securityfs_context_ops;
+	return 0;
 }
 
 static struct file_system_type fs_type = {
 	.owner =	THIS_MODULE,
 	.name =		"securityfs",
-	.mount =	get_sb,
+	.init_fs_context = securityfs_init_fs_context,
 	.kill_sb =	kill_litter_super,
 };
 


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 36/38] vfs: Convert selinuxfs to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (34 preceding siblings ...)
  2019-03-14 16:13 ` [PATCH 35/38] vfs: Convert securityfs " David Howells
@ 2019-03-14 16:13 ` David Howells
  2019-03-14 16:13 ` [PATCH 37/38] vfs: Convert smackfs " David Howells
  2019-03-14 16:13 ` [PATCH 38/38] tmpfs, devtmpfs, ramfs, rootfs: Convert " David Howells
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:13 UTC (permalink / raw)
  To: viro
  Cc: Paul Moore, Stephen Smalley, Eric Paris, selinux,
	linux-security-module, dhowells, linux-fsdevel, linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Paul Moore <paul@paul-moore.com>
cc: Stephen Smalley <sds@tycho.nsa.gov>
cc: Eric Paris <eparis@parisplace.org>
cc: selinux@vger.kernel.org
cc: linux-security-module@vger.kernel.org
---

 security/selinux/selinuxfs.c |   20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index 145ee62f205a..ccfe86dfa784 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -19,6 +19,7 @@
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/fs.h>
+#include <linux/fs_context.h>
 #include <linux/mount.h>
 #include <linux/mutex.h>
 #include <linux/init.h>
@@ -1893,7 +1894,7 @@ static struct dentry *sel_make_dir(struct dentry *dir, const char *name,
 
 #define NULL_FILE_NAME "null"
 
-static int sel_fill_super(struct super_block *sb, void *data, int silent)
+static int sel_fill_super(struct super_block *sb, struct fs_context *fc)
 {
 	struct selinux_fs_info *fsi;
 	int ret;
@@ -2009,10 +2010,19 @@ static int sel_fill_super(struct super_block *sb, void *data, int silent)
 	return ret;
 }
 
-static struct dentry *sel_mount(struct file_system_type *fs_type,
-		      int flags, const char *dev_name, void *data)
+static int sel_get_tree(struct fs_context *fc)
 {
-	return mount_single(fs_type, flags, data, sel_fill_super);
+	return vfs_get_super(fc, vfs_get_single_super, sel_fill_super);
+}
+
+static const struct fs_context_operations sel_context_ops = {
+	.get_tree	= sel_get_tree,
+};
+
+static int sel_init_fs_context(struct fs_context *fc)
+{
+	fc->ops = &sel_context_ops;
+	return 0;
 }
 
 static void sel_kill_sb(struct super_block *sb)
@@ -2023,7 +2033,7 @@ static void sel_kill_sb(struct super_block *sb)
 
 static struct file_system_type sel_fs_type = {
 	.name		= "selinuxfs",
-	.mount		= sel_mount,
+	.init_fs_context = sel_init_fs_context,
 	.kill_sb	= sel_kill_sb,
 };
 


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 37/38] vfs: Convert smackfs to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (35 preceding siblings ...)
  2019-03-14 16:13 ` [PATCH 36/38] vfs: Convert selinuxfs " David Howells
@ 2019-03-14 16:13 ` David Howells
  2019-03-14 16:13 ` [PATCH 38/38] tmpfs, devtmpfs, ramfs, rootfs: Convert " David Howells
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:13 UTC (permalink / raw)
  To: viro
  Cc: Casey Schaufler, linux-security-module, dhowells, linux-fsdevel,
	linux-kernel

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Casey Schaufler <casey@schaufler-ca.com>
cc: linux-security-module@vger.kernel.org
---

 security/smack/smackfs.c |   34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
index faf2ea3968b3..7e3a81d05136 100644
--- a/security/smack/smackfs.c
+++ b/security/smack/smackfs.c
@@ -27,6 +27,7 @@
 #include <linux/ctype.h>
 #include <linux/audit.h>
 #include <linux/magic.h>
+#include <linux/fs_context.h>
 #include "smack.h"
 
 #define BEBITS	(sizeof(__be32) * 8)
@@ -2843,14 +2844,13 @@ static const struct file_operations smk_ptrace_ops = {
 /**
  * smk_fill_super - fill the smackfs superblock
  * @sb: the empty superblock
- * @data: unused
- * @silent: unused
+ * @fc: unused
  *
  * Fill in the well known entries for the smack filesystem
  *
  * Returns 0 on success, an error code on failure
  */
-static int smk_fill_super(struct super_block *sb, void *data, int silent)
+static int smk_fill_super(struct super_block *sb, struct fs_context *fc)
 {
 	int rc;
 
@@ -2920,25 +2920,35 @@ static int smk_fill_super(struct super_block *sb, void *data, int silent)
 }
 
 /**
- * smk_mount - get the smackfs superblock
- * @fs_type: passed along without comment
- * @flags: passed along without comment
- * @dev_name: passed along without comment
- * @data: passed along without comment
+ * smk_get_tree - get the smackfs superblock
+ * @fc: The mount context, including any options
  *
  * Just passes everything along.
  *
  * Returns what the lower level code does.
  */
-static struct dentry *smk_mount(struct file_system_type *fs_type,
-		      int flags, const char *dev_name, void *data)
+static int smk_get_tree(struct fs_context *fc)
 {
-	return mount_single(fs_type, flags, data, smk_fill_super);
+	return vfs_get_super(fc, vfs_get_single_super, smk_fill_super);
+}
+
+static const struct fs_context_operations smk_context_ops = {
+	.get_tree	= smk_get_tree,
+};
+
+/**
+ * smk_init_fs_context - Initialise a filesystem context for smackfs
+ * @fc: The blank mount context
+ */
+static int smk_init_fs_context(struct fs_context *fc)
+{
+	fc->ops = &smk_context_ops;
+	return 0;
 }
 
 static struct file_system_type smk_fs_type = {
 	.name		= "smackfs",
-	.mount		= smk_mount,
+	.init_fs_context = smk_init_fs_context,
 	.kill_sb	= kill_litter_super,
 };
 


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH 38/38] tmpfs, devtmpfs, ramfs, rootfs: Convert to fs_context
       [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
                   ` (36 preceding siblings ...)
  2019-03-14 16:13 ` [PATCH 37/38] vfs: Convert smackfs " David Howells
@ 2019-03-14 16:13 ` David Howells
  37 siblings, 0 replies; 46+ messages in thread
From: David Howells @ 2019-03-14 16:13 UTC (permalink / raw)
  To: viro; +Cc: Hugh Dickins, linux-mm, dhowells, linux-fsdevel, linux-kernel

Convert tmpfs to fs_context as the mpol= option can be properly handled.
The issue is that it can contain embedded commas, so it can't be trivially
split up using strsep() to break on commas in generic_parse_monolithic().
Instead, tmpfs must supply its own generic parser.

However, if tmpfs changes, then devtmpfs and rootfs, which are wrappers around
tmpfs or ramfs, must change too - and thus so must ramfs, so convert these
also.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Hugh Dickins <hughd@google.com>
cc: linux-mm@kvack.org
---

 drivers/base/devtmpfs.c  |   16 +-
 fs/ramfs/inode.c         |  104 +++++++-----
 include/linux/ramfs.h    |    6 -
 include/linux/shmem_fs.h |    4 
 init/do_mounts.c         |   12 +
 mm/shmem.c               |  396 ++++++++++++++++++++++++++++++----------------
 6 files changed, 341 insertions(+), 197 deletions(-)

diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
index 0dbc43068eeb..1f50c844c2ab 100644
--- a/drivers/base/devtmpfs.c
+++ b/drivers/base/devtmpfs.c
@@ -56,19 +56,15 @@ static int __init mount_param(char *str)
 }
 __setup("devtmpfs.mount=", mount_param);
 
-static struct dentry *dev_mount(struct file_system_type *fs_type, int flags,
-		      const char *dev_name, void *data)
-{
+static struct file_system_type dev_fs_type = {
+	.name = "devtmpfs",
 #ifdef CONFIG_TMPFS
-	return mount_single(fs_type, flags, data, shmem_fill_super);
+	.init_fs_context = shmem_init_fs_context,
+	.parameters	= &shmem_fs_parameters,
 #else
-	return mount_single(fs_type, flags, data, ramfs_fill_super);
+	.init_fs_context = ramfs_init_fs_context,
+	.parameters	= &ramfs_fs_parameters,
 #endif
-}
-
-static struct file_system_type dev_fs_type = {
-	.name = "devtmpfs",
-	.mount = dev_mount,
 	.kill_sb = kill_litter_super,
 };
 
diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index 11201b2d06b9..01170dd6c95f 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -36,6 +36,8 @@
 #include <linux/magic.h>
 #include <linux/slab.h>
 #include <linux/uaccess.h>
+#include <linux/fs_context.h>
+#include <linux/fs_parser.h>
 #include "internal.h"
 
 struct ramfs_mount_opts {
@@ -175,62 +177,52 @@ static const struct super_operations ramfs_ops = {
 	.show_options	= ramfs_show_options,
 };
 
-enum {
+enum ramfs_param {
 	Opt_mode,
-	Opt_err
 };
 
-static const match_table_t tokens = {
-	{Opt_mode, "mode=%o"},
-	{Opt_err, NULL}
+static const struct fs_parameter_spec ramfs_param_specs[] = {
+	fsparam_u32oct("mode",	Opt_mode),
+	{}
 };
 
-static int ramfs_parse_options(char *data, struct ramfs_mount_opts *opts)
+const struct fs_parameter_description ramfs_fs_parameters = {
+	.name		= "ramfs",
+	.specs		= ramfs_param_specs,
+};
+
+static int ramfs_parse_param(struct fs_context *fc, struct fs_parameter *param)
 {
-	substring_t args[MAX_OPT_ARGS];
-	int option;
-	int token;
-	char *p;
-
-	opts->mode = RAMFS_DEFAULT_MODE;
-
-	while ((p = strsep(&data, ",")) != NULL) {
-		if (!*p)
-			continue;
-
-		token = match_token(p, tokens, args);
-		switch (token) {
-		case Opt_mode:
-			if (match_octal(&args[0], &option))
-				return -EINVAL;
-			opts->mode = option & S_IALLUGO;
-			break;
+	struct fs_parse_result result;
+	struct ramfs_fs_info *fsi = fc->s_fs_info;
+	int opt;
+
+	opt = fs_parse(fc, &ramfs_fs_parameters, param, &result);
+	if (opt < 0) {
 		/*
 		 * We might like to report bad mount options here;
 		 * but traditionally ramfs has ignored all mount options,
 		 * and as it is used as a !CONFIG_SHMEM simple substitute
 		 * for tmpfs, better continue to ignore other mount options.
 		 */
-		}
+		if (opt == -ENOPARAM)
+			opt = 0;
+		return opt;
+	}
+
+	switch (opt) {
+	case Opt_mode:
+		fsi->mount_opts.mode = result.uint_32 & S_IALLUGO;
+		break;
 	}
 
 	return 0;
 }
 
-int ramfs_fill_super(struct super_block *sb, void *data, int silent)
+static int ramfs_fill_super(struct super_block *sb, struct fs_context *fc)
 {
-	struct ramfs_fs_info *fsi;
+	struct ramfs_fs_info *fsi = sb->s_fs_info;
 	struct inode *inode;
-	int err;
-
-	fsi = kzalloc(sizeof(struct ramfs_fs_info), GFP_KERNEL);
-	sb->s_fs_info = fsi;
-	if (!fsi)
-		return -ENOMEM;
-
-	err = ramfs_parse_options(data, &fsi->mount_opts);
-	if (err)
-		return err;
 
 	sb->s_maxbytes		= MAX_LFS_FILESIZE;
 	sb->s_blocksize		= PAGE_SIZE;
@@ -247,10 +239,39 @@ int ramfs_fill_super(struct super_block *sb, void *data, int silent)
 	return 0;
 }
 
-struct dentry *ramfs_mount(struct file_system_type *fs_type,
-	int flags, const char *dev_name, void *data)
+static int ramfs_get_tree(struct fs_context *fc)
 {
-	return mount_nodev(fs_type, flags, data, ramfs_fill_super);
+	enum vfs_get_super_keying keying = vfs_get_independent_super;
+
+	if (strcmp(fc->fs_type->name, "devtmpfs") == 0)
+		keying = vfs_get_single_super;
+
+	return vfs_get_super(fc, keying, ramfs_fill_super);
+}
+
+static void ramfs_free_fc(struct fs_context *fc)
+{
+	kfree(fc->s_fs_info);
+}
+
+static const struct fs_context_operations ramfs_context_ops = {
+	.free		= ramfs_free_fc,
+	.parse_param	= ramfs_parse_param,
+	.get_tree	= ramfs_get_tree,
+};
+
+int ramfs_init_fs_context(struct fs_context *fc)
+{
+	struct ramfs_fs_info *fsi;
+
+	fsi = kzalloc(sizeof(*fsi), GFP_KERNEL);
+	if (!fsi)
+		return -ENOMEM;
+
+	fsi->mount_opts.mode = RAMFS_DEFAULT_MODE;
+	fc->s_fs_info = fsi;
+	fc->ops = &ramfs_context_ops;
+	return 0;
 }
 
 static void ramfs_kill_sb(struct super_block *sb)
@@ -261,7 +282,8 @@ static void ramfs_kill_sb(struct super_block *sb)
 
 static struct file_system_type ramfs_fs_type = {
 	.name		= "ramfs",
-	.mount		= ramfs_mount,
+	.init_fs_context = ramfs_init_fs_context,
+	.parameters	= &ramfs_fs_parameters,
 	.kill_sb	= ramfs_kill_sb,
 	.fs_flags	= FS_USERNS_MOUNT,
 };
diff --git a/include/linux/ramfs.h b/include/linux/ramfs.h
index 5ef7d54caac2..94b407424cb7 100644
--- a/include/linux/ramfs.h
+++ b/include/linux/ramfs.h
@@ -4,8 +4,7 @@
 
 struct inode *ramfs_get_inode(struct super_block *sb, const struct inode *dir,
 	 umode_t mode, dev_t dev);
-extern struct dentry *ramfs_mount(struct file_system_type *fs_type,
-	 int flags, const char *dev_name, void *data);
+extern int ramfs_init_fs_context(struct fs_context *fc);
 
 #ifdef CONFIG_MMU
 static inline int
@@ -17,10 +16,9 @@ ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize)
 extern int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize);
 #endif
 
+extern const struct fs_parameter_description ramfs_fs_parameters;
 extern const struct file_operations ramfs_file_operations;
 extern const struct vm_operations_struct generic_file_vm_ops;
 extern int __init init_ramfs_fs(void);
 
-int ramfs_fill_super(struct super_block *sb, void *data, int silent);
-
 #endif
diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
index f3fb1edb3526..3f73c00081e8 100644
--- a/include/linux/shmem_fs.h
+++ b/include/linux/shmem_fs.h
@@ -48,8 +48,10 @@ static inline struct shmem_inode_info *SHMEM_I(struct inode *inode)
 /*
  * Functions in mm/shmem.c called directly from elsewhere:
  */
+extern const struct fs_parameter_description shmem_fs_parameters;
+
 extern int shmem_init(void);
-extern int shmem_fill_super(struct super_block *sb, void *data, int silent);
+extern int shmem_init_fs_context(struct fs_context *fc);
 extern struct file *shmem_file_setup(const char *name,
 					loff_t size, unsigned long flags);
 extern struct file *shmem_kernel_file_setup(const char *name, loff_t size,
diff --git a/init/do_mounts.c b/init/do_mounts.c
index f8c230c77035..8242abd47e3f 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -626,24 +626,22 @@ void __init prepare_namespace(void)
 }
 
 static bool is_tmpfs;
-static struct dentry *rootfs_mount(struct file_system_type *fs_type,
-	int flags, const char *dev_name, void *data)
+static int rootfs_init_fs_context(struct fs_context *fc)
 {
 	static unsigned long once;
-	void *fill = ramfs_fill_super;
 
 	if (test_and_set_bit(0, &once))
-		return ERR_PTR(-ENODEV);
+		return -ENODEV;
 
 	if (IS_ENABLED(CONFIG_TMPFS) && is_tmpfs)
-		fill = shmem_fill_super;
+		return shmem_init_fs_context(fc);
 
-	return mount_nodev(fs_type, flags, data, fill);
+	return ramfs_init_fs_context(fc);
 }
 
 static struct file_system_type rootfs_fs_type = {
 	.name		= "rootfs",
-	.mount		= rootfs_mount,
+	.init_fs_context = rootfs_init_fs_context,
 	.kill_sb	= kill_litter_super,
 };
 
diff --git a/mm/shmem.c b/mm/shmem.c
index b3db3779a30a..5f45a710ee04 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -37,6 +37,8 @@
 #include <linux/khugepaged.h>
 #include <linux/hugetlb.h>
 #include <linux/frontswap.h>
+#include <linux/fs_context.h>
+#include <linux/fs_parser.h>
 
 #include <asm/tlbflush.h> /* for arch/microblaze update_mmu_cache() */
 
@@ -85,6 +87,17 @@ static struct vfsmount *shm_mnt;
 
 #include "internal.h"
 
+struct shmem_fs_context {
+	unsigned long	changes;
+	unsigned long	max_blocks;	/* How many blocks are allowed */
+	unsigned long	max_inodes;	/* How many inodes are allowed */
+	kuid_t		uid;
+	kgid_t		gid;
+	int		huge;
+	umode_t		mode;
+	struct mempolicy *mpol;		/* default memory policy for mappings */
+};
+
 #define BLOCKS_PER_PAGE  (PAGE_SIZE/512)
 #define VM_ACCT(size)    (PAGE_ALIGN(size) >> PAGE_SHIFT)
 
@@ -3351,16 +3364,13 @@ static const struct export_operations shmem_export_ops = {
 	.fh_to_dentry	= shmem_fh_to_dentry,
 };
 
-static int shmem_parse_options(char *options, struct shmem_sb_info *sbinfo,
-			       bool remount)
+static int shmem_parse_monolithic(struct fs_context *fc, void *data)
 {
-	char *this_char, *value, *rest;
-	struct mempolicy *mpol = NULL;
-	uid_t uid;
-	gid_t gid;
+	char *options = data, *key;
+	int ret = 0;
 
 	while (options != NULL) {
-		this_char = options;
+		key = options;
 		for (;;) {
 			/*
 			 * NUL-terminate this option: unfortunately,
@@ -3376,139 +3386,219 @@ static int shmem_parse_options(char *options, struct shmem_sb_info *sbinfo,
 				break;
 			}
 		}
-		if (!*this_char)
-			continue;
-		if ((value = strchr(this_char,'=')) != NULL) {
-			*value++ = 0;
-		} else {
-			pr_err("tmpfs: No value for mount option '%s'\n",
-			       this_char);
-			goto error;
-		}
 
-		if (!strcmp(this_char,"size")) {
-			unsigned long long size;
-			size = memparse(value,&rest);
-			if (*rest == '%') {
-				size <<= PAGE_SHIFT;
-				size *= totalram_pages();
-				do_div(size, 100);
-				rest++;
+		if (*key) {
+			size_t v_len = 0;
+			char *value = strchr(key, '=');
+
+			if (value) {
+				if (value == key)
+					continue;
+				*value++ = 0;
+				v_len = strlen(value);
 			}
-			if (*rest)
-				goto bad_val;
-			sbinfo->max_blocks =
-				DIV_ROUND_UP(size, PAGE_SIZE);
-		} else if (!strcmp(this_char,"nr_blocks")) {
-			sbinfo->max_blocks = memparse(value, &rest);
-			if (*rest)
-				goto bad_val;
-		} else if (!strcmp(this_char,"nr_inodes")) {
-			sbinfo->max_inodes = memparse(value, &rest);
-			if (*rest)
-				goto bad_val;
-		} else if (!strcmp(this_char,"mode")) {
-			if (remount)
-				continue;
-			sbinfo->mode = simple_strtoul(value, &rest, 8) & 07777;
-			if (*rest)
-				goto bad_val;
-		} else if (!strcmp(this_char,"uid")) {
-			if (remount)
-				continue;
-			uid = simple_strtoul(value, &rest, 0);
-			if (*rest)
-				goto bad_val;
-			sbinfo->uid = make_kuid(current_user_ns(), uid);
-			if (!uid_valid(sbinfo->uid))
-				goto bad_val;
-		} else if (!strcmp(this_char,"gid")) {
-			if (remount)
-				continue;
-			gid = simple_strtoul(value, &rest, 0);
-			if (*rest)
-				goto bad_val;
-			sbinfo->gid = make_kgid(current_user_ns(), gid);
-			if (!gid_valid(sbinfo->gid))
-				goto bad_val;
+			ret = vfs_parse_fs_string(fc, key, value, v_len);
+			if (ret < 0)
+				break;
+		}
+	}
+
+	return ret;
+}
+
+enum shmem_param {
+	Opt_gid,
+	Opt_huge,
+	Opt_mode,
+	Opt_mpol,
+	Opt_nr_blocks,
+	Opt_nr_inodes,
+	Opt_size,
+	Opt_uid,
+};
+
+static const struct fs_parameter_spec shmem_param_specs[] = {
+	fsparam_u32   ("gid",		Opt_gid),
+	fsparam_enum  ("huge",		Opt_huge),
+	fsparam_u32oct("mode",		Opt_mode),
+	fsparam_string("mpol",		Opt_mpol),
+	fsparam_string("nr_blocks",	Opt_nr_blocks),
+	fsparam_string("nr_inodes",	Opt_nr_inodes),
+	fsparam_string("size",		Opt_size),
+	fsparam_u32   ("uid",		Opt_uid),
+	{}
+};
+
+static const struct fs_parameter_enum shmem_param_enums[] = {
+	{ Opt_huge,	"never",	SHMEM_HUGE_NEVER },
+	{ Opt_huge,	"always",	SHMEM_HUGE_ALWAYS },
+	{ Opt_huge,	"within_size",	SHMEM_HUGE_WITHIN_SIZE },
+	{ Opt_huge,	"advise",	SHMEM_HUGE_ADVISE },
+	{ Opt_huge,	"deny",		SHMEM_HUGE_DENY },
+	{ Opt_huge,	"force",	SHMEM_HUGE_FORCE },
+	{}
+};
+
+const struct fs_parameter_description shmem_fs_parameters = {
+	.name		= "shmem",
+	.specs		= shmem_param_specs,
+	.enums		= shmem_param_enums,
+};
+
+static void shmem_apply_options(struct shmem_sb_info *sbinfo,
+				struct fs_context *fc,
+				unsigned long inodes_in_use)
+{
+	struct shmem_fs_context *ctx = fc->fs_private;
+	struct mempolicy *old = NULL;
+
+	if (test_bit(Opt_nr_blocks, &ctx->changes))
+		sbinfo->max_blocks = ctx->max_blocks;
+	if (test_bit(Opt_nr_inodes, &ctx->changes)) {
+		sbinfo->max_inodes = ctx->max_inodes;
+		sbinfo->free_inodes = ctx->max_inodes - inodes_in_use;
+	}
+	if (test_bit(Opt_huge, &ctx->changes))
+		sbinfo->huge = ctx->huge;
+	if (test_bit(Opt_mpol, &ctx->changes)) {
+		old = sbinfo->mpol;
+		sbinfo->mpol = ctx->mpol;
+	}
+
+	if (fc->purpose != FS_CONTEXT_FOR_RECONFIGURE) {
+		if (test_bit(Opt_uid, &ctx->changes))
+			sbinfo->uid = ctx->uid;
+		if (test_bit(Opt_gid, &ctx->changes))
+			sbinfo->gid = ctx->gid;
+		if (test_bit(Opt_mode, &ctx->changes))
+			sbinfo->mode = ctx->mode;
+	}
+
+	mpol_put(old);
+}
+
+static int shmem_parse_param(struct fs_context *fc, struct fs_parameter *param)
+{
+	struct shmem_fs_context *ctx = fc->fs_private;
+	struct fs_parse_result result;
+	unsigned long long size;
+	struct mempolicy *mpol;
+	char *rest;
+	int opt;
+
+	opt = fs_parse(fc, &shmem_fs_parameters, param, &result);
+	if (opt < 0)
+		return opt;
+
+	switch (opt) {
+	case Opt_size:
+		rest = param->string;
+		size = memparse(param->string, &rest);
+		if (*rest == '%') {
+			size <<= PAGE_SHIFT;
+			size *= totalram_pages();
+			do_div(size, 100);
+			rest++;
+		}
+		if (*rest)
+			return invalf(fc, "shmem: Invalid size");
+		ctx->max_blocks = DIV_ROUND_UP(size, PAGE_SIZE);
+		break;
+
+	case Opt_nr_blocks:
+		rest = param->string;
+		ctx->max_blocks = memparse(param->string, &rest);
+		if (*rest)
+			return invalf(fc, "shmem: Invalid nr_blocks");
+		break;
+	case Opt_nr_inodes:
+		rest = param->string;
+		ctx->max_inodes = memparse(param->string, &rest);
+		if (*rest)
+			return invalf(fc, "shmem: Invalid nr_inodes");
+		break;
+	case Opt_mode:
+		ctx->mode = result.uint_32 & 07777;
+		break;
+	case Opt_uid:
+		ctx->uid = make_kuid(current_user_ns(), result.uint_32);
+		if (!uid_valid(ctx->uid))
+			return invalf(fc, "shmem: Invalid uid");
+		break;
+
+	case Opt_gid:
+		ctx->gid = make_kgid(current_user_ns(), result.uint_32);
+		if (!gid_valid(ctx->gid))
+			return invalf(fc, "shmem: Invalid gid");
+		break;
+
+	case Opt_huge:
 #ifdef CONFIG_TRANSPARENT_HUGE_PAGECACHE
-		} else if (!strcmp(this_char, "huge")) {
-			int huge;
-			huge = shmem_parse_huge(value);
-			if (huge < 0)
-				goto bad_val;
-			if (!has_transparent_hugepage() &&
-					huge != SHMEM_HUGE_NEVER)
-				goto bad_val;
-			sbinfo->huge = huge;
+		if (!has_transparent_hugepage() &&
+		    result.uint_32 != SHMEM_HUGE_NEVER)
+			return invalf(fc, "shmem: Huge pages disabled");
+
+		ctx->huge = result.uint_32;
+		break;
+#else
+		return invalf(fc, "shmem: huge= option disabled");
 #endif
+
+	case Opt_mpol:
 #ifdef CONFIG_NUMA
-		} else if (!strcmp(this_char,"mpol")) {
-			mpol_put(mpol);
-			mpol = NULL;
-			if (mpol_parse_str(value, &mpol))
-				goto bad_val;
+		if (mpol_parse_str(param->string, &mpol))
+			return invalf(fc, "shmem: Invalid mpol=");
+		mpol_put(ctx->mpol);
+		ctx->mpol = mpol;
 #endif
-		} else {
-			pr_err("tmpfs: Bad mount option %s\n", this_char);
-			goto error;
-		}
+		break;
 	}
-	sbinfo->mpol = mpol;
-	return 0;
-
-bad_val:
-	pr_err("tmpfs: Bad value '%s' for mount option '%s'\n",
-	       value, this_char);
-error:
-	mpol_put(mpol);
-	return 1;
 
+	__set_bit(opt, &ctx->changes);
+	return 0;
 }
 
-static int shmem_remount_fs(struct super_block *sb, int *flags, char *data)
+/*
+ * Reconfigure a shmem filesystem.
+ *
+ * Note that we disallow change from limited->unlimited blocks/inodes while any
+ * are in use; but we must separately disallow unlimited->limited, because in
+ * that case we have no record of how much is already in use.
+ */
+static int shmem_reconfigure(struct fs_context *fc)
 {
+	struct shmem_fs_context *ctx = fc->fs_private;
+	struct super_block *sb = fc->root->d_sb;
 	struct shmem_sb_info *sbinfo = SHMEM_SB(sb);
-	struct shmem_sb_info config = *sbinfo;
-	unsigned long inodes;
-	int error = -EINVAL;
-
-	config.mpol = NULL;
-	if (shmem_parse_options(data, &config, true))
-		return error;
+	unsigned long inodes_in_use;
 
 	spin_lock(&sbinfo->stat_lock);
-	inodes = sbinfo->max_inodes - sbinfo->free_inodes;
-	if (percpu_counter_compare(&sbinfo->used_blocks, config.max_blocks) > 0)
-		goto out;
-	if (config.max_inodes < inodes)
-		goto out;
-	/*
-	 * Those tests disallow limited->unlimited while any are in use;
-	 * but we must separately disallow unlimited->limited, because
-	 * in that case we have no record of how much is already in use.
-	 */
-	if (config.max_blocks && !sbinfo->max_blocks)
-		goto out;
-	if (config.max_inodes && !sbinfo->max_inodes)
-		goto out;
-
-	error = 0;
-	sbinfo->huge = config.huge;
-	sbinfo->max_blocks  = config.max_blocks;
-	sbinfo->max_inodes  = config.max_inodes;
-	sbinfo->free_inodes = config.max_inodes - inodes;
+	if (test_bit(Opt_nr_blocks, &ctx->changes)) {
+		if (ctx->max_blocks && !sbinfo->max_blocks) {
+			spin_unlock(&sbinfo->stat_lock);
+			return invalf(fc, "shmem: Can't retroactively limit nr_blocks");
+		}
+		if (percpu_counter_compare(&sbinfo->used_blocks, ctx->max_blocks) > 0) {
+			spin_unlock(&sbinfo->stat_lock);
+			return invalf(fc, "shmem: Too few blocks for current use");
+		}
+	}
 
-	/*
-	 * Preserve previous mempolicy unless mpol remount option was specified.
-	 */
-	if (config.mpol) {
-		mpol_put(sbinfo->mpol);
-		sbinfo->mpol = config.mpol;	/* transfers initial ref */
+	inodes_in_use = sbinfo->max_inodes - sbinfo->free_inodes;
+	if (test_bit(Opt_nr_inodes, &ctx->changes)) {
+		if (ctx->max_inodes && !sbinfo->max_inodes) {
+			spin_unlock(&sbinfo->stat_lock);
+			return invalf(fc, "shmem: Can't retroactively limit nr_inodes");
+		}
+		if (ctx->max_inodes < inodes_in_use) {
+			spin_unlock(&sbinfo->stat_lock);
+			return invalf(fc, "shmem: Too few inodes for current use");
+		}
 	}
-out:
+
+	shmem_apply_options(sbinfo, fc, inodes_in_use);
 	spin_unlock(&sbinfo->stat_lock);
-	return error;
+	return 0;
 }
 
 static int shmem_show_options(struct seq_file *seq, struct dentry *root)
@@ -3549,7 +3639,7 @@ static void shmem_put_super(struct super_block *sb)
 	sb->s_fs_info = NULL;
 }
 
-int shmem_fill_super(struct super_block *sb, void *data, int silent)
+static int shmem_fill_super(struct super_block *sb, struct fs_context *fc)
 {
 	struct inode *inode;
 	struct shmem_sb_info *sbinfo;
@@ -3575,10 +3665,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
 	if (!(sb->s_flags & SB_KERNMOUNT)) {
 		sbinfo->max_blocks = shmem_default_max_blocks();
 		sbinfo->max_inodes = shmem_default_max_inodes();
-		if (shmem_parse_options(data, sbinfo, false)) {
-			err = -EINVAL;
-			goto failed;
-		}
+		shmem_apply_options(sbinfo, fc, 0);
 	} else {
 		sb->s_flags |= SB_NOUSER;
 	}
@@ -3624,6 +3711,36 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
 	return err;
 }
 
+static int shmem_get_tree(struct fs_context *fc)
+{
+	enum vfs_get_super_keying keying = vfs_get_independent_super;
+
+	if (strcmp(fc->fs_type->name, "devtmpfs") == 0)
+		keying = vfs_get_single_super;
+
+	return vfs_get_super(fc, keying, shmem_fill_super);
+}
+
+static void shmem_free_fc(struct fs_context *fc)
+{
+	struct shmem_fs_context *ctx = fc->fs_private;
+
+	if (ctx) {
+		mpol_put(ctx->mpol);
+		kfree(ctx);
+	}
+}
+
+static const struct fs_context_operations shmem_fs_context_ops = {
+	.free			= shmem_free_fc,
+	.get_tree		= shmem_get_tree,
+#ifdef CONFIG_TMPFS
+	.parse_monolithic	= shmem_parse_monolithic,
+	.parse_param		= shmem_parse_param,
+	.reconfigure		= shmem_reconfigure,
+#endif
+};
+
 static struct kmem_cache *shmem_inode_cachep;
 
 static struct inode *shmem_alloc_inode(struct super_block *sb)
@@ -3741,7 +3858,6 @@ static const struct super_operations shmem_ops = {
 	.destroy_inode	= shmem_destroy_inode,
 #ifdef CONFIG_TMPFS
 	.statfs		= shmem_statfs,
-	.remount_fs	= shmem_remount_fs,
 	.show_options	= shmem_show_options,
 #endif
 	.evict_inode	= shmem_evict_inode,
@@ -3762,16 +3878,26 @@ static const struct vm_operations_struct shmem_vm_ops = {
 #endif
 };
 
-static struct dentry *shmem_mount(struct file_system_type *fs_type,
-	int flags, const char *dev_name, void *data)
+int shmem_init_fs_context(struct fs_context *fc)
 {
-	return mount_nodev(fs_type, flags, data, shmem_fill_super);
+	struct shmem_fs_context *ctx;
+
+	ctx = kzalloc(sizeof(struct shmem_fs_context), GFP_KERNEL);
+	if (!ctx)
+		return -ENOMEM;
+
+	fc->fs_private = ctx;
+	fc->ops = &shmem_fs_context_ops;
+	return 0;
 }
 
 static struct file_system_type shmem_fs_type = {
 	.owner		= THIS_MODULE,
 	.name		= "tmpfs",
-	.mount		= shmem_mount,
+	.init_fs_context = shmem_init_fs_context,
+#ifdef CONFIG_TMPFS
+	.parameters	= &shmem_fs_parameters,
+#endif
 	.kill_sb	= kill_litter_super,
 	.fs_flags	= FS_USERNS_MOUNT,
 };
@@ -3916,7 +4042,8 @@ bool shmem_huge_enabled(struct vm_area_struct *vma)
 
 static struct file_system_type shmem_fs_type = {
 	.name		= "tmpfs",
-	.mount		= ramfs_mount,
+	.init_fs_context = ramfs_init_fs_context,
+	.parameters	= &ramfs_fs_parameters,
 	.kill_sb	= kill_litter_super,
 	.fs_flags	= FS_USERNS_MOUNT,
 };
@@ -4117,3 +4244,4 @@ struct page *shmem_read_mapping_page_gfp(struct address_space *mapping,
 #endif
 }
 EXPORT_SYMBOL_GPL(shmem_read_mapping_page_gfp);
+


^ permalink raw reply related	[flat|nested] 46+ messages in thread

* Re: [PATCH 20/38] vfs: Convert nfsctl to fs_context
  2019-03-14 16:11 ` [PATCH 20/38] vfs: Convert nfsctl " David Howells
@ 2019-03-14 17:29   ` J. Bruce Fields
  0 siblings, 0 replies; 46+ messages in thread
From: J. Bruce Fields @ 2019-03-14 17:29 UTC (permalink / raw)
  To: David Howells; +Cc: viro, Jeff Layton, linux-nfs, linux-fsdevel, linux-kernel

Fine by me.

(Are these for 5.1 or 5.2?  Just wondering what to do with some other
ongoing work in the same area.  Any conflicts are probably trivial,
though, so no big deal either way.)

--b.

On Thu, Mar 14, 2019 at 04:11:34PM +0000, David Howells wrote:
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: "J. Bruce Fields" <bfields@fieldses.org>
> cc: Jeff Layton <jlayton@kernel.org>
> cc: linux-nfs@vger.kernel.org
> ---
> 
>  fs/nfsd/nfsctl.c |   33 ++++++++++++++++++++++++++-------
>  1 file changed, 26 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
> index f2feb2d11bae..d4eb4f34a94c 100644
> --- a/fs/nfsd/nfsctl.c
> +++ b/fs/nfsd/nfsctl.c
> @@ -7,6 +7,7 @@
>  #include <linux/slab.h>
>  #include <linux/namei.h>
>  #include <linux/ctype.h>
> +#include <linux/fs_context.h>
>  
>  #include <linux/sunrpc/svcsock.h>
>  #include <linux/lockd/lockd.h>
> @@ -1146,7 +1147,7 @@ static ssize_t write_v4_end_grace(struct file *file, char *buf, size_t size)
>   *	populating the filesystem.
>   */
>  
> -static int nfsd_fill_super(struct super_block * sb, void * data, int silent)
> +static int nfsd_fill_super(struct super_block *sb, struct fs_context *fc)
>  {
>  	static const struct tree_descr nfsd_files[] = {
>  		[NFSD_List] = {"exports", &exports_nfsd_operations, S_IRUGO},
> @@ -1176,15 +1177,33 @@ static int nfsd_fill_super(struct super_block * sb, void * data, int silent)
>  #endif
>  		/* last one */ {""}
>  	};
> -	get_net(sb->s_fs_info);
> +
>  	return simple_fill_super(sb, 0x6e667364, nfsd_files);
>  }
>  
> -static struct dentry *nfsd_mount(struct file_system_type *fs_type,
> -	int flags, const char *dev_name, void *data)
> +static int nfsd_fs_get_tree(struct fs_context *fc)
> +{
> +	fc->s_fs_info = get_net(fc->net_ns);
> +	return vfs_get_super(fc, vfs_get_keyed_super, nfsd_fill_super);
> +}
> +
> +static void nfsd_fs_free_fc(struct fs_context *fc)
> +{
> +	if (fc->s_fs_info)
> +		put_net(fc->s_fs_info);
> +}
> +
> +static const struct fs_context_operations nfsd_fs_context_ops = {
> +	.free		= nfsd_fs_free_fc,
> +	.get_tree	= nfsd_fs_get_tree,
> +};
> +
> +static int nfsd_init_fs_context(struct fs_context *fc)
>  {
> -	struct net *net = current->nsproxy->net_ns;
> -	return mount_ns(fs_type, flags, data, net, net->user_ns, nfsd_fill_super);
> +	put_user_ns(fc->user_ns);
> +	fc->user_ns = get_user_ns(fc->net_ns->user_ns);
> +	fc->ops = &nfsd_fs_context_ops;
> +	return 0;
>  }
>  
>  static void nfsd_umount(struct super_block *sb)
> @@ -1198,7 +1217,7 @@ static void nfsd_umount(struct super_block *sb)
>  static struct file_system_type nfsd_fs_type = {
>  	.owner		= THIS_MODULE,
>  	.name		= "nfsd",
> -	.mount		= nfsd_mount,
> +	.init_fs_context = nfsd_init_fs_context,
>  	.kill_sb	= nfsd_umount,
>  };
>  MODULE_ALIAS_FS("nfsd");

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 16/38] vfs: Convert btrfs_test to fs_context
  2019-03-14 16:11 ` [PATCH 16/38] vfs: Convert btrfs_test " David Howells
@ 2019-03-14 18:24   ` David Sterba
  0 siblings, 0 replies; 46+ messages in thread
From: David Sterba @ 2019-03-14 18:24 UTC (permalink / raw)
  To: David Howells
  Cc: viro, Chris Mason, Josef Bacik, linux-btrfs, linux-fsdevel, linux-kernel

On Thu, Mar 14, 2019 at 04:11:04PM +0000, David Howells wrote:
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Chris Mason <clm@fb.com>
> cc: Josef Bacik <josef@toxicpanda.com>
> cc: David Sterba <dsterba@suse.com>
> cc: linux-btrfs@vger.kernel.org

Acked-by: David Sterba <dsterba@suse.com>

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 13/38] vfs: Convert cxl to fs_context
  2019-03-14 16:10 ` [PATCH 13/38] vfs: Convert cxl " David Howells
@ 2019-03-15  0:22   ` Andrew Donnellan
  2019-03-22  7:42   ` Frederic Barrat
  1 sibling, 0 replies; 46+ messages in thread
From: Andrew Donnellan @ 2019-03-15  0:22 UTC (permalink / raw)
  To: David Howells, viro
  Cc: linux-kernel, linux-fsdevel, Frederic Barrat, linuxppc-dev

On 15/3/19 3:10 am, David Howells wrote:
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Frederic Barrat <fbarrat@linux.ibm.com>
> cc: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
> cc: linuxppc-dev@lists.ozlabs.org

Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>

> ---
> 
>   drivers/misc/cxl/api.c |   10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c
> index 750470ef2049..395e9a88e6ba 100644
> --- a/drivers/misc/cxl/api.c
> +++ b/drivers/misc/cxl/api.c
> @@ -13,6 +13,7 @@
>   #include <misc/cxl.h>
>   #include <linux/module.h>
>   #include <linux/mount.h>
> +#include <linux/fs_context.h>
>   #include <linux/sched/mm.h>
>   #include <linux/mmu_context.h>
>   
> @@ -41,17 +42,16 @@ static const struct dentry_operations cxl_fs_dops = {
>   	.d_dname	= simple_dname,
>   };
>   
> -static struct dentry *cxl_fs_mount(struct file_system_type *fs_type, int flags,
> -				const char *dev_name, void *data)
> +static int cxl_fs_init_fs_context(struct fs_context *fc)
>   {
> -	return mount_pseudo(fs_type, "cxl:", NULL, &cxl_fs_dops,
> -			CXL_PSEUDO_FS_MAGIC);
> +	return vfs_init_pseudo_fs_context(fc, "cxl:", NULL, NULL,
> +					  &cxl_fs_dops, CXL_PSEUDO_FS_MAGIC);
>   }
>   
>   static struct file_system_type cxl_fs_type = {
>   	.name		= "cxl",
>   	.owner		= THIS_MODULE,
> -	.mount		= cxl_fs_mount,
> +	.init_fs_context = cxl_fs_init_fs_context,
>   	.kill_sb	= kill_anon_super,
>   };
>   
> 

-- 
Andrew Donnellan              OzLabs, ADL Canberra
andrew.donnellan@au1.ibm.com  IBM Australia Limited


^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 14/38] vfs: Convert ocxlflash to fs_context
  2019-03-14 16:10 ` [PATCH 14/38] vfs: Convert ocxlflash " David Howells
@ 2019-03-19 14:53   ` Matthew R. Ochs
  0 siblings, 0 replies; 46+ messages in thread
From: Matthew R. Ochs @ 2019-03-19 14:53 UTC (permalink / raw)
  To: David Howells
  Cc: viro, Manoj N. Kumar, Uma Krishnan, James E.J. Bottomley,
	Martin K. Petersen, linux-scsi, linux-fsdevel, linux-kernel

On Thu, Mar 14, 2019 at 04:10:47PM +0000, David Howells wrote:
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: "Manoj N. Kumar" <manoj@linux.ibm.com>
> cc: "Matthew R. Ochs" <mrochs@linux.ibm.com>
> cc: Uma Krishnan <ukrishn@linux.ibm.com>
> cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
> cc: "Martin K. Petersen" <martin.petersen@oracle.com>
> cc: linux-scsi@vger.kernel.org

Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>

> ---
> 
>  drivers/scsi/cxlflash/ocxl_hw.c |   21 ++++++---------------
>  1 file changed, 6 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/scsi/cxlflash/ocxl_hw.c b/drivers/scsi/cxlflash/ocxl_hw.c
> index 37b8dc60f5f6..a8d2cc6390c7 100644
> --- a/drivers/scsi/cxlflash/ocxl_hw.c
> +++ b/drivers/scsi/cxlflash/ocxl_hw.c
> @@ -16,6 +16,7 @@
>  #include <linux/idr.h>
>  #include <linux/module.h>
>  #include <linux/mount.h>
> +#include <linux/fs_context.h>
>  #include <linux/poll.h>
>  #include <linux/sched/signal.h>
>  
> @@ -39,27 +40,17 @@ static const struct dentry_operations ocxlflash_fs_dops = {
>  	.d_dname	= simple_dname,
>  };
>  
> -/*
> - * ocxlflash_fs_mount() - mount the pseudo-filesystem
> - * @fs_type:	File system type.
> - * @flags:	Flags for the filesystem.
> - * @dev_name:	Device name associated with the filesystem.
> - * @data:	Data pointer.
> - *
> - * Return: pointer to the directory entry structure
> - */
> -static struct dentry *ocxlflash_fs_mount(struct file_system_type *fs_type,
> -					 int flags, const char *dev_name,
> -					 void *data)
> +static int ocxlflash_fs_init_fs_context(struct fs_context *fc)
>  {
> -	return mount_pseudo(fs_type, "ocxlflash:", NULL, &ocxlflash_fs_dops,
> -			    OCXLFLASH_FS_MAGIC);
> +	return vfs_init_pseudo_fs_context(fc, "ocxlflash:",
> +					  NULL, NULL,
> +					  &ocxlflash_fs_dops, OCXLFLASH_FS_MAGIC);
>  }
>  
>  static struct file_system_type ocxlflash_fs_type = {
>  	.name		= "ocxlflash",
>  	.owner		= THIS_MODULE,
> -	.mount		= ocxlflash_fs_mount,
> +	.init_fs_context = ocxlflash_fs_init_fs_context,
>  	.kill_sb	= kill_anon_super,
>  };
>  
> 


^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 31/38] vfs: Convert gadgetfs to fs_context
  2019-03-14 16:13 ` [PATCH 31/38] vfs: Convert gadgetfs " David Howells
@ 2019-03-20  6:57   ` Felipe Balbi
  2019-03-20  7:42   ` David Howells
  1 sibling, 0 replies; 46+ messages in thread
From: Felipe Balbi @ 2019-03-20  6:57 UTC (permalink / raw)
  To: David Howells, viro; +Cc: linux-usb, dhowells, linux-fsdevel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2359 bytes --]

David Howells <dhowells@redhat.com> writes:

> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Felipe Balbi <balbi@kernel.org>
> cc: linux-usb@vger.kernel.org
> ---
>
>  drivers/usb/gadget/legacy/inode.c |   21 +++++++++++++++------
>  1 file changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
> index 249277d0e53f..441da16ffc39 100644
> --- a/drivers/usb/gadget/legacy/inode.c
> +++ b/drivers/usb/gadget/legacy/inode.c
> @@ -12,6 +12,7 @@
>  #include <linux/init.h>
>  #include <linux/module.h>
>  #include <linux/fs.h>
> +#include <linux/fs_context.h>
>  #include <linux/pagemap.h>
>  #include <linux/uts.h>
>  #include <linux/wait.h>
> @@ -1990,7 +1991,7 @@ static const struct super_operations gadget_fs_operations = {
>  };
>  
>  static int
> -gadgetfs_fill_super (struct super_block *sb, void *opts, int silent)
> +gadgetfs_fill_super (struct super_block *sb, struct fs_context *fc)
>  {
>  	struct inode	*inode;
>  	struct dev_data	*dev;
> @@ -2044,11 +2045,19 @@ gadgetfs_fill_super (struct super_block *sb, void *opts, int silent)
>  }
>  
>  /* "mount -t gadgetfs path /dev/gadget" ends up here */
> -static struct dentry *
> -gadgetfs_mount (struct file_system_type *t, int flags,
> -		const char *path, void *opts)
> +static int gadgetfs_get_tree(struct fs_context *fc)
>  {
> -	return mount_single (t, flags, opts, gadgetfs_fill_super);
> +	return vfs_get_super(fc, vfs_get_single_super, gadgetfs_fill_super);
> +}
> +
> +static const struct fs_context_operations gadgetfs_context_ops = {
> +	.get_tree	= gadgetfs_get_tree,
> +};
> +
> +static int gadgetfs_init_fs_context(struct fs_context *fc)
> +{
> +	fc->ops = &gadgetfs_context_ops;
> +	return 0;
>  }
>  
>  static void
> @@ -2068,7 +2077,7 @@ gadgetfs_kill_sb (struct super_block *sb)
>  static struct file_system_type gadgetfs_type = {
>  	.owner		= THIS_MODULE,
>  	.name		= shortname,
> -	.mount		= gadgetfs_mount,
> +	.init_fs_context = gadgetfs_init_fs_context,
>  	.kill_sb	= gadgetfs_kill_sb,
>  };
>  MODULE_ALIAS_FS("gadgetfs");

looks like a mostly mechanical change. Do you want this to go through
the USB tree or FS tree?

Also, do you mind doing the same for drivers/usb/gadget/function/f_fs.c?

cheers

-- 
balbi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 31/38] vfs: Convert gadgetfs to fs_context
  2019-03-14 16:13 ` [PATCH 31/38] vfs: Convert gadgetfs " David Howells
  2019-03-20  6:57   ` Felipe Balbi
@ 2019-03-20  7:42   ` David Howells
  2019-03-20  8:34     ` Felipe Balbi
  1 sibling, 1 reply; 46+ messages in thread
From: David Howells @ 2019-03-20  7:42 UTC (permalink / raw)
  To: Felipe Balbi; +Cc: dhowells, viro, linux-usb, linux-fsdevel, linux-kernel

Felipe Balbi <balbi@kernel.org> wrote:

> looks like a mostly mechanical change. Do you want this to go through
> the USB tree or FS tree?

I'm going to try and get all of these to go through the Al's vfs tree since
there are dependent cleanup patches that remove code that's then obsolete.

> Also, do you mind doing the same for drivers/usb/gadget/function/f_fs.c?

Sure.  The reason I hadn't already done it is that it doesn't look entirely
trivial.

David

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 31/38] vfs: Convert gadgetfs to fs_context
  2019-03-20  7:42   ` David Howells
@ 2019-03-20  8:34     ` Felipe Balbi
  0 siblings, 0 replies; 46+ messages in thread
From: Felipe Balbi @ 2019-03-20  8:34 UTC (permalink / raw)
  To: David Howells; +Cc: dhowells, viro, linux-usb, linux-fsdevel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 676 bytes --]

David Howells <dhowells@redhat.com> writes:

> Felipe Balbi <balbi@kernel.org> wrote:
>
>> looks like a mostly mechanical change. Do you want this to go through
>> the USB tree or FS tree?
>
> I'm going to try and get all of these to go through the Al's vfs tree since
> there are dependent cleanup patches that remove code that's then obsolete.

In that case, here's my ack:

Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com>

>> Also, do you mind doing the same for drivers/usb/gadget/function/f_fs.c?
>
> Sure.  The reason I hadn't already done it is that it doesn't look entirely
> trivial.

oh, no rush :-) Just thought I'd mention.

-- 
balbi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: [PATCH 13/38] vfs: Convert cxl to fs_context
  2019-03-14 16:10 ` [PATCH 13/38] vfs: Convert cxl " David Howells
  2019-03-15  0:22   ` Andrew Donnellan
@ 2019-03-22  7:42   ` Frederic Barrat
  1 sibling, 0 replies; 46+ messages in thread
From: Frederic Barrat @ 2019-03-22  7:42 UTC (permalink / raw)
  To: David Howells, viro
  Cc: Andrew Donnellan, linuxppc-dev, linux-fsdevel, linux-kernel



Le 14/03/2019 à 17:10, David Howells a écrit :
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Frederic Barrat <fbarrat@linux.ibm.com>
> cc: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
> cc: linuxppc-dev@lists.ozlabs.org
> ---

Acked-by: Frederic Barrat <fbarrat@linux.ibm.com>


> 
>   drivers/misc/cxl/api.c |   10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c
> index 750470ef2049..395e9a88e6ba 100644
> --- a/drivers/misc/cxl/api.c
> +++ b/drivers/misc/cxl/api.c
> @@ -13,6 +13,7 @@
>   #include <misc/cxl.h>
>   #include <linux/module.h>
>   #include <linux/mount.h>
> +#include <linux/fs_context.h>
>   #include <linux/sched/mm.h>
>   #include <linux/mmu_context.h>
>   
> @@ -41,17 +42,16 @@ static const struct dentry_operations cxl_fs_dops = {
>   	.d_dname	= simple_dname,
>   };
>   
> -static struct dentry *cxl_fs_mount(struct file_system_type *fs_type, int flags,
> -				const char *dev_name, void *data)
> +static int cxl_fs_init_fs_context(struct fs_context *fc)
>   {
> -	return mount_pseudo(fs_type, "cxl:", NULL, &cxl_fs_dops,
> -			CXL_PSEUDO_FS_MAGIC);
> +	return vfs_init_pseudo_fs_context(fc, "cxl:", NULL, NULL,
> +					  &cxl_fs_dops, CXL_PSEUDO_FS_MAGIC);
>   }
>   
>   static struct file_system_type cxl_fs_type = {
>   	.name		= "cxl",
>   	.owner		= THIS_MODULE,
> -	.mount		= cxl_fs_mount,
> +	.init_fs_context = cxl_fs_init_fs_context,
>   	.kill_sb	= kill_anon_super,
>   };
>   
> 


^ permalink raw reply	[flat|nested] 46+ messages in thread

end of thread, other threads:[~2019-03-22  7:43 UTC | newest]

Thread overview: 46+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <155257972443.13720.11743171471060355965.stgit@warthog.procyon.org.uk>
2019-03-14 16:09 ` [PATCH 01/38] vfs: Provide sb->s_iflags settings in fs_context struct David Howells
2019-03-14 16:09 ` [PATCH 02/38] vfs: Provide a mount_pseudo-replacement for fs_context David Howells
2019-03-14 16:09 ` [PATCH 03/38] vfs: Convert aio to fs_context David Howells
2019-03-14 16:09 ` [PATCH 04/38] vfs: Convert anon_inodes " David Howells
2019-03-14 16:09 ` [PATCH 05/38] vfs: Convert bdev " David Howells
2019-03-14 16:09 ` [PATCH 06/38] vfs: Convert nsfs " David Howells
2019-03-14 16:09 ` [PATCH 07/38] vfs: Convert pipe " David Howells
2019-03-14 16:09 ` [PATCH 08/38] vfs: Convert zsmalloc " David Howells
2019-03-14 16:10 ` [PATCH 09/38] vfs: Convert sockfs " David Howells
2019-03-14 16:10 ` [PATCH 10/38] vfs: Convert dax " David Howells
2019-03-14 16:10 ` [PATCH 11/38] vfs: Convert drm " David Howells
2019-03-14 16:10 ` [PATCH 12/38] vfs: Convert ia64 perfmon " David Howells
2019-03-14 16:10 ` [PATCH 13/38] vfs: Convert cxl " David Howells
2019-03-15  0:22   ` Andrew Donnellan
2019-03-22  7:42   ` Frederic Barrat
2019-03-14 16:10 ` [PATCH 14/38] vfs: Convert ocxlflash " David Howells
2019-03-19 14:53   ` Matthew R. Ochs
2019-03-14 16:10 ` [PATCH 15/38] vfs: Convert virtio_balloon " David Howells
2019-03-14 16:11 ` [PATCH 16/38] vfs: Convert btrfs_test " David Howells
2019-03-14 18:24   ` David Sterba
2019-03-14 16:11 ` [PATCH 17/38] vfs: Kill off mount_pseudo() and mount_pseudo_xattr() David Howells
2019-03-14 16:11 ` [PATCH 18/38] vfs: Use sget_fc() for pseudo-filesystems David Howells
2019-03-14 16:11 ` [PATCH 19/38] vfs: Convert binderfs to fs_context David Howells
2019-03-14 16:11 ` [PATCH 20/38] vfs: Convert nfsctl " David Howells
2019-03-14 17:29   ` J. Bruce Fields
2019-03-14 16:11 ` [PATCH 21/38] vfs: Convert rpc_pipefs " David Howells
2019-03-14 16:11 ` [PATCH 22/38] vfs: Kill off mount_ns() David Howells
2019-03-14 16:11 ` [PATCH 23/38] vfs: Kill sget_userns() David Howells
2019-03-14 16:12 ` [PATCH 24/38] vfs: Convert binfmt_misc to fs_context David Howells
2019-03-14 16:12 ` [PATCH 25/38] vfs: Convert configfs " David Howells
2019-03-14 16:12 ` [PATCH 26/38] vfs: Convert efivarfs " David Howells
2019-03-14 16:12 ` [PATCH 27/38] vfs: Convert fusectl " David Howells
2019-03-14 16:12 ` [PATCH 28/38] vfs: Convert qib_fs/ipathfs " David Howells
2019-03-14 16:12 ` [PATCH 29/38] vfs: Convert ibmasmfs " David Howells
2019-03-14 16:12 ` [PATCH 30/38] vfs: Convert oprofilefs " David Howells
2019-03-14 16:13 ` [PATCH 31/38] vfs: Convert gadgetfs " David Howells
2019-03-20  6:57   ` Felipe Balbi
2019-03-20  7:42   ` David Howells
2019-03-20  8:34     ` Felipe Balbi
2019-03-14 16:13 ` [PATCH 32/38] vfs: Convert xenfs " David Howells
2019-03-14 16:13 ` [PATCH 33/38] vfs: Convert openpromfs " David Howells
2019-03-14 16:13 ` [PATCH 34/38] vfs: Convert apparmorfs " David Howells
2019-03-14 16:13 ` [PATCH 35/38] vfs: Convert securityfs " David Howells
2019-03-14 16:13 ` [PATCH 36/38] vfs: Convert selinuxfs " David Howells
2019-03-14 16:13 ` [PATCH 37/38] vfs: Convert smackfs " David Howells
2019-03-14 16:13 ` [PATCH 38/38] tmpfs, devtmpfs, ramfs, rootfs: Convert " David Howells

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).