erofs-utils: lib: fix incorrect nblocks in block list for chunked inodes
PATCH v2 1/1 erofs-utils: lib: fix incorrect nblocks in block list for chunked inodes
Currently, the number of physical blocks (nblocks) for the last chunk written to the block list file is incorrectly recorded as the inode chunksize.
This patch writes the actual number of physical blocks for the inode in the last chunk to the block list file.
--- lib/blobchunk.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
lib/blobchunk.c +5 -1
@@ -133,6 +133,7 @@ static int erofs_blob_hashmap_cmp(const void *a, const void *b,int erofs_blob_write_chunk_indexes (struct erofs_inode *inode,erofs_off_t off) { +erofs_blk_t remaining_blks =BLK_ROUND_UP (inode->sbi, inode->i_size);struct erofs_inode_chunk_index idx = {0 };erofs_blk_t extent_start =EROFS_NULL_ADDR ;erofs_blk_t extent_end, chunkblks;
@@ -165,6 +166,7 @@ int erofs_blob_write_chunk_indexes(struct erofs_inode *inode,if (extent_start ==EROFS_NULL_ADDR || idx.blkaddr != extent_end) {if (extent_start !=EROFS_NULL_ADDR ) { + remaining_blks -= extent_end - extent_start;tarerofs_blocklist_write (extent_start, extent_end - extent_start, source_offset);
@@ -187,9 +189,11 @@ int erofs_blob_write_chunk_indexes(struct erofs_inode *inode,memcpy (inode->chunkindexes + dst, &idx,sizeof (idx)); } off =roundup (off, unit); -if (extent_start !=EROFS_NULL_ADDR ) +if (extent_start !=EROFS_NULL_ADDR ) { + extent_end =min (extent_end, extent_start + remaining_blks);tarerofs_blocklist_write (extent_start, extent_end - extent_start, source_offset); + } erofs_droid_blocklist_write_extent(inode, extent_start, extent_start == EROFS_NULL_ADDR ? 0 : extent_end - extent_start,
Signature · 1 line
2.43.5
Quoted 8 lines · Hongzhen Luo
Currently, the number of physical blocks (nblocks) for the last chunk written to the block list file is incorrectly recorded as the inode chunksize.
This patch writes the actual number of physical blocks for the inode in the last chunk to the block list file.
Signed-off-by Hongzhen Luo <[email protected]>
I guess it fixes
?
Quoted 24 lines
--- lib/blobchunk.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)lib/blobchunk.c +2
-0@@ -133,6 +133,7 @@ static int erofs_blob_hashmap_cmp(const void *a, const void *b,int erofs_blob_write_chunk_indexes (struct erofs_inode *inode,erofs_off_t off) { +erofs_blk_t remaining_blks =BLK_ROUND_UP (inode->sbi, inode->i_size); struct erofs_inode_chunk_index idx = {0};> erofs_blk_t extent_start = EROFS_NULL_ADDR;erofs_blk_t extent_end, chunkblks;@@ -165,6 +166,7 @@ int erofs_blob_write_chunk_indexes(struct erofs_inode *inode,if (extent_start ==EROFS_NULL_ADDR || idx.blkaddr != extent_end) {if (extent_start !=EROFS_NULL_ADDR ) { + remaining_blks -= extent_end - extent_start;tarerofs_blocklist_write (extent_start, extent_end - extent_start, source_offset);
lib/blobchunk.c int erofs_blob_write_chunk_indexes(struct erofs_inode *inode, · line 192
Quoted 5 lines
lib/blobchunk.c +1
-1@@ -187,9 +189,11 @@ int erofs_blob_write_chunk_indexes(struct erofs_inode *inode,memcpy (inode->chunkindexes + dst, &idx,sizeof (idx)); } off =roundup (off, unit); -if (extent_start !=EROFS_NULL_ADDR ) +if (extent_start !=EROFS_NULL_ADDR ) {
You should move extent_end out of this block since erofs_droid_blocklist_write_extent() is impacted too.
Thanks,
Gao Xiang
Quoted 10 lines · Gao Xiang
Quoted 7 lines · Hongzhen Luo
Currently, the number of physical blocks (nblocks) for the last chunk written to the block list file is incorrectly recorded as the inode chunksize.
This patch writes the actual number of physical blocks for the inode in the last chunk to the block list file.
Quoted 9 lines
Quoted 1 line
Signed-off-by Hongzhen Luo <[email protected]>I guess it fixes
Fixes 7b46f7a0160a ("erofs-utils: lib: merge consecutive chunks if possible")Fixes b6749839e710 ("erofs-utils: generate preallocated extents for tarerofs")?
Yes.
Quoted 29 lines
Quoted 29 lines
---
lib/blobchunk.c| 6 +++++-1 file changed, 5 insertions(+), 1 deletion(-)lib/blobchunk.c +1
-0@@ -133,6 +133,7 @@ static int erofs_blob_hashmap_cmp(const void *a,const void *b, int erofs_blob_write_chunk_indexes(struct erofs_inode *inode, erofs_off_t off) { + erofs_blk_t remaining_blks = BLK_ROUND_UP(inode->sbi, inode->i_size); struct erofs_inode_chunk_index idx = {0};> erofs_blk_t extent_start = EROFS_NULL_ADDR;
erofs_blk_textent_end, chunkblks;lib/blobchunk.c +0
-0@@ -165,6 +166,7 @@ int erofs_blob_write_chunk_indexes(struct erofs_inode *inode,if (
extent_start==EROFS_NULL_ADDR|| idx.blkaddr !=extent_end) {
if (extent_start!=EROFS_NULL_ADDR) { +remaining_blks-=extent_end-extent_start;tarerofs_blocklist_write(extent_start, extent_end - extent_start, source_offset);lib/blobchunk.c +0
-0@@ -187,9 +189,11 @@ int erofs_blob_write_chunk_indexes(struct erofs_inode *inode,
Quoted 8 lines
lib/blobchunk.c int erofs_blob_write_chunk_indexes(struct erofs_inode *inode, · line 192
Quoted 5 lines
lib/blobchunk.c +1
-1memcpy(inode->chunkindexes + dst, &idx, sizeof(idx)); } off = roundup(off, unit); - if (extent_start != EROFS_NULL_ADDR) + if (extent_start != EROFS_NULL_ADDR) {You should move
extent_endout of this block sinceerofs_droid_blocklist_write_extent()is impacted too.
Sure, i will fix this in the next patch.
Thanks,
Hongzhen
Quoted 3 lines
Thanks,
Gao Xiang