]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
erofs: fix blksize < PAGE_SIZE for file-backed mounts
authorHongzhen Luo <hongzhen@linux.alibaba.com>
Tue, 15 Oct 2024 10:38:36 +0000 (18:38 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Mon, 18 Nov 2024 10:50:14 +0000 (18:50 +0800)
Adjust sb->s_blocksize{,_bits} directly for file-backed
mounts when the fs block size is smaller than PAGE_SIZE.

Previously, EROFS used sb_set_blocksize(), which caused
a panic if bdev-backed mounts is not used.

Fixes: fb176750266a ("erofs: add file-backed mount support")
Signed-off-by: Hongzhen Luo <hongzhen@linux.alibaba.com>
Link: https://lore.kernel.org/r/20241015103836.3757438-1-hongzhen@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
fs/erofs/super.c

index 961ee47e2b4d8c294927153993ecde4504624ca3..c235a8e4315ea441221e6d0b9530a8af1461714d 100644 (file)
@@ -616,7 +616,11 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
                        errorfc(fc, "unsupported blksize for fscache mode");
                        return -EINVAL;
                }
-               if (!sb_set_blocksize(sb, 1 << sbi->blkszbits)) {
+
+               if (erofs_is_fileio_mode(sbi)) {
+                       sb->s_blocksize = 1 << sbi->blkszbits;
+                       sb->s_blocksize_bits = sbi->blkszbits;
+               } else if (!sb_set_blocksize(sb, 1 << sbi->blkszbits)) {
                        errorfc(fc, "failed to set erofs blksize");
                        return -EINVAL;
                }