From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B7C6FF55449 for ; Wed, 25 Feb 2026 03:55:23 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4fLLMt0m76z3dK1; Wed, 25 Feb 2026 14:55:22 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=115.124.30.112 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1771991722; cv=none; b=CX3t4peUsorAWnXn1YjxhV4Q+XfMvNKQhv/bIkwcYOmfrgnp+iDH9xijspWQyHYo0ES9hiFuetCkil1nxVWF89jwLEVfYWoAkGvzuSfsRPoauAYtd3H7ZTHMfsV6A1YdwYm/4eyMo7Vp+22I7trShXbVA9+3C+3cw8tlZ69sJaxgugjW49WdAOUVBXoHmirBEIVWXzAj4TgB2854TqEgcufJJI8yluVCJWF4lJUde2K5KsH219zhhKiud5WamUnP5sS5xsaJ5NNOiC8vBNiaSKM1GXmfsooiVBxJCAZaPl80oucYQDDqR9E1eQJDVLeEVoUMwauWJLmqQBJcXEU4Cg== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1771991722; c=relaxed/relaxed; bh=rOaNlOKYE9wnK/GNUdS/PG4m0qPTZlR0nzr8wXLPraQ=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=JASdDK/bVFG/pw9zggadoxyjeJI3mawZiD/ATLlq338AjtYmMMwAWuw6itbZKVHqEMuynnFgQw6hXTRRVasaDI4k8jd5bzBtB1GqzQfdaPIx+UHX/xfAnRKXH+NPRD2UKgxrsan965j+XrznD4Z4FRUlyUjXJolUpcgyZMY2aRdXoCYHPZe5tVizHfy5yjQHXc45Q5gi7+PX2AbxuxZnJ3zz6ewQKKsbHdWAkfbqHLg8tIxyE/LwlFlAxqTeMPLi9zF43iBcV+7JeO7oibhNpnvWcpADLH/caSlhrkZ8ze9UpMC/8ajeTPm+Ea4IumEFu/jDgdIVvNdIZnNXcfWHng== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; dkim=pass (1024-bit key; unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=PgZUm2Ye; dkim-atps=neutral; spf=pass (client-ip=115.124.30.112; helo=out30-112.freemail.mail.aliyun.com; envelope-from=hsiangkao@linux.alibaba.com; receiver=lists.ozlabs.org) smtp.mailfrom=linux.alibaba.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=PgZUm2Ye; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.alibaba.com (client-ip=115.124.30.112; helo=out30-112.freemail.mail.aliyun.com; envelope-from=hsiangkao@linux.alibaba.com; receiver=lists.ozlabs.org) Received: from out30-112.freemail.mail.aliyun.com (out30-112.freemail.mail.aliyun.com [115.124.30.112]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4fLLMn1G2Kz3dJg for ; Wed, 25 Feb 2026 14:55:15 +1100 (AEDT) DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1771991708; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=rOaNlOKYE9wnK/GNUdS/PG4m0qPTZlR0nzr8wXLPraQ=; b=PgZUm2Yet4yWM2/Kc07jZ5r1HGR0JL5hpoK99JgnN3wzIywMDsPVnrG2gbP2xQk1nYq746BIp3TudfvK/y4BOZwud6ulRUi6p2NUXpnTN0yIzvFh8bSF50XcW03JJfp6pijc88bP2/BFy/VsW70hq760LxQbjfeVCju/5FzC5go= Received: from 30.221.131.204(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0WzlBM5P_1771991707 cluster:ay36) by smtp.aliyun-inc.com; Wed, 25 Feb 2026 11:55:07 +0800 Message-ID: <616015da-0938-44e2-9cb3-4d6bb37d8cd2@linux.alibaba.com> Date: Wed, 25 Feb 2026 11:55:06 +0800 X-Mailing-List: linux-erofs@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] erofs-utils: lib: fix 48bit addressing detection for chunk-based format To: puneeth_aditya_5656 , linux-erofs@lists.ozlabs.org References: <20260224055712.14110-1-myakampuneeth@gmail.com> <20260224191316.2294-1-myakampuneeth@gmail.com> From: Gao Xiang In-Reply-To: <20260224191316.2294-1-myakampuneeth@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2026/2/25 03:13, puneeth_aditya_5656 wrote: > The 48-bit chunk format flag was being set inside > erofs_blob_write_chunked_file right after erofs_blob_getchunk returns. > At that point chunk->blkaddr is the chunk's offset in the temporary > blob buffer, not the final image address. The real address is only > known after erofs_mkfs_dump_blobs applies remapped_base. > > This means the detection was unreliable in both directions: a chunk > whose blob offset looks large but fits in 32-bits after remapping gets > flagged unnecessarily, and worse, a chunk that lands above UINT32_MAX I think the first case is impossible for the current remapping mechanism. > after remapping may not get flagged at all, producing a corrupt image. > > Fix this by introducing erofs_inode_fixup_chunkformat() which walks > the chunk array after remapped_base is finalized and sets the 48-bit > flag if any chunk address exceeds UINT32_MAX. The fixup is called from > erofs_iflush so that the correct chunkformat is written into the > on-disk inode header. Both blob chunks (remapped_base + chunk->blkaddr) > and device chunks (chunk->blkaddr directly) are handled. > > Signed-off-by: Puneeth Aditya > --- > include/erofs/blobchunk.h | 1 + > lib/blobchunk.c | 40 +++++++++++++++++++++++++++++++++++---- > lib/inode.c | 2 ++ > 3 files changed, 39 insertions(+), 4 deletions(-) > > diff --git a/include/erofs/blobchunk.h b/include/erofs/blobchunk.h > index ef06773..48fca63 100644 > --- a/include/erofs/blobchunk.h > +++ b/include/erofs/blobchunk.h > @@ -16,6 +16,7 @@ extern "C" > > struct erofs_blobchunk *erofs_get_unhashed_chunk(unsigned int device_id, > erofs_blk_t blkaddr, erofs_off_t sourceoffset); > +void erofs_inode_fixup_chunkformat(struct erofs_inode *inode); > int erofs_write_chunk_indexes(struct erofs_inode *inode, struct erofs_vfile *vf, > erofs_off_t off); > int erofs_blob_write_chunked_file(struct erofs_inode *inode, int fd, > diff --git a/lib/blobchunk.c b/lib/blobchunk.c > index a051904..96c161b 100644 > --- a/lib/blobchunk.c > +++ b/lib/blobchunk.c > @@ -136,6 +136,42 @@ static int erofs_blob_hashmap_cmp(const void *a, const void *b, > sizeof(ec1->sha256)); > } > ... > + > int erofs_write_chunk_indexes(struct erofs_inode *inode, struct erofs_vfile *vf, > erofs_off_t off) > { > @@ -380,10 +416,6 @@ int erofs_blob_write_chunked_file(struct erofs_inode *inode, int fd, > goto err; > } > > - /* FIXME! `chunk->blkaddr` is not the final blkaddr here */ > - if (chunk->blkaddr != EROFS_NULL_ADDR && > - chunk->blkaddr >= UINT32_MAX) > - inode->u.chunkformat |= EROFS_CHUNK_FORMAT_48BIT; > if (!erofs_blob_can_merge(sbi, lastch, chunk)) { > erofs_update_minextblks(sbi, interval_start, pos, > &minextblks); > diff --git a/lib/inode.c b/lib/inode.c > index 4a214f9..25087ca 100644 > --- a/lib/inode.c > +++ b/lib/inode.c > @@ -794,6 +794,8 @@ int erofs_iflush(struct erofs_inode *inode) > } else if (is_inode_layout_compression(inode)) { > u1.blocks_lo = cpu_to_le32(inode->u.i_blocks); > } else if (inode->datalayout == EROFS_INODE_CHUNK_BASED) { > + if (inode->chunkindexes) It's a useless check, just remove this. Thanks, Gao Xiang