[PATCH 1/3] erofs-utils: lib: s3: fix diskbuf commit size
Yifan Zhao
zhaoyifan28 at huawei.com
Tue Jan 13 17:11:47 AEDT 2026
Currently, when calling erofs_diskbuf_commit() in the S3 code, the
argument passed is `resp.end - resp.pos`. This value is always zero upon
a successful GetObject operation, making erofs_diskbuf_commit() a no-op.
It should use the modified `resp.pos` in s3erofs_remote_getobject_cb()
minus its original value instead.
Fixes: 093c7e2f97a1 ("erofs-utils: mkfs: support full image generation from S3")
Signed-off-by: Yifan Zhao <zhaoyifan28 at huawei.com>
---
lib/remotes/s3.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/lib/remotes/s3.c b/lib/remotes/s3.c
index 296df61..3426585 100644
--- a/lib/remotes/s3.c
+++ b/lib/remotes/s3.c
@@ -980,6 +980,7 @@ static int s3erofs_remote_getobject(struct erofs_importer *im,
struct s3erofs_curl_request req = {};
struct s3erofs_curl_getobject_resp resp;
struct erofs_vfile vf;
+ u64 diskbuf_off;
int ret;
ret = s3erofs_prepare_url(&req, s3->endpoint, bucket, key, NULL,
@@ -1003,8 +1004,6 @@ static int s3erofs_remote_getobject(struct erofs_importer *im,
resp.pos = erofs_pos(inode->sbi, inode->u.i_blkaddr);
inode->datasource = EROFS_INODE_DATA_SOURCE_NONE;
} else {
- u64 off;
-
if (!inode->i_diskbuf) {
inode->i_diskbuf = calloc(1, sizeof(*inode->i_diskbuf));
if (!inode->i_diskbuf)
@@ -1014,10 +1013,10 @@ static int s3erofs_remote_getobject(struct erofs_importer *im,
}
vf = (struct erofs_vfile) {.fd =
- erofs_diskbuf_reserve(inode->i_diskbuf, 0, &off)};
+ erofs_diskbuf_reserve(inode->i_diskbuf, 0, &diskbuf_off)};
if (vf.fd < 0)
return -EBADF;
- resp.pos = off;
+ resp.pos = diskbuf_off;
resp.vf = &vf;
inode->datasource = EROFS_INODE_DATA_SOURCE_DISKBUF;
}
@@ -1025,7 +1024,7 @@ static int s3erofs_remote_getobject(struct erofs_importer *im,
ret = s3erofs_request_perform(s3, &req, &resp);
if (resp.vf == &vf) {
- erofs_diskbuf_commit(inode->i_diskbuf, resp.end - resp.pos);
+ erofs_diskbuf_commit(inode->i_diskbuf, resp.pos - diskbuf_off);
if (ret) {
erofs_diskbuf_close(inode->i_diskbuf);
inode->i_diskbuf = NULL;
--
2.47.3
More information about the Linux-erofs
mailing list