mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] erofs: fix blksize < PAGE_SIZE in fileio mode
@ 2024-10-15  6:40 Hongzhen Luo
  2024-10-15  6:57 ` Gao Xiang
  0 siblings, 1 reply; 2+ messages in thread
From: Hongzhen Luo @ 2024-10-15  6:40 UTC (permalink / raw)
  To: linux-erofs; +Cc: linux-kernel, Hongzhen Luo

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@linux.alibaba.com>
---
v2: Add support for blocksize < PAGE_SIZE in file-backed mount mode.
v1: https://lore.kernel.org/linux-erofs/20241015033601.3206952-1-hongzhen@linux.alibaba.com/
---
 fs/erofs/super.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 320d586c3896..abe2d85512dd 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -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;
+			}
 		}
 	}
 
-- 
2.43.5


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] erofs: fix blksize < PAGE_SIZE in fileio mode
  2024-10-15  6:40 [PATCH v2] erofs: fix blksize < PAGE_SIZE in fileio mode Hongzhen Luo
@ 2024-10-15  6:57 ` Gao Xiang
  0 siblings, 0 replies; 2+ messages in thread
From: Gao Xiang @ 2024-10-15  6:57 UTC (permalink / raw)
  To: Hongzhen Luo, linux-erofs; +Cc: linux-kernel



On 2024/10/15 14:40, Hongzhen Luo wrote:
> 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.

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.

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

Unnecessary blank line.

> Signed-off-by: Hongzhen Luo <hongzhen@linux.alibaba.com>
> ---
> v2: Add support for blocksize < PAGE_SIZE in file-backed mount mode.
> v1: https://lore.kernel.org/linux-erofs/20241015033601.3206952-1-hongzhen@linux.alibaba.com/
> ---
>   fs/erofs/super.c | 12 +++++++++---
>   1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/erofs/super.c b/fs/erofs/super.c
> index 320d586c3896..abe2d85512dd 100644
> --- a/fs/erofs/super.c
> +++ b/fs/erofs/super.c
> @@ -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;
> +			}

Please use

		} else if (!sb_set_blocksize(sb, 1 << sbi->blkszbits)) {
			errorfc(fc, "failed to set erofs blksize");
			return -EINVAL;
		}
Here.

Thanks,
Gao Xiang

>   		}
>   	}
>   


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-10-15  6:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-15  6:40 [PATCH v2] erofs: fix blksize < PAGE_SIZE in fileio mode Hongzhen Luo
2024-10-15  6:57 ` Gao Xiang

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®