Skip to content

Commit 4340ca4

Browse files
committed
erofs: decouple struct erofs_anon_fs_type
- Move the `struct erofs_anon_fs_type` to super.c and expose it in preparation for the upcoming page cache share feature; - Remove the `.owner` field, as they are all internal mounts and fully managed by EROFS. Retaining `.owner` would unnecessarily increment module reference counts, preventing the EROFS kernel module from being unloaded. Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
1 parent 3736449 commit 4340ca4

3 files changed

Lines changed: 16 additions & 13 deletions

File tree

fs/erofs/fscache.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Copyright (C) 2022, Alibaba Cloud
44
* Copyright (C) 2022, Bytedance Inc. All rights reserved.
55
*/
6-
#include <linux/pseudo_fs.h>
76
#include <linux/fscache.h>
87
#include "internal.h"
98

@@ -13,18 +12,6 @@ static LIST_HEAD(erofs_domain_list);
1312
static LIST_HEAD(erofs_domain_cookies_list);
1413
static struct vfsmount *erofs_pseudo_mnt;
1514

16-
static int erofs_anon_init_fs_context(struct fs_context *fc)
17-
{
18-
return init_pseudo(fc, EROFS_SUPER_MAGIC) ? 0 : -ENOMEM;
19-
}
20-
21-
static struct file_system_type erofs_anon_fs_type = {
22-
.owner = THIS_MODULE,
23-
.name = "pseudo_erofs",
24-
.init_fs_context = erofs_anon_init_fs_context,
25-
.kill_sb = kill_anon_super,
26-
};
27-
2815
struct erofs_fscache_io {
2916
struct netfs_cache_resources cres;
3017
struct iov_iter iter;

fs/erofs/internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ static inline bool erofs_is_fileio_mode(struct erofs_sb_info *sbi)
185185
return IS_ENABLED(CONFIG_EROFS_FS_BACKED_BY_FILE) && sbi->dif0.file;
186186
}
187187

188+
extern struct file_system_type erofs_anon_fs_type;
189+
188190
static inline bool erofs_is_fscache_mode(struct super_block *sb)
189191
{
190192
return IS_ENABLED(CONFIG_EROFS_FS_ONDEMAND) &&

fs/erofs/super.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/fs_parser.h>
1212
#include <linux/exportfs.h>
1313
#include <linux/backing-dev.h>
14+
#include <linux/pseudo_fs.h>
1415
#include "xattr.h"
1516

1617
#define CREATE_TRACE_POINTS
@@ -945,6 +946,19 @@ static struct file_system_type erofs_fs_type = {
945946
};
946947
MODULE_ALIAS_FS("erofs");
947948

949+
#if defined(CONFIG_EROFS_FS_ONDEMAND)
950+
static int erofs_anon_init_fs_context(struct fs_context *fc)
951+
{
952+
return init_pseudo(fc, EROFS_SUPER_MAGIC) ? 0 : -ENOMEM;
953+
}
954+
955+
struct file_system_type erofs_anon_fs_type = {
956+
.name = "pseudo_erofs",
957+
.init_fs_context = erofs_anon_init_fs_context,
958+
.kill_sb = kill_anon_super,
959+
};
960+
#endif
961+
948962
static int __init erofs_module_init(void)
949963
{
950964
int err;

0 commit comments

Comments
 (0)