* [PATCH] erofs: handle 48-bit blocks_hi for compressed inodes
@ 2026-06-22 7:34 Zhan Xusheng
2026-06-22 7:43 ` Gao Xiang
0 siblings, 1 reply; 4+ messages in thread
From: Zhan Xusheng @ 2026-06-22 7:34 UTC (permalink / raw)
To: Gao Xiang; +Cc: Chao Yu, linux-erofs, linux-kernel, Zhan Xusheng
Combine i_nb.blocks_hi with i_u.blocks_lo when computing
inode->i_blocks for compressed inodes, mirroring the startblk_hi
handling for unencoded inodes a few lines above. Also evaluate
the shift in u64 to avoid truncation.
Fixes: 2e1473d5195f ("erofs: implement 48-bit block addressing for unencoded inodes")
Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
---
fs/erofs/inode.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
index a188c570087a..cf2f00e13cae 100644
--- a/fs/erofs/inode.c
+++ b/fs/erofs/inode.c
@@ -191,8 +191,9 @@ static int erofs_read_inode(struct inode *inode)
err = -EFSCORRUPTED;
goto err_out;
} else {
- inode->i_blocks = le32_to_cpu(copied.i_u.blocks_lo) <<
- (sb->s_blocksize_bits - 9);
+ inode->i_blocks = ((u64)le16_to_cpu(copied.i_nb.blocks_hi) << 32 |
+ le32_to_cpu(copied.i_u.blocks_lo)) <<
+ (sb->s_blocksize_bits - 9);
}
if (vi->datalayout == EROFS_INODE_CHUNK_BASED) {
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] erofs: handle 48-bit blocks_hi for compressed inodes
2026-06-22 7:34 [PATCH] erofs: handle 48-bit blocks_hi for compressed inodes Zhan Xusheng
@ 2026-06-22 7:43 ` Gao Xiang
2026-06-22 8:11 ` [PATCH v2] " Zhan Xusheng
0 siblings, 1 reply; 4+ messages in thread
From: Gao Xiang @ 2026-06-22 7:43 UTC (permalink / raw)
To: Zhan Xusheng, Gao Xiang; +Cc: Chao Yu, linux-erofs, linux-kernel, Zhan Xusheng
Hi Xusheng,
On 2026/6/22 15:34, Zhan Xusheng wrote:
> Combine i_nb.blocks_hi with i_u.blocks_lo when computing
> inode->i_blocks for compressed inodes, mirroring the startblk_hi
> handling for unencoded inodes a few lines above. Also evaluate
> the shift in u64 to avoid truncation.
>
> Fixes: 2e1473d5195f ("erofs: implement 48-bit block addressing for unencoded inodes")
It's not the right fix, it should be efb2aef569b3 since
the pcluster layout only allows 32-bit addresssing for now.
> Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
> ---
> fs/erofs/inode.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
> index a188c570087a..cf2f00e13cae 100644
> --- a/fs/erofs/inode.c
> +++ b/fs/erofs/inode.c
> @@ -191,8 +191,9 @@ static int erofs_read_inode(struct inode *inode)
> err = -EFSCORRUPTED;
> goto err_out;
> } else {
> - inode->i_blocks = le32_to_cpu(copied.i_u.blocks_lo) <<
> - (sb->s_blocksize_bits - 9);
> + inode->i_blocks = ((u64)le16_to_cpu(copied.i_nb.blocks_hi) << 32 |
> + le32_to_cpu(copied.i_u.blocks_lo)) <<
> + (sb->s_blocksize_bits - 9);
I hope it could be:
inode->i_blocks = (le32_to_cpu(copied.i_u.blocks_lo) |
((u64)le16_to_cpu(copied.i_nb.blocks_hi) << 32)) <<
(sb->s_blocksize_bits - 9);
to explicitly use "()" and avoid overly long lines.
Thanks,
Gao Xiang
> }
>
> if (vi->datalayout == EROFS_INODE_CHUNK_BASED) {
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] erofs: handle 48-bit blocks_hi for compressed inodes
2026-06-22 7:43 ` Gao Xiang
@ 2026-06-22 8:11 ` Zhan Xusheng
2026-06-22 8:36 ` Gao Xiang
0 siblings, 1 reply; 4+ messages in thread
From: Zhan Xusheng @ 2026-06-22 8:11 UTC (permalink / raw)
To: Gao Xiang; +Cc: Gao Xiang, Chao Yu, linux-erofs, linux-kernel, Zhan Xusheng
Combine i_nb.blocks_hi with i_u.blocks_lo when computing
inode->i_blocks for compressed inodes, mirroring the startblk_hi
handling for unencoded inodes a few lines above. Also evaluate
the shift in u64 to avoid truncation.
Fixes: efb2aef569b3 ("erofs: add encoded extent on-disk definition")
Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
---
v2:
- Fix the Fixes: tag to efb2aef569b3 ("erofs: add encoded extent
on-disk definition"), the commit that introduced blocks_hi for
compressed inodes (Gao Xiang)
- Reorder to "blocks_lo | (blocks_hi << 32)" with explicit parentheses
and shorter lines (Gao Xiang)
fs/erofs/inode.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
index a188c570087a..dc0e3d6bb2b1 100644
--- a/fs/erofs/inode.c
+++ b/fs/erofs/inode.c
@@ -191,8 +191,9 @@ static int erofs_read_inode(struct inode *inode)
err = -EFSCORRUPTED;
goto err_out;
} else {
- inode->i_blocks = le32_to_cpu(copied.i_u.blocks_lo) <<
- (sb->s_blocksize_bits - 9);
+ inode->i_blocks = (le32_to_cpu(copied.i_u.blocks_lo) |
+ ((u64)le16_to_cpu(copied.i_nb.blocks_hi) << 32)) <<
+ (sb->s_blocksize_bits - 9);
}
if (vi->datalayout == EROFS_INODE_CHUNK_BASED) {
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] erofs: handle 48-bit blocks_hi for compressed inodes
2026-06-22 8:11 ` [PATCH v2] " Zhan Xusheng
@ 2026-06-22 8:36 ` Gao Xiang
0 siblings, 0 replies; 4+ messages in thread
From: Gao Xiang @ 2026-06-22 8:36 UTC (permalink / raw)
To: Zhan Xusheng; +Cc: Gao Xiang, Chao Yu, linux-erofs, linux-kernel, Zhan Xusheng
On 2026/6/22 16:11, Zhan Xusheng wrote:
> Combine i_nb.blocks_hi with i_u.blocks_lo when computing
> inode->i_blocks for compressed inodes, mirroring the startblk_hi
> handling for unencoded inodes a few lines above. Also evaluate
> the shift in u64 to avoid truncation.
>
> Fixes: efb2aef569b3 ("erofs: add encoded extent on-disk definition")
> Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
> ---
> v2:
> - Fix the Fixes: tag to efb2aef569b3 ("erofs: add encoded extent
> on-disk definition"), the commit that introduced blocks_hi for
> compressed inodes (Gao Xiang)
> - Reorder to "blocks_lo | (blocks_hi << 32)" with explicit parentheses
> and shorter lines (Gao Xiang)
>
> fs/erofs/inode.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
> index a188c570087a..dc0e3d6bb2b1 100644
> --- a/fs/erofs/inode.c
> +++ b/fs/erofs/inode.c
> @@ -191,8 +191,9 @@ static int erofs_read_inode(struct inode *inode)
> err = -EFSCORRUPTED;
> goto err_out;
> } else {
> - inode->i_blocks = le32_to_cpu(copied.i_u.blocks_lo) <<
> - (sb->s_blocksize_bits - 9);
> + inode->i_blocks = (le32_to_cpu(copied.i_u.blocks_lo) |
> + ((u64)le16_to_cpu(copied.i_nb.blocks_hi) << 32)) <<
I will change this line to
((u64)le16_to_cpu(copied.i_nb.blocks_hi) << 32)) <<
to avoid overly long lines (since such alignment is not strictly necessary
but overly long lines should be avoided), otherwise it looks good to me,
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Thanks,
Gao Xiang
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-22 8:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-22 7:34 [PATCH] erofs: handle 48-bit blocks_hi for compressed inodes Zhan Xusheng
2026-06-22 7:43 ` Gao Xiang
2026-06-22 8:11 ` [PATCH v2] " Zhan Xusheng
2026-06-22 8:36 ` 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®