Skip to content

Commit cb94873

Browse files
isilenceaxboe
authored andcommitted
io_uring/zctx: separate notification user_data
People previously asked for the notification CQE to have a different user_data value from the main request completion. It's useful to separate buffer and request handling logic and avoid separately refcounting the request. Let the user pass the notification user_data in sqe->addr3. If zero, it'll inherit sqe->user_data as before. It doesn't change the rules for when the user can expect a notification CQE, and it should still check the IORING_CQE_F_MORE flag. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent dce00c8 commit cb94873

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

io_uring/net.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,11 +1333,12 @@ int io_send_zc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
13331333
struct io_ring_ctx *ctx = req->ctx;
13341334
struct io_async_msghdr *iomsg;
13351335
struct io_kiocb *notif;
1336+
u64 user_data;
13361337
int ret;
13371338

13381339
zc->done_io = 0;
13391340

1340-
if (unlikely(READ_ONCE(sqe->__pad2[0]) || READ_ONCE(sqe->addr3)))
1341+
if (unlikely(READ_ONCE(sqe->__pad2[0])))
13411342
return -EINVAL;
13421343
/* we don't support IOSQE_CQE_SKIP_SUCCESS just yet */
13431344
if (req->flags & REQ_F_CQE_SKIP)
@@ -1346,7 +1347,11 @@ int io_send_zc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
13461347
notif = zc->notif = io_alloc_notif(ctx);
13471348
if (!notif)
13481349
return -ENOMEM;
1349-
notif->cqe.user_data = req->cqe.user_data;
1350+
user_data = READ_ONCE(sqe->addr3);
1351+
if (!user_data)
1352+
user_data = req->cqe.user_data;
1353+
1354+
notif->cqe.user_data = user_data;
13501355
notif->cqe.res = 0;
13511356
notif->cqe.flags = IORING_CQE_F_NOTIF;
13521357
req->flags |= REQ_F_NEED_CLEANUP | REQ_F_POLL_NO_LAZY;

0 commit comments

Comments
 (0)