Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

io_uring: kill dead code in io_req_complete_post

Since commit 8f6c829491fe ("io_uring: remove struct io_tw_state::locked"),
io_req_complete_post() is only called from io-wq submit work, where the
request reference is guaranteed to be grabbed and won't drop to zero
in io_req_complete_post().

Kill the dead code, meantime add req_ref_put() to put the reference.

Cc: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/1d8297e2046553153e763a52574f0e0f4d512f86.1712331455.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Ming Lei and committed by
Jens Axboe
f3913000 285207f6

+9 -35
+2 -35
io_uring/io_uring.c
··· 928 928 static void io_req_complete_post(struct io_kiocb *req, unsigned issue_flags) 929 929 { 930 930 struct io_ring_ctx *ctx = req->ctx; 931 - struct io_rsrc_node *rsrc_node = NULL; 932 931 933 932 /* 934 933 * Handle special CQ sync cases via task_work. DEFER_TASKRUN requires ··· 944 945 if (!io_fill_cqe_req(ctx, req)) 945 946 io_req_cqe_overflow(req); 946 947 } 947 - 948 - /* 949 - * If we're the last reference to this request, add to our locked 950 - * free_list cache. 951 - */ 952 - if (req_ref_put_and_test(req)) { 953 - if (req->flags & IO_REQ_LINK_FLAGS) { 954 - if (req->flags & IO_DISARM_MASK) 955 - io_disarm_next(req); 956 - if (req->link) { 957 - io_req_task_queue(req->link); 958 - req->link = NULL; 959 - } 960 - } 961 - io_put_kbuf_comp(req); 962 - if (unlikely(req->flags & IO_REQ_CLEAN_FLAGS)) 963 - io_clean_op(req); 964 - io_put_file(req); 965 - 966 - rsrc_node = req->rsrc_node; 967 - /* 968 - * Selected buffer deallocation in io_clean_op() assumes that 969 - * we don't hold ->completion_lock. Clean them here to avoid 970 - * deadlocks. 971 - */ 972 - io_put_task_remote(req->task); 973 - wq_list_add_head(&req->comp_list, &ctx->locked_free_list); 974 - ctx->locked_free_nr++; 975 - } 976 948 io_cq_unlock_post(ctx); 977 949 978 - if (rsrc_node) { 979 - io_ring_submit_lock(ctx, issue_flags); 980 - io_put_rsrc_node(ctx, rsrc_node); 981 - io_ring_submit_unlock(ctx, issue_flags); 982 - } 950 + /* called from io-wq submit work only, the ref won't drop to zero */ 951 + req_ref_put(req); 983 952 } 984 953 985 954 void io_req_defer_failed(struct io_kiocb *req, s32 res)
+7
io_uring/refs.h
··· 33 33 atomic_inc(&req->refs); 34 34 } 35 35 36 + static inline void req_ref_put(struct io_kiocb *req) 37 + { 38 + WARN_ON_ONCE(!(req->flags & REQ_F_REFCOUNT)); 39 + WARN_ON_ONCE(req_ref_zero_or_close_to_overflow(req)); 40 + atomic_dec(&req->refs); 41 + } 42 + 36 43 static inline void __io_req_set_refcount(struct io_kiocb *req, int nr) 37 44 { 38 45 if (!(req->flags & REQ_F_REFCOUNT)) {