提交 76b0f792 编写于 作者: P Pavel Begunkov 提交者: Xiaoguang Wang

io_uring: remove @nxt from handlers

to #28170604

commit 014db0073cc6a12e1f421b9231d6f3aa35735823 upstream

There will be no use for @nxt in the handlers, and it's doesn't work
anyway, so purge it
Signed-off-by: NPavel Begunkov <asml.silence@gmail.com>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
Acked-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
Signed-off-by: NXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
上级 8a438665
...@@ -1809,17 +1809,6 @@ static void io_complete_rw(struct kiocb *kiocb, long res, long res2) ...@@ -1809,17 +1809,6 @@ static void io_complete_rw(struct kiocb *kiocb, long res, long res2)
io_put_req(req); io_put_req(req);
} }
static struct io_kiocb *__io_complete_rw(struct kiocb *kiocb, long res)
{
struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw.kiocb);
struct io_kiocb *nxt = NULL;
io_complete_rw_common(kiocb, res);
io_put_req_find_next(req, &nxt);
return nxt;
}
static void io_complete_rw_iopoll(struct kiocb *kiocb, long res, long res2) static void io_complete_rw_iopoll(struct kiocb *kiocb, long res, long res2)
{ {
struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw.kiocb); struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw.kiocb);
...@@ -2014,14 +2003,14 @@ static inline void io_rw_done(struct kiocb *kiocb, ssize_t ret) ...@@ -2014,14 +2003,14 @@ static inline void io_rw_done(struct kiocb *kiocb, ssize_t ret)
} }
} }
static void kiocb_done(struct kiocb *kiocb, ssize_t ret, struct io_kiocb **nxt) static void kiocb_done(struct kiocb *kiocb, ssize_t ret)
{ {
struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw.kiocb); struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw.kiocb);
if (req->flags & REQ_F_CUR_POS) if (req->flags & REQ_F_CUR_POS)
req->file->f_pos = kiocb->ki_pos; req->file->f_pos = kiocb->ki_pos;
if (ret >= 0 && kiocb->ki_complete == io_complete_rw) if (ret >= 0 && kiocb->ki_complete == io_complete_rw)
*nxt = __io_complete_rw(kiocb, ret); io_complete_rw(kiocb, ret, 0);
else else
io_rw_done(kiocb, ret); io_rw_done(kiocb, ret);
} }
...@@ -2270,8 +2259,7 @@ static int io_read_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe, ...@@ -2270,8 +2259,7 @@ static int io_read_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe,
return 0; return 0;
} }
static int io_read(struct io_kiocb *req, struct io_kiocb **nxt, static int io_read(struct io_kiocb *req, bool force_nonblock)
bool force_nonblock)
{ {
struct iovec inline_vecs[UIO_FASTIOV], *iovec = inline_vecs; struct iovec inline_vecs[UIO_FASTIOV], *iovec = inline_vecs;
struct kiocb *kiocb = &req->rw.kiocb; struct kiocb *kiocb = &req->rw.kiocb;
...@@ -2311,7 +2299,7 @@ static int io_read(struct io_kiocb *req, struct io_kiocb **nxt, ...@@ -2311,7 +2299,7 @@ static int io_read(struct io_kiocb *req, struct io_kiocb **nxt,
/* Catch -EAGAIN return for forced non-blocking submission */ /* Catch -EAGAIN return for forced non-blocking submission */
if (!force_nonblock || ret2 != -EAGAIN) { if (!force_nonblock || ret2 != -EAGAIN) {
kiocb_done(kiocb, ret2, nxt); kiocb_done(kiocb, ret2);
} else { } else {
copy_iov: copy_iov:
ret = io_setup_async_rw(req, io_size, iovec, ret = io_setup_async_rw(req, io_size, iovec,
...@@ -2360,8 +2348,7 @@ static int io_write_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe, ...@@ -2360,8 +2348,7 @@ static int io_write_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe,
return 0; return 0;
} }
static int io_write(struct io_kiocb *req, struct io_kiocb **nxt, static int io_write(struct io_kiocb *req, bool force_nonblock)
bool force_nonblock)
{ {
struct iovec inline_vecs[UIO_FASTIOV], *iovec = inline_vecs; struct iovec inline_vecs[UIO_FASTIOV], *iovec = inline_vecs;
struct kiocb *kiocb = &req->rw.kiocb; struct kiocb *kiocb = &req->rw.kiocb;
...@@ -2425,7 +2412,7 @@ static int io_write(struct io_kiocb *req, struct io_kiocb **nxt, ...@@ -2425,7 +2412,7 @@ static int io_write(struct io_kiocb *req, struct io_kiocb **nxt,
if (ret2 == -EOPNOTSUPP && (kiocb->ki_flags & IOCB_NOWAIT)) if (ret2 == -EOPNOTSUPP && (kiocb->ki_flags & IOCB_NOWAIT))
ret2 = -EAGAIN; ret2 = -EAGAIN;
if (!force_nonblock || ret2 != -EAGAIN) { if (!force_nonblock || ret2 != -EAGAIN) {
kiocb_done(kiocb, ret2, nxt); kiocb_done(kiocb, ret2);
} else { } else {
copy_iov: copy_iov:
ret = io_setup_async_rw(req, io_size, iovec, ret = io_setup_async_rw(req, io_size, iovec,
...@@ -2482,8 +2469,7 @@ static bool io_splice_punt(struct file *file) ...@@ -2482,8 +2469,7 @@ static bool io_splice_punt(struct file *file)
return !(file->f_mode & O_NONBLOCK); return !(file->f_mode & O_NONBLOCK);
} }
static int io_splice(struct io_kiocb *req, struct io_kiocb **nxt, static int io_splice(struct io_kiocb *req, bool force_nonblock)
bool force_nonblock)
{ {
struct io_splice *sp = &req->splice; struct io_splice *sp = &req->splice;
struct file *in = sp->file_in; struct file *in = sp->file_in;
...@@ -2510,7 +2496,7 @@ static int io_splice(struct io_kiocb *req, struct io_kiocb **nxt, ...@@ -2510,7 +2496,7 @@ static int io_splice(struct io_kiocb *req, struct io_kiocb **nxt,
io_cqring_add_event(req, ret); io_cqring_add_event(req, ret);
if (ret != sp->len) if (ret != sp->len)
req_set_fail_links(req); req_set_fail_links(req);
io_put_req_find_next(req, nxt); io_put_req(req);
return 0; return 0;
} }
...@@ -2583,7 +2569,7 @@ static void io_wq_assign_next(struct io_wq_work **workptr, struct io_kiocb *nxt) ...@@ -2583,7 +2569,7 @@ static void io_wq_assign_next(struct io_wq_work **workptr, struct io_kiocb *nxt)
} }
} }
static void __io_fsync(struct io_kiocb *req, struct io_kiocb **nxt) static void __io_fsync(struct io_kiocb *req)
{ {
loff_t end = req->sync.off + req->sync.len; loff_t end = req->sync.off + req->sync.len;
int ret; int ret;
...@@ -2594,7 +2580,7 @@ static void __io_fsync(struct io_kiocb *req, struct io_kiocb **nxt) ...@@ -2594,7 +2580,7 @@ static void __io_fsync(struct io_kiocb *req, struct io_kiocb **nxt)
if (ret < 0) if (ret < 0)
req_set_fail_links(req); req_set_fail_links(req);
io_cqring_add_event(req, ret); io_cqring_add_event(req, ret);
io_put_req_find_next(req, nxt); io_put_req(req);
} }
static void io_fsync_finish(struct io_wq_work **workptr) static void io_fsync_finish(struct io_wq_work **workptr)
...@@ -2604,25 +2590,24 @@ static void io_fsync_finish(struct io_wq_work **workptr) ...@@ -2604,25 +2590,24 @@ static void io_fsync_finish(struct io_wq_work **workptr)
if (io_req_cancelled(req)) if (io_req_cancelled(req))
return; return;
__io_fsync(req, &nxt); __io_fsync(req);
io_put_req(req); /* drop submission reference */ io_put_req(req); /* drop submission reference */
if (nxt) if (nxt)
io_wq_assign_next(workptr, nxt); io_wq_assign_next(workptr, nxt);
} }
static int io_fsync(struct io_kiocb *req, struct io_kiocb **nxt, static int io_fsync(struct io_kiocb *req, bool force_nonblock)
bool force_nonblock)
{ {
/* fsync always requires a blocking context */ /* fsync always requires a blocking context */
if (force_nonblock) { if (force_nonblock) {
req->work.func = io_fsync_finish; req->work.func = io_fsync_finish;
return -EAGAIN; return -EAGAIN;
} }
__io_fsync(req, nxt); __io_fsync(req);
return 0; return 0;
} }
static void __io_fallocate(struct io_kiocb *req, struct io_kiocb **nxt) static void __io_fallocate(struct io_kiocb *req)
{ {
int ret; int ret;
...@@ -2631,7 +2616,7 @@ static void __io_fallocate(struct io_kiocb *req, struct io_kiocb **nxt) ...@@ -2631,7 +2616,7 @@ static void __io_fallocate(struct io_kiocb *req, struct io_kiocb **nxt)
if (ret < 0) if (ret < 0)
req_set_fail_links(req); req_set_fail_links(req);
io_cqring_add_event(req, ret); io_cqring_add_event(req, ret);
io_put_req_find_next(req, nxt); io_put_req(req);
} }
static void io_fallocate_finish(struct io_wq_work **workptr) static void io_fallocate_finish(struct io_wq_work **workptr)
...@@ -2641,7 +2626,7 @@ static void io_fallocate_finish(struct io_wq_work **workptr) ...@@ -2641,7 +2626,7 @@ static void io_fallocate_finish(struct io_wq_work **workptr)
if (io_req_cancelled(req)) if (io_req_cancelled(req))
return; return;
__io_fallocate(req, &nxt); __io_fallocate(req);
io_put_req(req); /* drop submission reference */ io_put_req(req); /* drop submission reference */
if (nxt) if (nxt)
io_wq_assign_next(workptr, nxt); io_wq_assign_next(workptr, nxt);
...@@ -2659,8 +2644,7 @@ static int io_fallocate_prep(struct io_kiocb *req, ...@@ -2659,8 +2644,7 @@ static int io_fallocate_prep(struct io_kiocb *req,
return 0; return 0;
} }
static int io_fallocate(struct io_kiocb *req, struct io_kiocb **nxt, static int io_fallocate(struct io_kiocb *req, bool force_nonblock)
bool force_nonblock)
{ {
/* fallocate always requiring blocking context */ /* fallocate always requiring blocking context */
if (force_nonblock) { if (force_nonblock) {
...@@ -2668,7 +2652,7 @@ static int io_fallocate(struct io_kiocb *req, struct io_kiocb **nxt, ...@@ -2668,7 +2652,7 @@ static int io_fallocate(struct io_kiocb *req, struct io_kiocb **nxt,
return -EAGAIN; return -EAGAIN;
} }
__io_fallocate(req, nxt); __io_fallocate(req);
return 0; return 0;
} }
...@@ -2743,8 +2727,7 @@ static int io_openat2_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) ...@@ -2743,8 +2727,7 @@ static int io_openat2_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
return 0; return 0;
} }
static int io_openat2(struct io_kiocb *req, struct io_kiocb **nxt, static int io_openat2(struct io_kiocb *req, bool force_nonblock)
bool force_nonblock)
{ {
struct open_flags op; struct open_flags op;
struct file *file; struct file *file;
...@@ -2775,15 +2758,14 @@ static int io_openat2(struct io_kiocb *req, struct io_kiocb **nxt, ...@@ -2775,15 +2758,14 @@ static int io_openat2(struct io_kiocb *req, struct io_kiocb **nxt,
if (ret < 0) if (ret < 0)
req_set_fail_links(req); req_set_fail_links(req);
io_cqring_add_event(req, ret); io_cqring_add_event(req, ret);
io_put_req_find_next(req, nxt); io_put_req(req);
return 0; return 0;
} }
static int io_openat(struct io_kiocb *req, struct io_kiocb **nxt, static int io_openat(struct io_kiocb *req, bool force_nonblock)
bool force_nonblock)
{ {
req->open.how = build_open_how(req->open.how.flags, req->open.how.mode); req->open.how = build_open_how(req->open.how.flags, req->open.how.mode);
return io_openat2(req, nxt, force_nonblock); return io_openat2(req, force_nonblock);
} }
static int io_epoll_ctl_prep(struct io_kiocb *req, static int io_epoll_ctl_prep(struct io_kiocb *req,
...@@ -2811,8 +2793,7 @@ static int io_epoll_ctl_prep(struct io_kiocb *req, ...@@ -2811,8 +2793,7 @@ static int io_epoll_ctl_prep(struct io_kiocb *req,
#endif #endif
} }
static int io_epoll_ctl(struct io_kiocb *req, struct io_kiocb **nxt, static int io_epoll_ctl(struct io_kiocb *req, bool force_nonblock)
bool force_nonblock)
{ {
#if defined(CONFIG_EPOLL) #if defined(CONFIG_EPOLL)
struct io_epoll *ie = &req->epoll; struct io_epoll *ie = &req->epoll;
...@@ -2825,7 +2806,7 @@ static int io_epoll_ctl(struct io_kiocb *req, struct io_kiocb **nxt, ...@@ -2825,7 +2806,7 @@ static int io_epoll_ctl(struct io_kiocb *req, struct io_kiocb **nxt,
if (ret < 0) if (ret < 0)
req_set_fail_links(req); req_set_fail_links(req);
io_cqring_add_event(req, ret); io_cqring_add_event(req, ret);
io_put_req_find_next(req, nxt); io_put_req(req);
return 0; return 0;
#else #else
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -2847,8 +2828,7 @@ static int io_madvise_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) ...@@ -2847,8 +2828,7 @@ static int io_madvise_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
#endif #endif
} }
static int io_madvise(struct io_kiocb *req, struct io_kiocb **nxt, static int io_madvise(struct io_kiocb *req, bool force_nonblock)
bool force_nonblock)
{ {
#if defined(CONFIG_ADVISE_SYSCALLS) && defined(CONFIG_MMU) #if defined(CONFIG_ADVISE_SYSCALLS) && defined(CONFIG_MMU)
struct io_madvise *ma = &req->madvise; struct io_madvise *ma = &req->madvise;
...@@ -2861,7 +2841,7 @@ static int io_madvise(struct io_kiocb *req, struct io_kiocb **nxt, ...@@ -2861,7 +2841,7 @@ static int io_madvise(struct io_kiocb *req, struct io_kiocb **nxt,
if (ret < 0) if (ret < 0)
req_set_fail_links(req); req_set_fail_links(req);
io_cqring_add_event(req, ret); io_cqring_add_event(req, ret);
io_put_req_find_next(req, nxt); io_put_req(req);
return 0; return 0;
#else #else
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -2879,8 +2859,7 @@ static int io_fadvise_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) ...@@ -2879,8 +2859,7 @@ static int io_fadvise_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
return 0; return 0;
} }
static int io_fadvise(struct io_kiocb *req, struct io_kiocb **nxt, static int io_fadvise(struct io_kiocb *req, bool force_nonblock)
bool force_nonblock)
{ {
struct io_fadvise *fa = &req->fadvise; struct io_fadvise *fa = &req->fadvise;
int ret; int ret;
...@@ -2900,7 +2879,7 @@ static int io_fadvise(struct io_kiocb *req, struct io_kiocb **nxt, ...@@ -2900,7 +2879,7 @@ static int io_fadvise(struct io_kiocb *req, struct io_kiocb **nxt,
if (ret < 0) if (ret < 0)
req_set_fail_links(req); req_set_fail_links(req);
io_cqring_add_event(req, ret); io_cqring_add_event(req, ret);
io_put_req_find_next(req, nxt); io_put_req(req);
return 0; return 0;
} }
...@@ -2937,8 +2916,7 @@ static int io_statx_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) ...@@ -2937,8 +2916,7 @@ static int io_statx_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
return 0; return 0;
} }
static int io_statx(struct io_kiocb *req, struct io_kiocb **nxt, static int io_statx(struct io_kiocb *req, bool force_nonblock)
bool force_nonblock)
{ {
struct io_open *ctx = &req->open; struct io_open *ctx = &req->open;
unsigned lookup_flags; unsigned lookup_flags;
...@@ -2975,7 +2953,7 @@ static int io_statx(struct io_kiocb *req, struct io_kiocb **nxt, ...@@ -2975,7 +2953,7 @@ static int io_statx(struct io_kiocb *req, struct io_kiocb **nxt,
if (ret < 0) if (ret < 0)
req_set_fail_links(req); req_set_fail_links(req);
io_cqring_add_event(req, ret); io_cqring_add_event(req, ret);
io_put_req_find_next(req, nxt); io_put_req(req);
return 0; return 0;
} }
...@@ -3002,7 +2980,7 @@ static int io_close_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) ...@@ -3002,7 +2980,7 @@ static int io_close_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
} }
/* only called when __close_fd_get_file() is done */ /* only called when __close_fd_get_file() is done */
static void __io_close_finish(struct io_kiocb *req, struct io_kiocb **nxt) static void __io_close_finish(struct io_kiocb *req)
{ {
int ret; int ret;
...@@ -3011,7 +2989,7 @@ static void __io_close_finish(struct io_kiocb *req, struct io_kiocb **nxt) ...@@ -3011,7 +2989,7 @@ static void __io_close_finish(struct io_kiocb *req, struct io_kiocb **nxt)
req_set_fail_links(req); req_set_fail_links(req);
io_cqring_add_event(req, ret); io_cqring_add_event(req, ret);
fput(req->close.put_file); fput(req->close.put_file);
io_put_req_find_next(req, nxt); io_put_req(req);
} }
static void io_close_finish(struct io_wq_work **workptr) static void io_close_finish(struct io_wq_work **workptr)
...@@ -3020,14 +2998,13 @@ static void io_close_finish(struct io_wq_work **workptr) ...@@ -3020,14 +2998,13 @@ static void io_close_finish(struct io_wq_work **workptr)
struct io_kiocb *nxt = NULL; struct io_kiocb *nxt = NULL;
/* not cancellable, don't do io_req_cancelled() */ /* not cancellable, don't do io_req_cancelled() */
__io_close_finish(req, &nxt); __io_close_finish(req);
io_put_req(req); /* drop submission reference */ io_put_req(req); /* drop submission reference */
if (nxt) if (nxt)
io_wq_assign_next(workptr, nxt); io_wq_assign_next(workptr, nxt);
} }
static int io_close(struct io_kiocb *req, struct io_kiocb **nxt, static int io_close(struct io_kiocb *req, bool force_nonblock)
bool force_nonblock)
{ {
int ret; int ret;
...@@ -3055,7 +3032,7 @@ static int io_close(struct io_kiocb *req, struct io_kiocb **nxt, ...@@ -3055,7 +3032,7 @@ static int io_close(struct io_kiocb *req, struct io_kiocb **nxt,
* No ->flush(), safely close from here and just punt the * No ->flush(), safely close from here and just punt the
* fput() to async context. * fput() to async context.
*/ */
__io_close_finish(req, nxt); __io_close_finish(req);
return 0; return 0;
} }
...@@ -3077,7 +3054,7 @@ static int io_prep_sfr(struct io_kiocb *req, const struct io_uring_sqe *sqe) ...@@ -3077,7 +3054,7 @@ static int io_prep_sfr(struct io_kiocb *req, const struct io_uring_sqe *sqe)
return 0; return 0;
} }
static void __io_sync_file_range(struct io_kiocb *req, struct io_kiocb **nxt) static void __io_sync_file_range(struct io_kiocb *req)
{ {
int ret; int ret;
...@@ -3086,7 +3063,7 @@ static void __io_sync_file_range(struct io_kiocb *req, struct io_kiocb **nxt) ...@@ -3086,7 +3063,7 @@ static void __io_sync_file_range(struct io_kiocb *req, struct io_kiocb **nxt)
if (ret < 0) if (ret < 0)
req_set_fail_links(req); req_set_fail_links(req);
io_cqring_add_event(req, ret); io_cqring_add_event(req, ret);
io_put_req_find_next(req, nxt); io_put_req(req);
} }
...@@ -3097,14 +3074,13 @@ static void io_sync_file_range_finish(struct io_wq_work **workptr) ...@@ -3097,14 +3074,13 @@ static void io_sync_file_range_finish(struct io_wq_work **workptr)
if (io_req_cancelled(req)) if (io_req_cancelled(req))
return; return;
__io_sync_file_range(req, &nxt); __io_sync_file_range(req);
io_put_req(req); /* put submission ref */ io_put_req(req); /* put submission ref */
if (nxt) if (nxt)
io_wq_assign_next(workptr, nxt); io_wq_assign_next(workptr, nxt);
} }
static int io_sync_file_range(struct io_kiocb *req, struct io_kiocb **nxt, static int io_sync_file_range(struct io_kiocb *req, bool force_nonblock)
bool force_nonblock)
{ {
/* sync_file_range always requires a blocking context */ /* sync_file_range always requires a blocking context */
if (force_nonblock) { if (force_nonblock) {
...@@ -3112,7 +3088,7 @@ static int io_sync_file_range(struct io_kiocb *req, struct io_kiocb **nxt, ...@@ -3112,7 +3088,7 @@ static int io_sync_file_range(struct io_kiocb *req, struct io_kiocb **nxt,
return -EAGAIN; return -EAGAIN;
} }
__io_sync_file_range(req, nxt); __io_sync_file_range(req);
return 0; return 0;
} }
...@@ -3164,8 +3140,7 @@ static int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) ...@@ -3164,8 +3140,7 @@ static int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
#endif #endif
} }
static int io_sendmsg(struct io_kiocb *req, struct io_kiocb **nxt, static int io_sendmsg(struct io_kiocb *req, bool force_nonblock)
bool force_nonblock)
{ {
#if defined(CONFIG_NET) #if defined(CONFIG_NET)
struct io_async_msghdr *kmsg = NULL; struct io_async_msghdr *kmsg = NULL;
...@@ -3219,15 +3194,14 @@ static int io_sendmsg(struct io_kiocb *req, struct io_kiocb **nxt, ...@@ -3219,15 +3194,14 @@ static int io_sendmsg(struct io_kiocb *req, struct io_kiocb **nxt,
io_cqring_add_event(req, ret); io_cqring_add_event(req, ret);
if (ret < 0) if (ret < 0)
req_set_fail_links(req); req_set_fail_links(req);
io_put_req_find_next(req, nxt); io_put_req(req);
return 0; return 0;
#else #else
return -EOPNOTSUPP; return -EOPNOTSUPP;
#endif #endif
} }
static int io_send(struct io_kiocb *req, struct io_kiocb **nxt, static int io_send(struct io_kiocb *req, bool force_nonblock)
bool force_nonblock)
{ {
#if defined(CONFIG_NET) #if defined(CONFIG_NET)
struct socket *sock; struct socket *sock;
...@@ -3270,7 +3244,7 @@ static int io_send(struct io_kiocb *req, struct io_kiocb **nxt, ...@@ -3270,7 +3244,7 @@ static int io_send(struct io_kiocb *req, struct io_kiocb **nxt,
io_cqring_add_event(req, ret); io_cqring_add_event(req, ret);
if (ret < 0) if (ret < 0)
req_set_fail_links(req); req_set_fail_links(req);
io_put_req_find_next(req, nxt); io_put_req(req);
return 0; return 0;
#else #else
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -3311,8 +3285,7 @@ static int io_recvmsg_prep(struct io_kiocb *req, ...@@ -3311,8 +3285,7 @@ static int io_recvmsg_prep(struct io_kiocb *req,
#endif #endif
} }
static int io_recvmsg(struct io_kiocb *req, struct io_kiocb **nxt, static int io_recvmsg(struct io_kiocb *req, bool force_nonblock)
bool force_nonblock)
{ {
#if defined(CONFIG_NET) #if defined(CONFIG_NET)
struct io_async_msghdr *kmsg = NULL; struct io_async_msghdr *kmsg = NULL;
...@@ -3368,15 +3341,14 @@ static int io_recvmsg(struct io_kiocb *req, struct io_kiocb **nxt, ...@@ -3368,15 +3341,14 @@ static int io_recvmsg(struct io_kiocb *req, struct io_kiocb **nxt,
io_cqring_add_event(req, ret); io_cqring_add_event(req, ret);
if (ret < 0) if (ret < 0)
req_set_fail_links(req); req_set_fail_links(req);
io_put_req_find_next(req, nxt); io_put_req(req);
return 0; return 0;
#else #else
return -EOPNOTSUPP; return -EOPNOTSUPP;
#endif #endif
} }
static int io_recv(struct io_kiocb *req, struct io_kiocb **nxt, static int io_recv(struct io_kiocb *req, bool force_nonblock)
bool force_nonblock)
{ {
#if defined(CONFIG_NET) #if defined(CONFIG_NET)
struct socket *sock; struct socket *sock;
...@@ -3420,7 +3392,7 @@ static int io_recv(struct io_kiocb *req, struct io_kiocb **nxt, ...@@ -3420,7 +3392,7 @@ static int io_recv(struct io_kiocb *req, struct io_kiocb **nxt,
io_cqring_add_event(req, ret); io_cqring_add_event(req, ret);
if (ret < 0) if (ret < 0)
req_set_fail_links(req); req_set_fail_links(req);
io_put_req_find_next(req, nxt); io_put_req(req);
return 0; return 0;
#else #else
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -3449,8 +3421,7 @@ static int io_accept_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) ...@@ -3449,8 +3421,7 @@ static int io_accept_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
} }
#if defined(CONFIG_NET) #if defined(CONFIG_NET)
static int __io_accept(struct io_kiocb *req, struct io_kiocb **nxt, static int __io_accept(struct io_kiocb *req, bool force_nonblock)
bool force_nonblock)
{ {
struct io_accept *accept = &req->accept; struct io_accept *accept = &req->accept;
unsigned file_flags; unsigned file_flags;
...@@ -3467,7 +3438,7 @@ static int __io_accept(struct io_kiocb *req, struct io_kiocb **nxt, ...@@ -3467,7 +3438,7 @@ static int __io_accept(struct io_kiocb *req, struct io_kiocb **nxt,
if (ret < 0) if (ret < 0)
req_set_fail_links(req); req_set_fail_links(req);
io_cqring_add_event(req, ret); io_cqring_add_event(req, ret);
io_put_req_find_next(req, nxt); io_put_req(req);
return 0; return 0;
} }
...@@ -3478,20 +3449,19 @@ static void io_accept_finish(struct io_wq_work **workptr) ...@@ -3478,20 +3449,19 @@ static void io_accept_finish(struct io_wq_work **workptr)
if (io_req_cancelled(req)) if (io_req_cancelled(req))
return; return;
__io_accept(req, &nxt, false); __io_accept(req, false);
io_put_req(req); /* drop submission reference */ io_put_req(req); /* drop submission reference */
if (nxt) if (nxt)
io_wq_assign_next(workptr, nxt); io_wq_assign_next(workptr, nxt);
} }
#endif #endif
static int io_accept(struct io_kiocb *req, struct io_kiocb **nxt, static int io_accept(struct io_kiocb *req, bool force_nonblock)
bool force_nonblock)
{ {
#if defined(CONFIG_NET) #if defined(CONFIG_NET)
int ret; int ret;
ret = __io_accept(req, nxt, force_nonblock); ret = __io_accept(req, force_nonblock);
if (ret == -EAGAIN && force_nonblock) { if (ret == -EAGAIN && force_nonblock) {
req->work.func = io_accept_finish; req->work.func = io_accept_finish;
return -EAGAIN; return -EAGAIN;
...@@ -3526,8 +3496,7 @@ static int io_connect_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) ...@@ -3526,8 +3496,7 @@ static int io_connect_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
#endif #endif
} }
static int io_connect(struct io_kiocb *req, struct io_kiocb **nxt, static int io_connect(struct io_kiocb *req, bool force_nonblock)
bool force_nonblock)
{ {
#if defined(CONFIG_NET) #if defined(CONFIG_NET)
struct io_async_ctx __io, *io; struct io_async_ctx __io, *io;
...@@ -3565,7 +3534,7 @@ static int io_connect(struct io_kiocb *req, struct io_kiocb **nxt, ...@@ -3565,7 +3534,7 @@ static int io_connect(struct io_kiocb *req, struct io_kiocb **nxt,
if (ret < 0) if (ret < 0)
req_set_fail_links(req); req_set_fail_links(req);
io_cqring_add_event(req, ret); io_cqring_add_event(req, ret);
io_put_req_find_next(req, nxt); io_put_req(req);
return 0; return 0;
#else #else
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -3962,7 +3931,7 @@ static int io_poll_add_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe ...@@ -3962,7 +3931,7 @@ static int io_poll_add_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe
return 0; return 0;
} }
static int io_poll_add(struct io_kiocb *req, struct io_kiocb **nxt) static int io_poll_add(struct io_kiocb *req)
{ {
struct io_poll_iocb *poll = &req->poll; struct io_poll_iocb *poll = &req->poll;
struct io_ring_ctx *ctx = req->ctx; struct io_ring_ctx *ctx = req->ctx;
...@@ -3984,7 +3953,7 @@ static int io_poll_add(struct io_kiocb *req, struct io_kiocb **nxt) ...@@ -3984,7 +3953,7 @@ static int io_poll_add(struct io_kiocb *req, struct io_kiocb **nxt)
if (mask) { if (mask) {
io_cqring_ev_posted(ctx); io_cqring_ev_posted(ctx);
io_put_req_find_next(req, nxt); io_put_req(req);
} }
return ipt.error; return ipt.error;
} }
...@@ -4233,7 +4202,7 @@ static int io_async_cancel_one(struct io_ring_ctx *ctx, void *sqe_addr) ...@@ -4233,7 +4202,7 @@ static int io_async_cancel_one(struct io_ring_ctx *ctx, void *sqe_addr)
static void io_async_find_and_cancel(struct io_ring_ctx *ctx, static void io_async_find_and_cancel(struct io_ring_ctx *ctx,
struct io_kiocb *req, __u64 sqe_addr, struct io_kiocb *req, __u64 sqe_addr,
struct io_kiocb **nxt, int success_ret) int success_ret)
{ {
unsigned long flags; unsigned long flags;
int ret; int ret;
...@@ -4259,7 +4228,7 @@ static void io_async_find_and_cancel(struct io_ring_ctx *ctx, ...@@ -4259,7 +4228,7 @@ static void io_async_find_and_cancel(struct io_ring_ctx *ctx,
if (ret < 0) if (ret < 0)
req_set_fail_links(req); req_set_fail_links(req);
io_put_req_find_next(req, nxt); io_put_req(req);
} }
static int io_async_cancel_prep(struct io_kiocb *req, static int io_async_cancel_prep(struct io_kiocb *req,
...@@ -4275,11 +4244,11 @@ static int io_async_cancel_prep(struct io_kiocb *req, ...@@ -4275,11 +4244,11 @@ static int io_async_cancel_prep(struct io_kiocb *req,
return 0; return 0;
} }
static int io_async_cancel(struct io_kiocb *req, struct io_kiocb **nxt) static int io_async_cancel(struct io_kiocb *req)
{ {
struct io_ring_ctx *ctx = req->ctx; struct io_ring_ctx *ctx = req->ctx;
io_async_find_and_cancel(ctx, req, req->cancel.addr, nxt, 0); io_async_find_and_cancel(ctx, req, req->cancel.addr, 0);
return 0; return 0;
} }
...@@ -4489,7 +4458,7 @@ static void io_cleanup_req(struct io_kiocb *req) ...@@ -4489,7 +4458,7 @@ static void io_cleanup_req(struct io_kiocb *req)
} }
static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe, static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
struct io_kiocb **nxt, bool force_nonblock) bool force_nonblock)
{ {
struct io_ring_ctx *ctx = req->ctx; struct io_ring_ctx *ctx = req->ctx;
int ret; int ret;
...@@ -4506,7 +4475,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe, ...@@ -4506,7 +4475,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
if (ret < 0) if (ret < 0)
break; break;
} }
ret = io_read(req, nxt, force_nonblock); ret = io_read(req, force_nonblock);
break; break;
case IORING_OP_WRITEV: case IORING_OP_WRITEV:
case IORING_OP_WRITE_FIXED: case IORING_OP_WRITE_FIXED:
...@@ -4516,7 +4485,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe, ...@@ -4516,7 +4485,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
if (ret < 0) if (ret < 0)
break; break;
} }
ret = io_write(req, nxt, force_nonblock); ret = io_write(req, force_nonblock);
break; break;
case IORING_OP_FSYNC: case IORING_OP_FSYNC:
if (sqe) { if (sqe) {
...@@ -4524,7 +4493,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe, ...@@ -4524,7 +4493,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
if (ret < 0) if (ret < 0)
break; break;
} }
ret = io_fsync(req, nxt, force_nonblock); ret = io_fsync(req, force_nonblock);
break; break;
case IORING_OP_POLL_ADD: case IORING_OP_POLL_ADD:
if (sqe) { if (sqe) {
...@@ -4532,7 +4501,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe, ...@@ -4532,7 +4501,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
if (ret) if (ret)
break; break;
} }
ret = io_poll_add(req, nxt); ret = io_poll_add(req);
break; break;
case IORING_OP_POLL_REMOVE: case IORING_OP_POLL_REMOVE:
if (sqe) { if (sqe) {
...@@ -4548,7 +4517,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe, ...@@ -4548,7 +4517,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
if (ret < 0) if (ret < 0)
break; break;
} }
ret = io_sync_file_range(req, nxt, force_nonblock); ret = io_sync_file_range(req, force_nonblock);
break; break;
case IORING_OP_SENDMSG: case IORING_OP_SENDMSG:
case IORING_OP_SEND: case IORING_OP_SEND:
...@@ -4558,9 +4527,9 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe, ...@@ -4558,9 +4527,9 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
break; break;
} }
if (req->opcode == IORING_OP_SENDMSG) if (req->opcode == IORING_OP_SENDMSG)
ret = io_sendmsg(req, nxt, force_nonblock); ret = io_sendmsg(req, force_nonblock);
else else
ret = io_send(req, nxt, force_nonblock); ret = io_send(req, force_nonblock);
break; break;
case IORING_OP_RECVMSG: case IORING_OP_RECVMSG:
case IORING_OP_RECV: case IORING_OP_RECV:
...@@ -4570,9 +4539,9 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe, ...@@ -4570,9 +4539,9 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
break; break;
} }
if (req->opcode == IORING_OP_RECVMSG) if (req->opcode == IORING_OP_RECVMSG)
ret = io_recvmsg(req, nxt, force_nonblock); ret = io_recvmsg(req, force_nonblock);
else else
ret = io_recv(req, nxt, force_nonblock); ret = io_recv(req, force_nonblock);
break; break;
case IORING_OP_TIMEOUT: case IORING_OP_TIMEOUT:
if (sqe) { if (sqe) {
...@@ -4596,7 +4565,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe, ...@@ -4596,7 +4565,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
if (ret) if (ret)
break; break;
} }
ret = io_accept(req, nxt, force_nonblock); ret = io_accept(req, force_nonblock);
break; break;
case IORING_OP_CONNECT: case IORING_OP_CONNECT:
if (sqe) { if (sqe) {
...@@ -4604,7 +4573,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe, ...@@ -4604,7 +4573,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
if (ret) if (ret)
break; break;
} }
ret = io_connect(req, nxt, force_nonblock); ret = io_connect(req, force_nonblock);
break; break;
case IORING_OP_ASYNC_CANCEL: case IORING_OP_ASYNC_CANCEL:
if (sqe) { if (sqe) {
...@@ -4612,7 +4581,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe, ...@@ -4612,7 +4581,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
if (ret) if (ret)
break; break;
} }
ret = io_async_cancel(req, nxt); ret = io_async_cancel(req);
break; break;
case IORING_OP_FALLOCATE: case IORING_OP_FALLOCATE:
if (sqe) { if (sqe) {
...@@ -4620,7 +4589,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe, ...@@ -4620,7 +4589,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
if (ret) if (ret)
break; break;
} }
ret = io_fallocate(req, nxt, force_nonblock); ret = io_fallocate(req, force_nonblock);
break; break;
case IORING_OP_OPENAT: case IORING_OP_OPENAT:
if (sqe) { if (sqe) {
...@@ -4628,7 +4597,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe, ...@@ -4628,7 +4597,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
if (ret) if (ret)
break; break;
} }
ret = io_openat(req, nxt, force_nonblock); ret = io_openat(req, force_nonblock);
break; break;
case IORING_OP_CLOSE: case IORING_OP_CLOSE:
if (sqe) { if (sqe) {
...@@ -4636,7 +4605,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe, ...@@ -4636,7 +4605,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
if (ret) if (ret)
break; break;
} }
ret = io_close(req, nxt, force_nonblock); ret = io_close(req, force_nonblock);
break; break;
case IORING_OP_FILES_UPDATE: case IORING_OP_FILES_UPDATE:
if (sqe) { if (sqe) {
...@@ -4652,7 +4621,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe, ...@@ -4652,7 +4621,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
if (ret) if (ret)
break; break;
} }
ret = io_statx(req, nxt, force_nonblock); ret = io_statx(req, force_nonblock);
break; break;
case IORING_OP_FADVISE: case IORING_OP_FADVISE:
if (sqe) { if (sqe) {
...@@ -4660,7 +4629,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe, ...@@ -4660,7 +4629,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
if (ret) if (ret)
break; break;
} }
ret = io_fadvise(req, nxt, force_nonblock); ret = io_fadvise(req, force_nonblock);
break; break;
case IORING_OP_MADVISE: case IORING_OP_MADVISE:
if (sqe) { if (sqe) {
...@@ -4668,7 +4637,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe, ...@@ -4668,7 +4637,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
if (ret) if (ret)
break; break;
} }
ret = io_madvise(req, nxt, force_nonblock); ret = io_madvise(req, force_nonblock);
break; break;
case IORING_OP_OPENAT2: case IORING_OP_OPENAT2:
if (sqe) { if (sqe) {
...@@ -4676,7 +4645,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe, ...@@ -4676,7 +4645,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
if (ret) if (ret)
break; break;
} }
ret = io_openat2(req, nxt, force_nonblock); ret = io_openat2(req, force_nonblock);
break; break;
case IORING_OP_EPOLL_CTL: case IORING_OP_EPOLL_CTL:
if (sqe) { if (sqe) {
...@@ -4684,7 +4653,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe, ...@@ -4684,7 +4653,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
if (ret) if (ret)
break; break;
} }
ret = io_epoll_ctl(req, nxt, force_nonblock); ret = io_epoll_ctl(req, force_nonblock);
break; break;
case IORING_OP_SPLICE: case IORING_OP_SPLICE:
if (sqe) { if (sqe) {
...@@ -4692,7 +4661,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe, ...@@ -4692,7 +4661,7 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
if (ret < 0) if (ret < 0)
break; break;
} }
ret = io_splice(req, nxt, force_nonblock); ret = io_splice(req, force_nonblock);
break; break;
default: default:
ret = -EINVAL; ret = -EINVAL;
...@@ -4736,7 +4705,7 @@ static void io_wq_submit_work(struct io_wq_work **workptr) ...@@ -4736,7 +4705,7 @@ static void io_wq_submit_work(struct io_wq_work **workptr)
if (!ret) { if (!ret) {
do { do {
ret = io_issue_sqe(req, NULL, &nxt, false); ret = io_issue_sqe(req, NULL, false);
/* /*
* We can get EAGAIN for polled IO even though we're * We can get EAGAIN for polled IO even though we're
* forcing a sync submission from here, since we can't * forcing a sync submission from here, since we can't
...@@ -4882,8 +4851,7 @@ static enum hrtimer_restart io_link_timeout_fn(struct hrtimer *timer) ...@@ -4882,8 +4851,7 @@ static enum hrtimer_restart io_link_timeout_fn(struct hrtimer *timer)
if (prev) { if (prev) {
req_set_fail_links(prev); req_set_fail_links(prev);
io_async_find_and_cancel(ctx, req, prev->user_data, NULL, io_async_find_and_cancel(ctx, req, prev->user_data, -ETIME);
-ETIME);
io_put_req(prev); io_put_req(prev);
} else { } else {
io_cqring_add_event(req, -ETIME); io_cqring_add_event(req, -ETIME);
...@@ -4952,7 +4920,7 @@ static void __io_queue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe) ...@@ -4952,7 +4920,7 @@ static void __io_queue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe)
old_creds = override_creds(req->work.creds); old_creds = override_creds(req->work.creds);
} }
ret = io_issue_sqe(req, sqe, &nxt, true); ret = io_issue_sqe(req, sqe, true);
/* /*
* We async punt it if the file wasn't marked NOWAIT, or if the file * We async punt it if the file wasn't marked NOWAIT, or if the file
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册