diff mbox series

[RFC,21/68] vfs: Use sget_fc() for pseudo-filesystems

Message ID 155373019372.7602.3546094909660562519.stgit@warthog.procyon.org.uk (mailing list archive)
State New, archived
Headers show
Series [RFC,01/68] kbuild: skip sub-make for in-tree build with GNU Make 4.x | expand

Commit Message

David Howells March 27, 2019, 11:43 p.m. UTC
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 mbox series

Patch

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;