erofs: handle 48-bit blocks_hi for compressed inodes
PATCH 1/1 erofs: handle 48-bit blocks_hi for compressed inodes
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.
--- fs/erofs/inode.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/erofs/inode.c +3 -2
@@ -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 ) {
Signature · 1 line
2.43.0
Hi Xusheng,
Quoted 6 lines · Zhan Xusheng
Combine i_nb.blocks_hi with i_u.blocks_lo when computing
inode->i_blocksfor compressed inodes, mirroring thestartblk_hihandling 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.
Quoted 10 lines
Signed-off-by Zhan Xusheng <[email protected]>--- fs/erofs/inode.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)fs/erofs/inode.c +0
-0
fs/erofs/inode.c static int erofs_read_inode(struct inode *inode) · line 196
Quoted 8 lines
fs/erofs/inode.c +3
-2@@ -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
Quoted 3 lines
fs/erofs/inode.c +0
-0}if (vi->datalayout ==EROFS_INODE_CHUNK_BASED ) {
PATCH v2 1/1 erofs: handle 48-bit blocks_hi for compressed inodes
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.
---
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(-)
fs/erofs/inode.c +3 -2
@@ -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 ) {
Signature · 1 line
2.43.0
Quoted 23 lines · Zhan Xusheng
Combine i_nb.blocks_hi with i_u.blocks_lo when computing
inode->i_blocksfor compressed inodes, mirroring thestartblk_hihandling 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 <[email protected]>---
v2:
- Fix the Fixes: tag toefb2aef569b3("erofs: add encoded extent on-disk definition"), the commit that introducedblocks_hifor 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(-)fs/erofs/inode.c +0
-0
fs/erofs/inode.c static int erofs_read_inode(struct inode *inode) · line 195
Quoted 7 lines
fs/erofs/inode.c +2
-2@@ -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,
Thanks,
Gao Xiang