Change erofs_importer_flush_all() to use max(). This allows callers to pre-allocate space for data beyond the metadata region.
Signed-off-by: Lucas Karpinski <[email protected]> --- lib/importer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/importer.c b/lib/importer.c index 26c86a0..56c8ea8 100644 --- a/lib/importer.c +++ b/lib/importer.c @@ -126,8 +126,9 @@ int erofs_importer_flush_all(struct erofs_importer *im) fsalignblks = im->params->fsalignblks ? roundup_pow_of_two(im->params->fsalignblks) : 1; - sbi->primarydevice_blocks = roundup(erofs_mapbh(sbi->bmgr, NULL), - fsalignblks); + sbi->primarydevice_blocks = max_t(erofs_blk_t, sbi->primarydevice_blocks, + roundup(erofs_mapbh(sbi->bmgr, NULL), + fsalignblks)); err = erofs_write_device_table(sbi); if (err) return err; -- Git-155)
