lkml.org 
[lkml]   [2021]   [Dec]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v1 11/23] erofs: register cookie context for bootstrap
Date
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 under
.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 | 2 ++
fs/erofs/super.c | 13 +++++++++++++
2 files changed, 15 insertions(+)

diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 2e4f267b37e7..4ee4ff6774ba 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -141,6 +141,8 @@ struct erofs_sb_info {
u8 volume_name[16]; /* volume name */
u32 feature_compat;
u32 feature_incompat;
+
+ struct erofs_cookie_ctx *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 517d74f3c303..141cabd01d32 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -663,6 +663,16 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
else
sbi->dax_dev = NULL;

+ if (!sb->s_bdev) {
+ struct erofs_cookie_ctx *bootstrap;
+
+ bootstrap = erofs_fscache_get_ctx(sb, ctx->opt.uuid);
+ if (IS_ERR(bootstrap))
+ return PTR_ERR(bootstrap);
+
+ sbi->bootstrap = bootstrap;
+ }
+
err = erofs_read_superblock(sb);
if (err)
return err;
@@ -820,6 +830,7 @@ static void erofs_kill_sb(struct super_block *sb)
return;

erofs_free_dev_context(sbi->devs);
+ erofs_fscache_put_ctx(sbi->bootstrap);
fs_put_dax(sbi->dax_dev);
kfree(sbi);
sb->s_fs_info = NULL;
@@ -837,6 +848,8 @@ static void erofs_put_super(struct super_block *sb)
iput(sbi->managed_cache);
sbi->managed_cache = NULL;
#endif
+ erofs_fscache_put_ctx(sbi->bootstrap);
+ sbi->bootstrap = NULL;
}

static struct file_system_type erofs_fs_type = {
--
2.27.0
\
 
 \ /
  Last update: 2021-12-27 13:56    [W:0.829 / U:0.312 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site