Skip to content

Commit 2e6e1fd

Browse files
isilenceaxboe
authored andcommitted
io_uring: fix error handling in io_queue_link_head
In case of an error io_submit_sqe() drops a request and continues without it, even if the request was a part of a link. Not only it doesn't cancel links, but also may execute wrong sequence of actions. Stop consuming sqes, and let the user handle errors. Signed-off-by: Pavel Begunkov <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 78076bb commit 2e6e1fd

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

fs/io_uring.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3315,7 +3315,7 @@ static inline void io_queue_link_head(struct io_kiocb *req)
33153315

33163316
#define SQE_VALID_FLAGS (IOSQE_FIXED_FILE|IOSQE_IO_DRAIN|IOSQE_IO_LINK)
33173317

3318-
static void io_submit_sqe(struct io_kiocb *req, struct io_submit_state *state,
3318+
static bool io_submit_sqe(struct io_kiocb *req, struct io_submit_state *state,
33193319
struct io_kiocb **link)
33203320
{
33213321
struct io_ring_ctx *ctx = req->ctx;
@@ -3334,7 +3334,7 @@ static void io_submit_sqe(struct io_kiocb *req, struct io_submit_state *state,
33343334
err_req:
33353335
io_cqring_add_event(req, ret);
33363336
io_double_put_req(req);
3337-
return;
3337+
return false;
33383338
}
33393339

33403340
/*
@@ -3373,6 +3373,8 @@ static void io_submit_sqe(struct io_kiocb *req, struct io_submit_state *state,
33733373
} else {
33743374
io_queue_sqe(req);
33753375
}
3376+
3377+
return true;
33763378
}
33773379

33783380
/*
@@ -3502,6 +3504,7 @@ static int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr,
35023504
}
35033505
}
35043506

3507+
submitted++;
35053508
sqe_flags = req->sqe->flags;
35063509

35073510
req->ring_file = ring_file;
@@ -3511,9 +3514,8 @@ static int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr,
35113514
req->needs_fixed_file = async;
35123515
trace_io_uring_submit_sqe(ctx, req->sqe->user_data,
35133516
true, async);
3514-
io_submit_sqe(req, statep, &link);
3515-
submitted++;
3516-
3517+
if (!io_submit_sqe(req, statep, &link))
3518+
break;
35173519
/*
35183520
* If previous wasn't linked and we have a linked command,
35193521
* that's the end of the chain. Submit the previous link.

0 commit comments

Comments
 (0)