erofs: fix blksize < PAGE_SIZE in fileio mode
PATCH v2 1/1 erofs: fix blksize < PAGE_SIZE in fileio mode
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.
---
v2: Add support for blocksize < PAGE_SIZE in file-backed mount mode.
v1: https://lore.kernel.org/linux-erofs/[email protected]/
--- fs/erofs/super.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
fs/erofs/super.c +9 -3
@@ -631,9 +631,15 @@ 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)) { -errorfc (fc,"failed to set erofs blksize" ); -return -EINVAL ; + +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 ; + } } }
Signature · 1 line
2.43.5
Quoted 3 lines · Hongzhen Luo
In fileio mode, when blcksize is not equal to
PAGE_SIZE, erofs will attempt to set the block size ofsb->s_bdev, which will trigger a panic. This patch fixes this.
Please fix trivial typos:
erofs: fix blksize < PAGE_SIZE for file-backed mounts
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.
Quoted 3 lines
Fixes fb176750266a ("erofs: add file-backed mount support")
Unnecessary blank line.
Quoted 18 lines
Signed-off-by Hongzhen Luo <[email protected]>---
v2: Add support for blocksize <PAGE_SIZEin file-backed mount mode.
v1: https://lore.kernel.org/linux-erofs/[email protected]/--- fs/erofs/super.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)fs/erofs/super.c +0
-2@@ -631,9 +631,15 @@ 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)) { -errorfc (fc,"failed to set erofs blksize" );
fs/erofs/super.c static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc) · line 642
Quoted 10 lines
fs/erofs/super.c +9
-1-return -EINVAL ; + +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 ; + }
Please use
} else if (!sb_set_blocksize(sb, 1 << sbi->blkszbits)) {
errorfc(fc, "failed to set erofs blksize");
return -EINVAL;
}Here.
Thanks,
Gao Xiang
Quoted 3 lines
fs/erofs/super.c +0
-0} }