* [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
* [PATCH 2/2] erofs-utils: lib: fix direct S3 writes to blob devices
2026-09-07 8:30 [PATCH 1/2] erofs-utils: mkfs: resize blob devices as well Gao Xiang
@ 2026-09-07 8:30 ` Gao Xiang
2026-09-07 11:04 ` Yifan Zhao
0 siblings, 1 reply; 5+ messages in thread
From: Gao Xiang @ 2026-09-07 8:30 UTC (permalink / raw)
To: linux-erofs; +Cc: Yifan Zhao, Gao Xiang
From: Yifan Zhao <yifan.yfzhao@foxmail.com>
Direct S3 writes target the primary device and may leave the selected
blob device shorter than its allocated extent.
Write objects at device-relative offsets on the selected device.
and extend it to the final block boundary.
Assisted-by: Codex:gpt-5.6-sol
Signed-off-by: Yifan Zhao <yifan.yfzhao@foxmail.com>
Signed-off-by: Gao Xiang <xiang@kernel.org>
---
lib/remotes/s3.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/lib/remotes/s3.c b/lib/remotes/s3.c
index 56ab808..01dd1ff 100644
--- a/lib/remotes/s3.c
+++ b/lib/remotes/s3.c
@@ -1054,15 +1054,19 @@ static int s3erofs_remote_getobject(struct erofs_importer *im,
resp.pos = 0;
if (!sbi->available_compr_algs && im->params->no_datainline) {
+ unsigned int device_id = im->params->ddev_id_def;
+
inode->datalayout = EROFS_INODE_FLAT_PLAIN;
inode->idata_size = 0;
ret = erofs_allocate_inode_bh_data(inode,
DIV_ROUND_UP(inode->i_size, 1U << sbi->blkszbits),
- im->params->ddev_id_def);
+ device_id);
if (ret)
return ret;
- resp.vf = &sbi->bdev;
- resp.pos = erofs_pos(inode->sbi, inode->u.i_blkaddr);
+
+ resp.vf = device_id ?
+ sbi->devs[device_id - 1].bmgr->vf : &sbi->bdev;
+ resp.pos = erofs_pos(sbi, erofs_inode_dev_baddr(inode));
inode->datasource = EROFS_INODE_DATA_SOURCE_NONE;
} else {
if (!inode->i_diskbuf) {
@@ -1179,7 +1183,7 @@ int s3erofs_build_trees(struct erofs_importer *im, struct erofs_s3 *s3,
ret = __erofs_fill_inode(im, inode, &st, obj->key);
if (!ret && S_ISREG(inode->i_mode)) {
inode->i_size = obj->size;
- if (fillzero)
+ if (fillzero || !inode->i_size)
ret = erofs_write_zero_inode(inode);
else
ret = s3erofs_remote_getobject(im, s3, inode,
--
2.47.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] erofs-utils: lib: fix direct S3 writes to blob devices
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
0 siblings, 1 reply; 5+ messages in thread
From: Yifan Zhao @ 2026-09-07 11:04 UTC (permalink / raw)
To: Gao Xiang, linux-erofs
missing #include "liberofs_cache.h" in s3.c
remotes/s3.c: In function 's3erofs_remote_getobject':
remotes/s3.c:1068:54: error: invalid use of undefined type 'struct
erofs_bufmgr'
1068 | sbi->devs[device_id - 1].bmgr->vf :
&sbi->bdev;
Thanks,
Yifan
On 7/9/26 16:30, Gao Xiang wrote:
> From: Yifan Zhao <yifan.yfzhao@foxmail.com>
>
> Direct S3 writes target the primary device and may leave the selected
> blob device shorter than its allocated extent.
>
> Write objects at device-relative offsets on the selected device.
> and extend it to the final block boundary.
>
> Assisted-by: Codex:gpt-5.6-sol
> Signed-off-by: Yifan Zhao <yifan.yfzhao@foxmail.com>
> Signed-off-by: Gao Xiang <xiang@kernel.org>
> ---
> lib/remotes/s3.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/lib/remotes/s3.c b/lib/remotes/s3.c
> index 56ab808..01dd1ff 100644
> --- a/lib/remotes/s3.c
> +++ b/lib/remotes/s3.c
> @@ -1054,15 +1054,19 @@ static int s3erofs_remote_getobject(struct erofs_importer *im,
>
> resp.pos = 0;
> if (!sbi->available_compr_algs && im->params->no_datainline) {
> + unsigned int device_id = im->params->ddev_id_def;
> +
> inode->datalayout = EROFS_INODE_FLAT_PLAIN;
> inode->idata_size = 0;
> ret = erofs_allocate_inode_bh_data(inode,
> DIV_ROUND_UP(inode->i_size, 1U << sbi->blkszbits),
> - im->params->ddev_id_def);
> + device_id);
> if (ret)
> return ret;
> - resp.vf = &sbi->bdev;
> - resp.pos = erofs_pos(inode->sbi, inode->u.i_blkaddr);
> +
> + resp.vf = device_id ?
> + sbi->devs[device_id - 1].bmgr->vf : &sbi->bdev;
> + resp.pos = erofs_pos(sbi, erofs_inode_dev_baddr(inode));
> inode->datasource = EROFS_INODE_DATA_SOURCE_NONE;
> } else {
> if (!inode->i_diskbuf) {
> @@ -1179,7 +1183,7 @@ int s3erofs_build_trees(struct erofs_importer *im, struct erofs_s3 *s3,
> ret = __erofs_fill_inode(im, inode, &st, obj->key);
> if (!ret && S_ISREG(inode->i_mode)) {
> inode->i_size = obj->size;
> - if (fillzero)
> + if (fillzero || !inode->i_size)
> ret = erofs_write_zero_inode(inode);
> else
> ret = s3erofs_remote_getobject(im, s3, inode,
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] erofs-utils: lib: fix direct S3 writes to blob devices
2026-09-07 11:04 ` Yifan Zhao
@ 2026-09-07 14:16 ` Gao Xiang
2026-09-07 14:48 ` Yifan Zhao
0 siblings, 1 reply; 5+ messages in thread
From: Gao Xiang @ 2026-09-07 14:16 UTC (permalink / raw)
To: Yifan Zhao; +Cc: Gao Xiang, linux-erofs
Hi Yifan,
On Mon, Sep 07, 2026 at 07:04:18PM +0800, Yifan Zhao wrote:
> missing #include "liberofs_cache.h" in s3.c
>
> remotes/s3.c: In function 's3erofs_remote_getobject':
> remotes/s3.c:1068:54: error: invalid use of undefined type 'struct
> erofs_bufmgr'
> 1068 | sbi->devs[device_id - 1].bmgr->vf :
> &sbi->bdev;
>
I've fixed it up, could you check again?
Thanks,
Gao Xiang
>
> Thanks,
>
> Yifan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] erofs-utils: lib: fix direct S3 writes to blob devices
2026-09-07 14:16 ` Gao Xiang
@ 2026-09-07 14:48 ` Yifan Zhao
0 siblings, 0 replies; 5+ messages in thread
From: Yifan Zhao @ 2026-09-07 14:48 UTC (permalink / raw)
To: Gao Xiang, linux-erofs
On 9/7/2026 10:16 PM, Gao Xiang wrote:
> Hi Yifan,
>
> On Mon, Sep 07, 2026 at 07:04:18PM +0800, Yifan Zhao wrote:
>> missing #include "liberofs_cache.h" in s3.c
>>
>> remotes/s3.c: In function 's3erofs_remote_getobject':
>> remotes/s3.c:1068:54: error: invalid use of undefined type 'struct
>> erofs_bufmgr'
>> 1068 | sbi->devs[device_id - 1].bmgr->vf :
>> &sbi->bdev;
>>
> I've fixed it up, could you check again?
Tested-by: Yifan Zhao <yifan.yfzhao@foxmail.com>
> Thanks,
> Gao Xiang
>
>> Thanks,
>>
>> Yifan
^ permalink raw reply [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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox