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 <noreply@anthropic.com>
This commit is contained in:
Ping Qiu
2026-03-10 16:13:24 -07:00
co-authored by Claude Opus 4.6
parent 9d0ec8efa3
commit 5e4baccc46
+15 -12
View File
@@ -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)
}