erofs-utils: fix incremental builds for tarerofs index mode
authorGao Xiang <hsiangkao@linux.alibaba.com>
Tue, 18 Jun 2024 08:24:12 +0000 (16:24 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Wed, 19 Jun 2024 03:11:32 +0000 (11:11 +0800)
The blob data area should be considered in the total block number to
prevent overlap during incremental builds.

Fixes: b6749839e710 ("erofs-utils: generate preallocated extents for tarerofs")
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20240618082414.47876-7-hsiangkao@linux.alibaba.com
lib/blobchunk.c

index dc1bf3c5ed63f152a4eaf0dcbb31ae95dee2b672..9af223dd1f33650ec7b7b12de39a225cbbb8239c 100644 (file)
@@ -517,7 +517,7 @@ int erofs_mkfs_dump_blobs(struct erofs_sb_info *sbi)
                return 0;
        }
 
-       bh = erofs_balloc(DATA, blobfile ? datablob_size : 0, 0, 0);
+       bh = erofs_balloc(DATA, datablob_size, 0, 0);
        if (IS_ERR(bh))
                return PTR_ERR(bh);
 
@@ -532,7 +532,7 @@ int erofs_mkfs_dump_blobs(struct erofs_sb_info *sbi)
                                sbi->bdev.fd, &pos_out, datablob_size);
                ret = ret < datablob_size ? -EIO : 0;
        } else {
-               ret = 0;
+               ret = erofs_io_ftruncate(&sbi->bdev, pos_out + datablob_size);
        }
        bh->op = &erofs_drop_directly_bhops;
        erofs_bdrop(bh, false);