Linux-EROFS Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Gao Xiang <xiang@kernel.org>
To: linux-erofs@lists.ozlabs.org
Cc: Gao Xiang <xiang@kernel.org>
Subject: [PATCH 1/2] erofs-utils: mkfs: resize blob devices as well
Date: Mon,  7 Sep 2026 16:30:26 +0800	[thread overview]
Message-ID: <20260907083027.13793-1-xiang@kernel.org> (raw)

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



             reply	other threads:[~2026-09-07  8:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-07  8:30 Gao Xiang [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260907083027.13793-1-xiang@kernel.org \
    --to=xiang@kernel.org \
    --cc=linux-erofs@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox