Skip to content

Commit 3515a2a

Browse files
joannekoongaxboe
authored andcommitted
io_uring/cmd: set selected buffer index in __io_uring_cmd_done()
When uring_cmd operations select a buffer, the completion queue entry should indicate which buffer was selected. Set IORING_CQE_F_BUFFER on the completed entry and encode the buffer index if a buffer was selected. This change is needed in order to relay to userspace which selected buffer contains the data. Signed-off-by: Joanne Koong <joannelkoong@gmail.com> Link: https://patch.msgid.link/20260306003224.3620942-9-joannelkoong@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 4706d1f commit 3515a2a

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

io_uring/uring_cmd.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ void __io_uring_cmd_done(struct io_uring_cmd *ioucmd, s32 ret, u64 res2,
151151
unsigned issue_flags, bool is_cqe32)
152152
{
153153
struct io_kiocb *req = cmd_to_io_kiocb(ioucmd);
154+
u32 cflags = 0;
154155

155156
if (WARN_ON_ONCE(req->flags & REQ_F_APOLL_MULTISHOT))
156157
return;
@@ -160,7 +161,10 @@ void __io_uring_cmd_done(struct io_uring_cmd *ioucmd, s32 ret, u64 res2,
160161
if (ret < 0)
161162
req_set_fail(req);
162163

163-
io_req_set_res(req, ret, 0);
164+
if (req->flags & (REQ_F_BUFFER_SELECTED | REQ_F_BUFFER_RING))
165+
cflags |= IORING_CQE_F_BUFFER |
166+
(req->buf_index << IORING_CQE_BUFFER_SHIFT);
167+
io_req_set_res(req, ret, cflags);
164168
if (is_cqe32) {
165169
if (req->ctx->flags & IORING_SETUP_CQE_MIXED)
166170
req->cqe.flags |= IORING_CQE_F_32;

0 commit comments

Comments
 (0)