From: Hongzhen Luo <hongz...@linux.alibaba.com> Move the `struct erofs_anon_fs_type` to the super.c and expose it in preparation for the upcoming page cache share feature.
Signed-off-by: Hongzhen Luo <hongz...@linux.alibaba.com> Link: https://lore.kernel.org/20240902110620.2202586-2-hongz...@linux.alibaba.com Signed-off-by: Christian Brauner <brau...@kernel.org> --- fs/erofs/fscache.c | 13 ------------- fs/erofs/internal.h | 2 ++ fs/erofs/super.c | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index 34517ca9df91..fe9216dd27f8 100644 --- a/fs/erofs/fscache.c +++ b/fs/erofs/fscache.c @@ -3,7 +3,6 @@ * Copyright (C) 2022, Alibaba Cloud * Copyright (C) 2022, Bytedance Inc. All rights reserved. */ -#include <linux/pseudo_fs.h> #include <linux/fscache.h> #include "internal.h" @@ -13,18 +12,6 @@ static LIST_HEAD(erofs_domain_list); static LIST_HEAD(erofs_domain_cookies_list); static struct vfsmount *erofs_pseudo_mnt; -static int erofs_anon_init_fs_context(struct fs_context *fc) -{ - return init_pseudo(fc, EROFS_SUPER_MAGIC) ? 0 : -ENOMEM; -} - -static struct file_system_type erofs_anon_fs_type = { - .owner = THIS_MODULE, - .name = "pseudo_erofs", - .init_fs_context = erofs_anon_init_fs_context, - .kill_sb = kill_anon_super, -}; - struct erofs_fscache_io { struct netfs_cache_resources cres; struct iov_iter iter; diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index a32c03a80c70..30380f7baf5e 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -372,6 +372,8 @@ extern const struct file_operations erofs_dir_fops; extern const struct iomap_ops z_erofs_iomap_report_ops; +extern struct file_system_type erofs_anon_fs_type; + /* flags for erofs_fscache_register_cookie() */ #define EROFS_REG_COOKIE_SHARE 0x0001 #define EROFS_REG_COOKIE_NEED_NOEXIST 0x0002 diff --git a/fs/erofs/super.c b/fs/erofs/super.c index e1e9f06e8342..8fb14df2a343 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -11,6 +11,7 @@ #include <linux/fs_parser.h> #include <linux/exportfs.h> #include <linux/backing-dev.h> +#include <linux/pseudo_fs.h> #include "xattr.h" #define CREATE_TRACE_POINTS @@ -889,6 +890,29 @@ static struct file_system_type erofs_fs_type = { }; MODULE_ALIAS_FS("erofs"); +static const struct super_operations erofs_anon_sops = { + .statfs = simple_statfs, +}; + +static int erofs_anon_init_fs_context(struct fs_context *fc) +{ + struct pseudo_fs_context *ctx; + + ctx = init_pseudo(fc, EROFS_SUPER_MAGIC); + if (!ctx) + return -ENOMEM; + + ctx->ops = &erofs_anon_sops; + return 0; +} + +struct file_system_type erofs_anon_fs_type = { + .owner = THIS_MODULE, + .name = "pseudo_erofs", + .init_fs_context = erofs_anon_init_fs_context, + .kill_sb = kill_anon_super, +}; + static int __init erofs_module_init(void) { int err; -- 2.47.2