Registers fscache_cookie for the bootstrap blob file. The bootstrap blob file can be specified by a new mount option, which is going to be introduced by a following patch. Something worth mentioning about the cleanup routine. 1. The init routine is prior to when the root inode gets initialized, and thus the corresponding cleanup routine shall be placed inside .kill_sb() callback. 2. The init routine will instantiate anonymous inodes under the super_block, and thus .put_super() callback shall also contain the cleanup routine. Or we'll get "VFS: Busy inodes after unmount." warning. Signed-off-by: Jeffle Xu <jefflexu@xxxxxxxxxxxxxxxxx> --- fs/erofs/internal.h | 3 +++ fs/erofs/super.c | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index 459f31803c3b..d8c886a7491e 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -73,6 +73,7 @@ struct erofs_mount_opts { /* threshold for decompression synchronously */ unsigned int max_sync_decompress_pages; #endif + char *tag; unsigned int mount_opt; }; @@ -151,6 +152,8 @@ struct erofs_sb_info { /* sysfs support */ struct kobject s_kobj; /* /sys/fs/erofs/<devname> */ struct completion s_kobj_unregister; + + struct erofs_fscache *bootstrap; }; #define EROFS_SB(sb) ((struct erofs_sb_info *)(sb)->s_fs_info) diff --git a/fs/erofs/super.c b/fs/erofs/super.c index 798f0c379e35..de5aeda4aea0 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -598,6 +598,16 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc) sbi->devs = ctx->devs; ctx->devs = NULL; + if (IS_ENABLED(CONFIG_EROFS_FS_ONDEMAND) && erofs_is_nodev_mode(sb)) { + struct erofs_fscache *bootstrap; + + bootstrap = erofs_fscache_get(sb, ctx->opt.tag, true); + if (IS_ERR(bootstrap)) + return PTR_ERR(bootstrap); + + sbi->bootstrap = bootstrap; + } + err = erofs_read_superblock(sb); if (err) return err; @@ -753,6 +763,7 @@ static void erofs_kill_sb(struct super_block *sb) return; erofs_free_dev_context(sbi->devs); + erofs_fscache_put(sbi->bootstrap); fs_put_dax(sbi->dax_dev); kfree(sbi); sb->s_fs_info = NULL; @@ -771,6 +782,12 @@ static void erofs_put_super(struct super_block *sb) iput(sbi->managed_cache); sbi->managed_cache = NULL; #endif + erofs_fscache_put(sbi->bootstrap); + /* + * Set sbi->bootstrap to NULL, so that the following cleanup routine + * inside .kill_sb() could be skipped then. + */ + sbi->bootstrap = NULL; } static struct file_system_type erofs_fs_type = { -- 2.27.0