[PATCH v2] erofs-utils: lib: fix incorrect nblocks in block list for chunked inodes

Hongzhen Luo hongzhen at linux.alibaba.com
Wed Sep 11 18:46:09 AEST 2024


On 2024/9/11 16:41, Gao Xiang wrote:
>
>
> On 2024/9/11 16:35, Hongzhen Luo wrote:
>> 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>
>
> I guess it fixes
>
> Fixes: 7b46f7a0160a ("erofs-utils: lib: merge consecutive chunks if 
> possible")
> Fixes: b6749839e710 ("erofs-utils: generate preallocated extents for 
> tarerofs")
>
> ?
>
Yes.
>
>> ---
>>   lib/blobchunk.c | 6 +++++-
>>   1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/lib/blobchunk.c b/lib/blobchunk.c
>> index 33dadd5..a0f3d0e 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,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.

Sure, i will fix this in the next patch.

Thanks,

Hongzhen

>
> Thanks,
> Gao Xiang


More information about the Linux-erofs mailing list