io_uring: return void from io_put_kbuf_comp()
PATCH 1/1 io_uring: return void from io_put_kbuf_comp()
The two callers don't handle the return value of io_put_kbuf_comp(), so change its return type into void.
--- io_uring/kbuf.h | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
io_uring/kbuf.h +3 -9
@@ -119,18 +119,12 @@ static inline void __io_put_kbuf_list(struct io_kiocb *req, } } -static inline unsigned int io_put_kbuf_comp (struct io_kiocb *req) +static inline void io_put_kbuf_comp (struct io_kiocb *req) { -unsigned int ret; -lockdep_assert_held (&req->ctx->completion_lock); -if (!(req->flags & (REQ_F_BUFFER_SELECTED |REQ_F_BUFFER_RING ))) -return 0 ; - - ret =IORING_CQE_F_BUFFER | (req->buf_index <<IORING_CQE_BUFFER_SHIFT ); -__io_put_kbuf_list (req, &req->ctx->io_buffers_comp); -return ret; +if (req->flags & (REQ_F_BUFFER_SELECTED |REQ_F_BUFFER_RING )) +__io_put_kbuf_list (req, &req->ctx->io_buffers_comp); } static inline unsigned int io_put_kbuf(struct io_kiocb *req,
Signature · 1 line
2.41.0
Jens Axboe
maintainerQuoted 2 lines · Ming Lei
The two callers don't handle the return value of
io_put_kbuf_comp(), so change its return type into void.
We might want to consider changing the name of it too, it's a bit different in that it's just recyling/dropping this kbuf rather than posting a completion on behalf of it.
Maybe io_kbuf_drop() would be better. Would distuingish it from the normal use cases of "drop this kbuf and return the cflags representation of it, as I'm posting a completionw ith it".
Quoted 19 lines
Signed-off-by Ming Lei <[email protected]>--- io_uring/kbuf.h | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)io_uring/kbuf.h +1
-3@@ -119,18 +119,12 @@ static inline void __io_put_kbuf_list(struct io_kiocb *req, } } -static inline unsigned int io_put_kbuf_comp (struct io_kiocb *req) +static inline void io_put_kbuf_comp (struct io_kiocb *req) { -unsigned int ret; -lockdep_assert_held (&req->ctx->completion_lock);
io_uring/kbuf.h static inline void __io_put_kbuf_list(struct io_kiocb *req, · line 128
Quoted 10 lines
io_uring/kbuf.h +2
-6-if (!(req->flags & (REQ_F_BUFFER_SELECTED |REQ_F_BUFFER_RING ))) -return 0 ; - - ret =IORING_CQE_F_BUFFER | (req->buf_index <<IORING_CQE_BUFFER_SHIFT ); -__io_put_kbuf_list (req, &req->ctx->io_buffers_comp); -return ret; +if (req->flags & (REQ_F_BUFFER_SELECTED |REQ_F_BUFFER_RING )) +__io_put_kbuf_list (req, &req->ctx->io_buffers_comp); }
If you post a v2 with the above suggestion, let's please just keep the flags checking how it is. It's consistent with what we do elsewhere.
Signature · 1 line
Jens Axboe
Quoted 32 lines · Jens Axboe
Quoted 2 lines · Ming Lei
The two callers don't handle the return value of
io_put_kbuf_comp(), so change its return type into void.We might want to consider changing the name of it too, it's a bit different in that it's just recyling/dropping this kbuf rather than posting a completion on behalf of it.
Maybe
io_kbuf_drop()would be better. Would distuingish it from the normal use cases of "drop this kbuf and return the cflags representation of it, as I'm posting a completionw ith it".Quoted 20 lines
Signed-off-by Ming Lei <[email protected]>--- io_uring/kbuf.h | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)io_uring/kbuf.h +1
-3@@ -119,18 +119,12 @@ static inline void __io_put_kbuf_list(struct io_kiocb *req, } } -static inline unsigned int io_put_kbuf_comp (struct io_kiocb *req) +static inline void io_put_kbuf_comp (struct io_kiocb *req) { -unsigned int ret; -lockdep_assert_held (&req->ctx->completion_lock);
Quoted 12 lines
io_uring/kbuf.h static inline void __io_put_kbuf_list(struct io_kiocb *req, · line 128
Quoted 9 lines
io_uring/kbuf.h +2
-6-if (!(req->flags & (REQ_F_BUFFER_SELECTED |REQ_F_BUFFER_RING ))) -return 0 ; - - ret =IORING_CQE_F_BUFFER | (req->buf_index <<IORING_CQE_BUFFER_SHIFT ); -__io_put_kbuf_list (req, &req->ctx->io_buffers_comp); -return ret; +if (req->flags & (REQ_F_BUFFER_SELECTED |REQ_F_BUFFER_RING )) +__io_put_kbuf_list (req, &req->ctx->io_buffers_comp); }If you post a v2 with the above suggestion, let's please just keep the flags checking how it is. It's consistent with what we do elsewhere.
OK, I can rename it as io_kbuf_drop() in v2 and keep the original check style.
Also the following patch removes one io_put_kbuf_comp(), I will post v2 when that patch gets feedback or merged.
https://lore.kernel.org/io-uring/[email protected]/
thanks,
Ming