Commit da1a08c5 authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe

io_uring: introduce IO_REQ_LINK_FLAGS

Add a macro for all link request flags to avoid duplication.
Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/df38b883e31e7e0ca4e364d25a0743862961b180.1650056133.git.asml.silence@gmail.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 7bfa9bad
...@@ -1180,6 +1180,7 @@ static const struct io_op_def io_op_defs[] = { ...@@ -1180,6 +1180,7 @@ static const struct io_op_def io_op_defs[] = {
/* requests with any of those set should undergo io_disarm_next() */ /* requests with any of those set should undergo io_disarm_next() */
#define IO_DISARM_MASK (REQ_F_ARM_LTIMEOUT | REQ_F_LINK_TIMEOUT | REQ_F_FAIL) #define IO_DISARM_MASK (REQ_F_ARM_LTIMEOUT | REQ_F_LINK_TIMEOUT | REQ_F_FAIL)
#define IO_REQ_LINK_FLAGS (REQ_F_LINK | REQ_F_HARDLINK)
static bool io_disarm_next(struct io_kiocb *req); static bool io_disarm_next(struct io_kiocb *req);
static void io_uring_del_tctx_node(unsigned long index); static void io_uring_del_tctx_node(unsigned long index);
...@@ -2160,7 +2161,7 @@ static void __io_req_complete_post(struct io_kiocb *req, s32 res, ...@@ -2160,7 +2161,7 @@ static void __io_req_complete_post(struct io_kiocb *req, s32 res,
* free_list cache. * free_list cache.
*/ */
if (req_ref_put_and_test(req)) { if (req_ref_put_and_test(req)) {
if (req->flags & (REQ_F_LINK | REQ_F_HARDLINK)) { if (req->flags & IO_REQ_LINK_FLAGS) {
if (req->flags & IO_DISARM_MASK) if (req->flags & IO_DISARM_MASK)
io_disarm_next(req); io_disarm_next(req);
if (req->link) { if (req->link) {
...@@ -2721,7 +2722,7 @@ static void io_free_batch_list(struct io_ring_ctx *ctx, ...@@ -2721,7 +2722,7 @@ static void io_free_batch_list(struct io_ring_ctx *ctx,
&ctx->apoll_cache); &ctx->apoll_cache);
req->flags &= ~REQ_F_POLLED; req->flags &= ~REQ_F_POLLED;
} }
if (req->flags & (REQ_F_LINK|REQ_F_HARDLINK)) if (req->flags & IO_REQ_LINK_FLAGS)
io_queue_next(req); io_queue_next(req);
if (unlikely(req->flags & IO_REQ_CLEAN_FLAGS)) if (unlikely(req->flags & IO_REQ_CLEAN_FLAGS))
io_clean_op(req); io_clean_op(req);
...@@ -2781,7 +2782,7 @@ static inline struct io_kiocb *io_put_req_find_next(struct io_kiocb *req) ...@@ -2781,7 +2782,7 @@ static inline struct io_kiocb *io_put_req_find_next(struct io_kiocb *req)
struct io_kiocb *nxt = NULL; struct io_kiocb *nxt = NULL;
if (req_ref_put_and_test(req)) { if (req_ref_put_and_test(req)) {
if (unlikely(req->flags & (REQ_F_LINK|REQ_F_HARDLINK))) if (unlikely(req->flags & IO_REQ_LINK_FLAGS))
nxt = io_req_find_next(req); nxt = io_req_find_next(req);
io_free_req(req); io_free_req(req);
} }
...@@ -7728,7 +7729,7 @@ static int io_submit_sqe(struct io_ring_ctx *ctx, struct io_kiocb *req, ...@@ -7728,7 +7729,7 @@ static int io_submit_sqe(struct io_ring_ctx *ctx, struct io_kiocb *req,
*/ */
if (!(link->head->flags & REQ_F_FAIL)) if (!(link->head->flags & REQ_F_FAIL))
req_fail_link_node(link->head, -ECANCELED); req_fail_link_node(link->head, -ECANCELED);
} else if (!(req->flags & (REQ_F_LINK | REQ_F_HARDLINK))) { } else if (!(req->flags & IO_REQ_LINK_FLAGS)) {
/* /*
* the current req is a normal req, we should return * the current req is a normal req, we should return
* error and thus break the submittion loop. * error and thus break the submittion loop.
...@@ -7766,12 +7767,12 @@ static int io_submit_sqe(struct io_ring_ctx *ctx, struct io_kiocb *req, ...@@ -7766,12 +7767,12 @@ static int io_submit_sqe(struct io_ring_ctx *ctx, struct io_kiocb *req,
link->last->link = req; link->last->link = req;
link->last = req; link->last = req;
if (req->flags & (REQ_F_LINK | REQ_F_HARDLINK)) if (req->flags & IO_REQ_LINK_FLAGS)
return 0; return 0;
/* last request of a link, enqueue the link */ /* last request of a link, enqueue the link */
link->head = NULL; link->head = NULL;
req = head; req = head;
} else if (req->flags & (REQ_F_LINK | REQ_F_HARDLINK)) { } else if (req->flags & IO_REQ_LINK_FLAGS) {
link->head = req; link->head = req;
link->last = req; link->last = req;
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment