From: Gao Xiang <xiang@kernel.org>
To: linux-erofs@lists.ozlabs.org
Cc: Yifan Zhao <yifan.yfzhao@foxmail.com>, Gao Xiang <xiang@kernel.org>
Subject: [PATCH 2/2] erofs-utils: lib: fix direct S3 writes to blob devices
Date: Mon, 7 Sep 2026 16:30:27 +0800 [thread overview]
Message-ID: <20260907083027.13793-2-xiang@kernel.org> (raw)
In-Reply-To: <20260907083027.13793-1-xiang@kernel.org>
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
next prev parent 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 [PATCH 1/2] erofs-utils: mkfs: resize blob devices as well Gao Xiang
2026-09-07 8:30 ` Gao Xiang [this message]
2026-09-07 11:04 ` [PATCH 2/2] erofs-utils: lib: fix direct S3 writes to blob devices 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-2-xiang@kernel.org \
--to=xiang@kernel.org \
--cc=linux-erofs@lists.ozlabs.org \
--cc=yifan.yfzhao@foxmail.com \
/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