Since we switched to io-wq, the dependent link optimization for when to
pass back work inline has been broken. Fix this by providing a suitable
io-wq helper for io_uring to use to detect when to do this.
Fixes: 561fb04a6a22 ("io_uring: replace workqueue usage with io-wq")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
 }
 #endif
 
+static inline bool io_wq_current_is_worker(void)
+{
+       return in_task() && (current->flags & PF_IO_WORKER);
+}
 #endif
 
                        /* we dropped this link, get next */
                        nxt = list_first_entry_or_null(&req->link_list,
                                                        struct io_kiocb, list);
-               } else if (nxtptr && current_work()) {
+               } else if (nxtptr && io_wq_current_is_worker()) {
                        *nxtptr = nxt;
                        break;
                } else {