io_uring: keep queue_sqe()'s fail path separately
authorPavel Begunkov <asml.silence@gmail.com>
Fri, 3 Jul 2020 19:15:07 +0000 (22:15 +0300)
committerJens Axboe <axboe@kernel.dk>
Sun, 5 Jul 2020 21:07:37 +0000 (15:07 -0600)
A preparation path, extracts error path into a separate block. It looks
saner then calling req_set_fail_links() after io_put_req_find_next(), even
though it have been working well.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c

index cf1b3d4..7147e87 100644 (file)
@@ -5937,22 +5937,21 @@ punt:
                goto exit;
        }
 
+       if (unlikely(ret)) {
 err:
-       /* drop submission reference */
-       nxt = io_put_req_find_next(req);
-
-       if (linked_timeout) {
-               if (!ret)
-                       io_queue_linked_timeout(linked_timeout);
-               else
-                       io_put_req(linked_timeout);
-       }
-
-       /* and drop final reference, if we failed */
-       if (ret) {
+               /* un-prep timeout, so it'll be killed as any other linked */
+               req->flags &= ~REQ_F_LINK_TIMEOUT;
                req_set_fail_links(req);
+               io_put_req(req);
                io_req_complete(req, ret);
+               goto exit;
        }
+
+       /* drop submission reference */
+       nxt = io_put_req_find_next(req);
+       if (linked_timeout)
+               io_queue_linked_timeout(linked_timeout);
+
        if (nxt) {
                req = nxt;