diff mbox series

[v6,15/22] erofs: register cookie context for bootstrap blob

Message ID 20220325122223.102958-16-jefflexu@linux.alibaba.com (mailing list archive)
State New, archived
Headers show
Series fscache,erofs: fscache-based on-demand read semantics | expand

Commit Message

Jingbo Xu March 25, 2022, 12:22 p.m. UTC
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@linux.alibaba.com>
---
 fs/erofs/internal.h |  3 +++
 fs/erofs/super.c    | 17 +++++++++++++++++
 2 files changed, 20 insertions(+)

Comments

Gao Xiang March 28, 2022, 3:04 a.m. UTC | #1
On Fri, Mar 25, 2022 at 08:22:16PM +0800, Jeffle Xu wrote:
> 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@linux.alibaba.com>
> ---
>  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;

the concept of bootstrap is nydus-specific. Actually here we need
a fscache context of the primary device.

So I prefer struct erofs_fscache *s_fscache;

Also please help revise the subject and commit message about
bootstrap.

Thanks,
Gao Xiang
Jingbo Xu March 28, 2022, 3:15 a.m. UTC | #2
On 3/28/22 11:04 AM, Gao Xiang wrote:
> On Fri, Mar 25, 2022 at 08:22:16PM +0800, Jeffle Xu wrote:
>> 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@linux.alibaba.com>
>> ---
>>  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;
> 
> the concept of bootstrap is nydus-specific. Actually here we need
> a fscache context of the primary device.
> 
> So I prefer struct erofs_fscache *s_fscache;
> 
> Also please help revise the subject and commit message about
> bootstrap.
> 

OK, will be done in the next version.
diff mbox series

Patch

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 = {