Skip to content

Commit 73b6dac

Browse files
calebsanderaxboe
authored andcommitted
io_uring/net: use REQ_F_IMPORT_BUFFER for send_zc
Instead of a bool field in struct io_sr_msg, use REQ_F_IMPORT_BUFFER to track whether io_send_zc() has already imported the buffer. This flag already serves a similar purpose for sendmsg_zc and {read,write}v_fixed. Signed-off-by: Caleb Sander Mateos <[email protected]> Suggested-by: Pavel Begunkov <[email protected]> Reviewed-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 8166197 commit 73b6dac

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

include/linux/io_uring_types.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,10 @@ enum {
585585
REQ_F_BUF_NODE = IO_REQ_FLAG(REQ_F_BUF_NODE_BIT),
586586
/* request has read/write metadata assigned */
587587
REQ_F_HAS_METADATA = IO_REQ_FLAG(REQ_F_HAS_METADATA_BIT),
588-
/* resolve padded iovec to registered buffers */
588+
/*
589+
* For vectored fixed buffers, resolve iovec to registered buffers.
590+
* For SEND_ZC, whether to import buffers (i.e. the first issue).
591+
*/
589592
REQ_F_IMPORT_BUFFER = IO_REQ_FLAG(REQ_F_IMPORT_BUFFER_BIT),
590593
};
591594

io_uring/net.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ struct io_sr_msg {
7777
/* initialised and used only by !msg send variants */
7878
u16 buf_group;
7979
bool retry;
80-
bool imported; /* only for io_send_zc */
8180
void __user *msg_control;
8281
/* used only for send zerocopy */
8382
struct io_kiocb *notif;
@@ -1307,7 +1306,6 @@ int io_send_zc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
13071306

13081307
zc->done_io = 0;
13091308
zc->retry = false;
1310-
zc->imported = false;
13111309
req->flags |= REQ_F_POLL_NO_LAZY;
13121310

13131311
if (unlikely(READ_ONCE(sqe->__pad2[0]) || READ_ONCE(sqe->addr3)))
@@ -1353,8 +1351,10 @@ int io_send_zc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
13531351

13541352
if (unlikely(!io_msg_alloc_async(req)))
13551353
return -ENOMEM;
1356-
if (req->opcode != IORING_OP_SENDMSG_ZC)
1354+
if (req->opcode == IORING_OP_SEND_ZC) {
1355+
req->flags |= REQ_F_IMPORT_BUFFER;
13571356
return io_send_setup(req, sqe);
1357+
}
13581358
return io_sendmsg_zc_setup(req, sqe);
13591359
}
13601360

@@ -1453,8 +1453,8 @@ int io_send_zc(struct io_kiocb *req, unsigned int issue_flags)
14531453
(zc->flags & IORING_RECVSEND_POLL_FIRST))
14541454
return -EAGAIN;
14551455

1456-
if (!zc->imported) {
1457-
zc->imported = true;
1456+
if (req->flags & REQ_F_IMPORT_BUFFER) {
1457+
req->flags &= ~REQ_F_IMPORT_BUFFER;
14581458
ret = io_send_zc_import(req, issue_flags);
14591459
if (unlikely(ret))
14601460
return ret;

0 commit comments

Comments
 (0)