[PATCH] erofs: fix unsupported blksize in fileio mode

From: Hongzhen Luo
Date: Mon Oct 14 2024 - 23:36:16 EST


In fileio mode, when blcksize is not equal to PAGE_SIZE,
erofs will attempt to set the block size of sb->s_bdev,
which will trigger a panic. This patch fixes this.

Fixes: fb176750266a ("erofs: add file-backed mount support")

Signed-off-by: Hongzhen Luo <hongzhen@xxxxxxxxxxxxxxxxx>
---
fs/erofs/super.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 320d586c3896..a7635e667d4b 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -631,6 +631,10 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
errorfc(fc, "unsupported blksize for fscache mode");
return -EINVAL;
}
+ if (erofs_is_fileio_mode(sbi)) {
+ errorfc(fc, "unsupported blksize for fileio mode");
+ return -EINVAL;
+ }
if (!sb_set_blocksize(sb, 1 << sbi->blkszbits)) {
errorfc(fc, "failed to set erofs blksize");
return -EINVAL;
--
2.43.5