Skip to content

Commit 2bb04df

Browse files
Stefan Roeschaxboe
authored andcommitted
io_uring: support CQE32 for nop operation
This adds support for filling the extra1 and extra2 fields for large CQE's. Co-developed-by: Jens Axboe <[email protected]> Signed-off-by: Stefan Roesch <[email protected]> Reviewed-by: Kanchan Joshi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 76c68fb commit 2bb04df

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

fs/io_uring.c

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,12 @@ struct io_msg {
767767
u32 len;
768768
};
769769

770+
struct io_nop {
771+
struct file *file;
772+
u64 extra1;
773+
u64 extra2;
774+
};
775+
770776
struct io_async_connect {
771777
struct sockaddr_storage address;
772778
};
@@ -965,6 +971,7 @@ struct io_kiocb {
965971
struct io_msg msg;
966972
struct io_xattr xattr;
967973
struct io_socket sock;
974+
struct io_nop nop;
968975
};
969976

970977
u8 opcode;
@@ -5040,12 +5047,29 @@ static int io_splice(struct io_kiocb *req, unsigned int issue_flags)
50405047
return 0;
50415048
}
50425049

5050+
static int io_nop_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
5051+
{
5052+
/*
5053+
* If the ring is setup with CQE32, relay back addr/addr
5054+
*/
5055+
if (req->ctx->flags & IORING_SETUP_CQE32) {
5056+
req->nop.extra1 = READ_ONCE(sqe->addr);
5057+
req->nop.extra2 = READ_ONCE(sqe->addr2);
5058+
}
5059+
5060+
return 0;
5061+
}
5062+
50435063
/*
50445064
* IORING_OP_NOP just posts a completion event, nothing else.
50455065
*/
50465066
static int io_nop(struct io_kiocb *req, unsigned int issue_flags)
50475067
{
5048-
__io_req_complete(req, issue_flags, 0, 0);
5068+
if (!(req->ctx->flags & IORING_SETUP_CQE32))
5069+
__io_req_complete(req, issue_flags, 0, 0);
5070+
else
5071+
__io_req_complete32(req, issue_flags, 0, 0, req->nop.extra1,
5072+
req->nop.extra2);
50495073
return 0;
50505074
}
50515075

@@ -7647,7 +7671,7 @@ static int io_req_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
76477671
{
76487672
switch (req->opcode) {
76497673
case IORING_OP_NOP:
7650-
return 0;
7674+
return io_nop_prep(req, sqe);
76517675
case IORING_OP_READV:
76527676
case IORING_OP_READ_FIXED:
76537677
case IORING_OP_READ:

0 commit comments

Comments
 (0)