On Wed, Apr 17, 2024 at 10:59:53AM +0800, Baokun Li wrote:
On 2024/4/16 22:49, Gao Xiang wrote:Hi Baokun,
On Tue, Apr 16, 2024 at 02:35:08PM +0200, Christian Brauner wrote:Hi Xiang,
Hi Christian,Instead of allocating the erofs_sb_info in fill_super() allocate itI'm not sure how to resolve it in EROFS itself, anyway...
during erofs_get_tree() and then you can ensure that you always have the
info you need available during erofs_kill_sb(). See the appended
(untested) patch.
Yeah, that is a good way I think. Although sbi will be allocated
unconditionally instead but that is minor.
I'm on OSSNA this week, will test this patch more when returning.
Hi Baokun,
Could you also check this on your side?
Thanks,
Gao Xiang
This patch does fix the initial problem.
Hi Christian,
Thanks for the patch, this is a good idea. Just with nits below.
Otherwise feel free to add.
Reviewed-and-tested-by: Baokun Li <libaokun1@xxxxxxxxxx>
SNIPFrom e4f586a41748b6edc05aca36d49b7b39e55def81 Mon Sep 17 00:00:00 2001
From: Christian Brauner <brauner@xxxxxxxxxx>
Date: Mon, 15 Apr 2024 20:17:46 +0800
Subject: [PATCH] erofs: reliably distinguish block based and fscache mode
This line is no longer needed.diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index c0eb139adb07..4ed80154edf8 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -581,7 +581,7 @@ static const struct export_operations erofs_export_ops = {
static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
{
struct inode *inode;
- struct erofs_sb_info *sbi;
+ struct erofs_sb_info *sbi = EROFS_SB(sb);
struct erofs_fs_context *ctx = fc->fs_private;
int err;
@@ -590,15 +590,10 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
sb->s_maxbytes = MAX_LFS_FILESIZE;
sb->s_op = &erofs_sops;
- sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
- if (!sbi)
- return -ENOMEM;
-
sb->s_fs_info = sbi;
Since erofs_sb_info is now allocated in erofs_fc_get_tree(), why notsbi->opt = ctx->opt;
sbi->devs = ctx->devs;
ctx->devs = NULL;
- sbi->fsid = ctx->fsid;
ctx->fsid = NULL;
sbi->domain_id = ctx->domain_id;
ctx->domain_id = NULL;
encapsulate the above lines as erofs_ctx_to_info() helper function
to be called in erofs_fc_get_tree()?Then erofs_fc_fill_super() wouldn't
have to use erofs_fs_context and would prevent the fsid from being
freed twice.
I'm not sure if Christian has enough time to polish the whole
codebase (I'm happy if do so). Basically, that is just a hint
to the issue, if you have more time, I guess you could also help
revive this patch together (also because you also have a real
EROFS test environment).
Let me also check this next week after OSSNA travelling.
Thanks,
Gao Xiang