From 5e4baccc46f27e47d532d3b7292bad79e72defc2 Mon Sep 17 00:00:00 2001 From: Ping Qiu Date: Tue, 10 Mar 2026 16:13:24 -0700 Subject: [PATCH] fix: use RequestSet.Requests() API for io_uring result iteration The iceber/iouring-go SubmitRequests returns a RequestSet interface which cannot be ranged over directly. Use resultSet.Done() to wait for all completions, then iterate resultSet.Requests(). Co-Authored-By: Claude Opus 4.6 --- .../storage/blockvol/batchio/iouring_linux.go | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/weed/storage/blockvol/batchio/iouring_linux.go b/weed/storage/blockvol/batchio/iouring_linux.go index fd71f265a..b927945a6 100644 --- a/weed/storage/blockvol/batchio/iouring_linux.go +++ b/weed/storage/blockvol/batchio/iouring_linux.go @@ -51,14 +51,15 @@ func (u *ioUringBatchIO) preadChunk(fd *os.File, ops []Op) error { requests[i] = iouring.Pread(fdInt, ops[i].Buf, uint64(ops[i].Offset)) } - results, err := u.ring.SubmitRequests(requests, nil) + resultSet, err := u.ring.SubmitRequests(requests, nil) if err != nil { return fmt.Errorf("iouring PreadBatch submit: %w", err) } - for i, res := range results { - <-res.Done() - n, err := res.ReturnInt() + // Wait for all completions before checking individual results. + <-resultSet.Done() + for i, req := range resultSet.Requests() { + n, err := req.ReturnInt() if err != nil { return fmt.Errorf("iouring PreadBatch op[%d]: %w", i, err) } @@ -93,14 +94,15 @@ func (u *ioUringBatchIO) pwriteChunk(fd *os.File, ops []Op) error { requests[i] = iouring.Pwrite(fdInt, ops[i].Buf, uint64(ops[i].Offset)) } - results, err := u.ring.SubmitRequests(requests, nil) + resultSet, err := u.ring.SubmitRequests(requests, nil) if err != nil { return fmt.Errorf("iouring PwriteBatch submit: %w", err) } - for i, res := range results { - <-res.Done() - n, err := res.ReturnInt() + // Wait for all completions before checking individual results. + <-resultSet.Done() + for i, req := range resultSet.Requests() { + n, err := req.ReturnInt() if err != nil { return fmt.Errorf("iouring PwriteBatch op[%d]: %w", i, err) } @@ -139,7 +141,7 @@ func (u *ioUringBatchIO) LinkedWriteFsync(fd *os.File, buf []byte, offset int64) // SubmitLinkRequests sets IOSQE_IO_LINK on all SQEs except the last, // ensuring the fdatasync executes only after the pwrite completes. - results, err := u.ring.SubmitLinkRequests( + resultSet, err := u.ring.SubmitLinkRequests( []iouring.PrepRequest{writeReq, fsyncReq}, nil, ) @@ -151,9 +153,10 @@ func (u *ioUringBatchIO) LinkedWriteFsync(fd *os.File, buf []byte, offset int64) return fdatasync(fd) } - for i, res := range results { - <-res.Done() - _, rerr := res.ReturnInt() + // Wait for all linked ops to complete, then check results. + <-resultSet.Done() + for i, req := range resultSet.Requests() { + _, rerr := req.ReturnInt() if rerr != nil { return fmt.Errorf("iouring LinkedWriteFsync op[%d]: %w", i, rerr) }