public inbox for linux-erofs@ozlabs.org
 help / color / mirror / Atom feed
* [PATCH] blobchunk: fix 48-bit format detection to use final remapped block addresses
@ 2026-02-24  5:57 puneeth_aditya_5656
  2026-02-24  6:44 ` Gao Xiang
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: puneeth_aditya_5656 @ 2026-02-24  5:57 UTC (permalink / raw)
  To: linux-erofs; +Cc: hsiangkao, puneeth_aditya_5656

---
 lib/blobchunk.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/lib/blobchunk.c b/lib/blobchunk.c
index a051904..9b8112b 100644
--- a/lib/blobchunk.c
+++ b/lib/blobchunk.c
@@ -154,6 +154,19 @@ int erofs_write_chunk_indexes(struct erofs_inode *inode, struct erofs_vfile *vf,
 		unit = EROFS_BLOCK_MAP_ENTRY_SIZE;
 
 	chunkblks = 1ULL << (inode->u.chunkformat & EROFS_CHUNK_FORMAT_BLKBITS_MASK);
+
+	/* check if any chunk lands above 32-bit range once remapped_base is applied */
+	for (src = 0; src < inode->extent_isize / unit * sizeof(void *);
+	     src += sizeof(void *)) {
+		struct erofs_blobchunk *chunk = *(void **)(inode->chunkindexes + src);
+
+		if (chunk->blkaddr != EROFS_NULL_ADDR && !chunk->device_id &&
+		    remapped_base + chunk->blkaddr > UINT32_MAX) {
+			inode->u.chunkformat |= EROFS_CHUNK_FORMAT_48BIT;
+			break;
+		}
+	}
+
 	_48bit = inode->u.chunkformat & EROFS_CHUNK_FORMAT_48BIT;
 	for (dst = src = 0; dst < inode->extent_isize;
 	     src += sizeof(void *), dst += unit) {
@@ -380,10 +393,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);
-- 
2.52.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-02-25  8:19 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-24  5:57 [PATCH] blobchunk: fix 48-bit format detection to use final remapped block addresses puneeth_aditya_5656
2026-02-24  6:44 ` Gao Xiang
2026-02-24 16:37 ` [PATCH v2] erofs-utils: lib: fix 48bit addressing detection for chunk-based format puneeth_aditya_5656
2026-02-24 17:44   ` Gao Xiang
2026-02-24 19:10 ` puneeth_aditya_5656
2026-02-24 19:13 ` [PATCH v3] " puneeth_aditya_5656
2026-02-25  3:55   ` Gao Xiang
2026-02-25  7:39 ` [PATCH v4] " puneeth_aditya_5656
2026-02-25  8:19   ` Gao Xiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox