[PATCH v3] erofs-utils: lib: fix incorrect nblocks in block list for chunked inodes
Hongzhen Luo
hongzhen at linux.alibaba.com
Wed Sep 11 18:55:31 AEST 2024
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 <hongzhen at linux.alibaba.com>
---
v3: Make the computed `extend_end` have impact on erofs_droid_blocklist_write_extent().
v2: https://lore.kernel.org/all/20240911083539.2111707-1-hongzhen@linux.alibaba.com/
v1: https://lore.kernel.org/all/20240911081020.2088531-1-hongzhen@linux.alibaba.com/
---
lib/blobchunk.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/blobchunk.c b/lib/blobchunk.c
index 33dadd5..6c2ea0e 100644
--- a/lib/blobchunk.c
+++ b/lib/blobchunk.c
@@ -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,6 +189,7 @@ int erofs_blob_write_chunk_indexes(struct erofs_inode *inode,
memcpy(inode->chunkindexes + dst, &idx, sizeof(idx));
}
off = roundup(off, unit);
+ extent_end = min(extent_end, extent_start + remaining_blks);
if (extent_start != EROFS_NULL_ADDR)
tarerofs_blocklist_write(extent_start, extent_end - extent_start,
source_offset);
--
2.43.5
More information about the Linux-erofs
mailing list