From ec6ced48bfd7db617793739faadca6ca7843919c Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 19 Oct 2022 18:18:57 -0700 Subject: [PATCH] man/io_uring_get_sqe.3: add note about SQE -> CQE user_data passing Anyone reaping a request completion and expecting the cqe->user_data field to be valid, MUST have ensured to set it before submitting the SQE. If one of the sqe_set_data() helpers aren't called for this, calling any of the cqe_get_data() helpers will return uninitialized data as it was never set. Link: https://github.com/axboe/liburing/issues/690 Signed-off-by: Jens Axboe --- man/io_uring_get_sqe.3 | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/man/io_uring_get_sqe.3 b/man/io_uring_get_sqe.3 index 58c8b96f..ce446142 100644 --- a/man/io_uring_get_sqe.3 +++ b/man/io_uring_get_sqe.3 @@ -32,10 +32,24 @@ prep functions such as and submitted via .BR io_uring_submit (3). +Note that the prep functions don't set the +.B user_data +field of the SQE, that is left to the caller. If the caller expects +.BR io_uring_cqe_get_data (3) +or +.BR io_uring_cqe_get_data64 (3) +to return valid data when reaping IO completions, either +.BR io_uring_sqe_set_data (3) +or +.BR io_uring_sqe_set_data64 (3) +.B MUST +have been called submitting the request. + .SH RETURN VALUE .BR io_uring_get_sqe (3) returns a pointer to the next submission queue event on success and NULL on failure. If NULL is returned, the SQ ring is currently full and entries must be submitted for processing before new ones can get allocated. .SH SEE ALSO -.BR io_uring_submit (3) +.BR io_uring_submit (3), +.BR io_uring_sqe_set_data (3)