Signed-off-by: Andrew Price <anpr...@redhat.com>
---
 fs/gfs2/ops_fstype.c | 54 ++++++++++++++++++++++++++------------------
 1 file changed, 32 insertions(+), 22 deletions(-)

diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index ad2c98a37bd4..460d31403a7c 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -1629,48 +1629,58 @@ static int gfs2_init_fs_context(struct fs_context *fc)
        return 0;
 }
 
-static int set_meta_super(struct super_block *s, void *ptr)
+static int set_meta_super(struct super_block *s, struct fs_context *fc)
 {
        return -EINVAL;
 }
 
-static int test_meta_super(struct super_block *s, void *ptr)
-{
-       struct block_device *bdev = ptr;
-       return (bdev == s->s_bdev);
-}
-
-
-static struct dentry *gfs2_mount_meta(struct file_system_type *fs_type,
-                       int flags, const char *dev_name, void *data)
+static int gfs2_meta_get_tree(struct fs_context *fc)
 {
+       struct gfs2_args *args = fc->fs_private;
        struct super_block *s;
        struct gfs2_sbd *sdp;
        struct path path;
        int error;
 
-       if (!dev_name || !*dev_name)
-               return ERR_PTR(-EINVAL);
+       if (!fc->source || !*fc->source)
+               return -EINVAL;
 
-       error = kern_path(dev_name, LOOKUP_FOLLOW, &path);
+       error = kern_path(fc->source, LOOKUP_FOLLOW, &path);
        if (error) {
                pr_warn("path_lookup on %s returned error %d\n",
-                       dev_name, error);
-               return ERR_PTR(error);
+                       fc->source, error);
+               return error;
        }
-       s = sget(&gfs2_fs_type, test_meta_super, set_meta_super, flags,
-                path.dentry->d_sb->s_bdev);
+       fc->fs_type = &gfs2_fs_type;
+       args->ar_bdev = path.dentry->d_sb->s_bdev;
+       s = sget_fc(fc, test_gfs2_super, set_meta_super);
        path_put(&path);
        if (IS_ERR(s)) {
                pr_warn("gfs2 mount does not exist\n");
-               return ERR_CAST(s);
+               return PTR_ERR(s);
        }
-       if ((flags ^ s->s_flags) & SB_RDONLY) {
+       if ((fc->sb_flags ^ s->s_flags) & SB_RDONLY) {
                deactivate_locked_super(s);
-               return ERR_PTR(-EBUSY);
+               return -EBUSY;
        }
        sdp = s->s_fs_info;
-       return dget(sdp->sd_master_dir);
+       fc->root = dget(sdp->sd_master_dir);
+       return 0;
+}
+
+static const struct fs_context_operations gfs2_meta_context_ops = {
+       .get_tree    = gfs2_meta_get_tree,
+};
+
+static int gfs2_meta_init_fs_context(struct fs_context *fc)
+{
+       int ret = gfs2_init_fs_context(fc);
+
+       if (ret)
+               return ret;
+
+       fc->ops = &gfs2_meta_context_ops;
+       return 0;
 }
 
 static void gfs2_kill_sb(struct super_block *sb)
@@ -1705,7 +1715,7 @@ MODULE_ALIAS_FS("gfs2");
 struct file_system_type gfs2meta_fs_type = {
        .name = "gfs2meta",
        .fs_flags = FS_REQUIRES_DEV,
-       .mount = gfs2_mount_meta,
+       .init_fs_context = gfs2_meta_init_fs_context,
        .owner = THIS_MODULE,
 };
 MODULE_ALIAS_FS("gfs2meta");
-- 
2.20.1

Reply via email to