}
 }
 
-/*
- * Drop reference to request, return next in chain (if there is one) if this
- * was the last reference to this request.
- */
-static inline struct io_kiocb *io_put_req_find_next(struct io_kiocb *req)
-{
-       struct io_kiocb *nxt = NULL;
-
-       if (req_ref_put_and_test(req)) {
-               if (unlikely(req->flags & IO_REQ_LINK_FLAGS))
-                       nxt = io_req_find_next(req);
-               io_free_req(req);
-       }
-       return nxt;
-}
-
 static unsigned io_cqring_events(struct io_ring_ctx *ctx)
 {
        /* See comment at the top of this file */
 struct io_wq_work *io_wq_free_work(struct io_wq_work *work)
 {
        struct io_kiocb *req = container_of(work, struct io_kiocb, work);
+       struct io_kiocb *nxt = NULL;
 
-       req = io_put_req_find_next(req);
-       return req ? &req->work : NULL;
+       if (req_ref_put_and_test(req)) {
+               if (req->flags & IO_REQ_LINK_FLAGS)
+                       nxt = io_req_find_next(req);
+               io_free_req(req);
+       }
+       return nxt ? &nxt->work : NULL;
 }
 
 void io_wq_submit_work(struct io_wq_work *work)