Skip to content

Commit 37c90c5

Browse files
lostjefflehsiangkao
authored andcommitted
erofs: register fscache context for primary data blob
Registers fscache context for primary data blob. Also move the initialization of s_op and related fields forward, since anonymous inode will be allocated under the super block when registering the fscache context. Something worth mentioning about the cleanup routine. 1. The fscache context will instantiate anonymous inodes under the super block. Release these anonymous inodes when .put_super() is called, or we'll get "VFS: Busy inodes after unmount." warning. 2. The fscache context is initialized prior to the root inode. If .kill_sb() is called when mount failed, .put_super() won't be called when root inode has not been initialized yet. Thus .kill_sb() shall also contain the cleanup routine. Signed-off-by: Jeffle Xu <[email protected]> Reviewed-by: Gao Xiang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Acked-by: Chao Yu <[email protected]> Signed-off-by: Gao Xiang <[email protected]>
1 parent ec00b5e commit 37c90c5

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

fs/erofs/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ struct erofs_sb_info {
155155

156156
/* fscache support */
157157
struct fscache_volume *volume;
158+
struct erofs_fscache *s_fscache;
158159
};
159160

160161
#define EROFS_SB(sb) ((struct erofs_sb_info *)(sb)->s_fs_info)

fs/erofs/super.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,9 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
628628
int err;
629629

630630
sb->s_magic = EROFS_SUPER_MAGIC;
631+
sb->s_flags |= SB_RDONLY | SB_NOATIME;
632+
sb->s_maxbytes = MAX_LFS_FILESIZE;
633+
sb->s_op = &erofs_sops;
631634

632635
sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
633636
if (!sbi)
@@ -645,6 +648,11 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
645648
err = erofs_fscache_register_fs(sb);
646649
if (err)
647650
return err;
651+
652+
err = erofs_fscache_register_cookie(sb, &sbi->s_fscache,
653+
sbi->opt.fsid, true);
654+
if (err)
655+
return err;
648656
} else {
649657
if (!sb_set_blocksize(sb, EROFS_BLKSIZ)) {
650658
erofs_err(sb, "failed to set erofs blksize");
@@ -667,11 +675,8 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
667675
clear_opt(&sbi->opt, DAX_ALWAYS);
668676
}
669677
}
670-
sb->s_flags |= SB_RDONLY | SB_NOATIME;
671-
sb->s_maxbytes = MAX_LFS_FILESIZE;
672-
sb->s_time_gran = 1;
673678

674-
sb->s_op = &erofs_sops;
679+
sb->s_time_gran = 1;
675680
sb->s_xattr = erofs_xattr_handlers;
676681
sb->s_export_op = &erofs_export_ops;
677682

@@ -812,6 +817,7 @@ static void erofs_kill_sb(struct super_block *sb)
812817

813818
erofs_free_dev_context(sbi->devs);
814819
fs_put_dax(sbi->dax_dev);
820+
erofs_fscache_unregister_cookie(&sbi->s_fscache);
815821
erofs_fscache_unregister_fs(sb);
816822
kfree(sbi);
817823
sb->s_fs_info = NULL;
@@ -830,6 +836,7 @@ static void erofs_put_super(struct super_block *sb)
830836
iput(sbi->managed_cache);
831837
sbi->managed_cache = NULL;
832838
#endif
839+
erofs_fscache_unregister_cookie(&sbi->s_fscache);
833840
}
834841

835842
static struct file_system_type erofs_fs_type = {

0 commit comments

Comments
 (0)