All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] erofs-utils: mkfs: resize blob devices as well
@ 2026-09-07  8:30 Gao Xiang
  2026-09-07  8:30 ` [PATCH 2/2] erofs-utils: lib: fix direct S3 writes to blob devices Gao Xiang
  0 siblings, 1 reply; 5+ messages in thread
From: Gao Xiang @ 2026-09-07  8:30 UTC (permalink / raw)
  To: linux-erofs; +Cc: Gao Xiang

Introduce erofs_flush_all_devices() to truncate both the primary device
and all extra blob devices according to their recorded block counts.

Signed-off-by: Gao Xiang <xiang@kernel.org>
---
 include/erofs/internal.h |  7 +------
 lib/super.c              | 18 ++++++++++++++++++
 mkfs/main.c              |  3 +--
 3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/include/erofs/internal.h b/include/erofs/internal.h
index 4d09c58..04775cc 100644
--- a/include/erofs/internal.h
+++ b/include/erofs/internal.h
@@ -468,6 +468,7 @@ int erofs_superblock_csum_verify(struct erofs_sb_info *sbi);
 int erofs_mkfs_format_fs(struct erofs_sb_info *sbi, unsigned int blkszbits,
 			 unsigned int dsunit, bool metazone);
 int erofs_mkfs_load_fs(struct erofs_sb_info *sbi, unsigned int dsunit);
+int erofs_flush_all_devices(struct erofs_sb_info *sbi);
 
 /* namei.c */
 int erofs_read_inode_from_disk(struct erofs_inode *vi);
@@ -543,12 +544,6 @@ static inline int erofs_dev_write(struct erofs_sb_info *sbi, const void *buf,
 	return 0;
 }
 
-static inline int erofs_dev_resize(struct erofs_sb_info *sbi,
-				   erofs_blk_t blocks)
-{
-	return erofs_io_ftruncate(&sbi->bdev, (u64)blocks * erofs_blksiz(sbi));
-}
-
 static inline int erofs_blk_write(struct erofs_sb_info *sbi, const void *buf,
 				  erofs_blk_t blkaddr, u32 nblocks)
 {
diff --git a/lib/super.c b/lib/super.c
index 2bb22ac..b1b3ab6 100644
--- a/lib/super.c
+++ b/lib/super.c
@@ -525,3 +525,21 @@ int erofs_mkfs_load_fs(struct erofs_sb_info *sbi, unsigned int dsunit)
 	bmgr->dsunit = dsunit;
 	return 0;
 }
+
+int erofs_flush_all_devices(struct erofs_sb_info *sbi)
+{
+	struct erofs_device_info *di;
+	int err;
+
+	err = erofs_io_ftruncate(&sbi->bdev,
+				 (erofs_off_t)sbi->dif0.blocks << sbi->blkszbits);
+	if (err)
+		return err;
+	for (di = sbi->devs; di < sbi->devs + sbi->extra_devices; ++di) {
+		err = erofs_io_ftruncate(di->bmgr->vf,
+				(erofs_off_t)di->blocks << sbi->blkszbits);
+		if (err)
+			return err;
+	}
+	return 0;
+}
diff --git a/mkfs/main.c b/mkfs/main.c
index cfdffa5..d9b4e22 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -2062,8 +2062,7 @@ int main(int argc, char **argv)
 	if (err)
 		goto exit;
 
-	err = erofs_dev_resize(&g_sbi, g_sbi.dif0.blocks);
-
+	err = erofs_flush_all_devices(&g_sbi);
 	if (!err && erofs_sb_has_sb_chksum(&g_sbi)) {
 		err = erofs_enable_sb_chksum(&g_sbi, &crc);
 		if (!err)
-- 
2.47.3



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

end of thread, other threads:[~2026-09-07 14:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-07  8:30 [PATCH 1/2] erofs-utils: mkfs: resize blob devices as well Gao Xiang
2026-09-07  8:30 ` [PATCH 2/2] erofs-utils: lib: fix direct S3 writes to blob devices Gao Xiang
2026-09-07 11:04   ` Yifan Zhao
2026-09-07 14:16     ` Gao Xiang
2026-09-07 14:48       ` Yifan Zhao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.