From: Jingbo Xu <jefflexu@linux.alibaba.com>
To: xiang@kernel.org, chao@kernel.org, linux-erofs@lists.ozlabs.org
Cc: huyue2@coolpad.com, zhujia.zj@bytedance.com,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] erofs: set blksize to on-disk blksize for fscache mode
Date: Tue, 21 Feb 2023 17:17:19 +0800 [thread overview]
Message-ID: <20230221091719.126127-3-jefflexu@linux.alibaba.com> (raw)
In-Reply-To: <20230221091719.126127-1-jefflexu@linux.alibaba.com>
Since fscache mode has supported PAGE_SIZE other than 4KB, remove the
constraint and set to on-disk blksize.
We need to initialize the fscache context for the bootstrap before
setting the initial blksize as it will also update anonymous inode's
i_blkbits for the bootstrap.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
---
fs/erofs/super.c | 38 ++++++++++++++++++++------------------
1 file changed, 20 insertions(+), 18 deletions(-)
diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 89011a4ed274..130e0f6db3c7 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -709,6 +709,17 @@ static int erofs_fc_fill_pseudo_super(struct super_block *sb, struct fs_context
return simple_fill_super(sb, EROFS_SUPER_MAGIC, &empty_descr);
}
+static bool erofs_set_block_size(struct super_block *sb, unsigned int blkszbits)
+{
+ if (!erofs_is_fscache_mode(sb))
+ return sb_set_blocksize(sb, 1 << blkszbits);
+
+ sb->s_blocksize = 1 << blkszbits;
+ sb->s_blocksize_bits = blkszbits;
+ EROFS_SB(sb)->s_fscache->inode->i_blkbits = blkszbits;
+ return true;
+}
+
static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
{
struct inode *inode;
@@ -734,11 +745,7 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
sbi->domain_id = ctx->domain_id;
ctx->domain_id = NULL;
- sbi->blkszbits = PAGE_SHIFT;
if (erofs_is_fscache_mode(sb)) {
- sb->s_blocksize = PAGE_SIZE;
- sb->s_blocksize_bits = PAGE_SHIFT;
-
err = erofs_fscache_register_fs(sb);
if (err)
return err;
@@ -747,29 +754,24 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
if (err)
return err;
} else {
- if (!sb_set_blocksize(sb, PAGE_SIZE)) {
- errorfc(fc, "failed to set initial blksize");
- return -EINVAL;
- }
-
sbi->dax_dev = fs_dax_get_by_bdev(sb->s_bdev,
&sbi->dax_part_off,
NULL, NULL);
}
+ if (!erofs_set_block_size(sb, PAGE_SHIFT)) {
+ errorfc(fc, "failed to set initial blksize");
+ return -EINVAL;
+ }
+
err = erofs_read_superblock(sb);
if (err)
return err;
- if (sb->s_blocksize_bits != sbi->blkszbits) {
- if (erofs_is_fscache_mode(sb)) {
- errorfc(fc, "unsupported blksize for fscache mode");
- return -EINVAL;
- }
- if (!sb_set_blocksize(sb, 1 << sbi->blkszbits)) {
- errorfc(fc, "failed to set erofs blksize");
- return -EINVAL;
- }
+ if (sb->s_blocksize_bits != sbi->blkszbits &&
+ !erofs_set_block_size(sb, sbi->blkszbits)) {
+ errorfc(fc, "failed to set erofs blksize");
+ return -EINVAL;
}
if (test_opt(&sbi->opt, DAX_ALWAYS)) {
--
2.19.1.6.gb485710b
prev parent reply other threads:[~2023-02-21 9:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-21 9:17 [PATCH 0/2] erofs: remove the constraint of 4KB " Jingbo Xu
2023-02-21 9:17 ` [PATCH 1/2] erofs: pass accurate blob size to prepare_ondemand_read() Jingbo Xu
2023-02-21 9:17 ` Jingbo Xu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230221091719.126127-3-jefflexu@linux.alibaba.com \
--to=jefflexu@linux.alibaba.com \
--cc=chao@kernel.org \
--cc=huyue2@coolpad.com \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xiang@kernel.org \
--cc=zhujia.zj@bytedance.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®