aboutsummaryrefslogtreecommitdiffstats
path: root/io_uring
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2023-08-09 10:03:00 -0600
committerJens Axboe <axboe@kernel.dk>2023-08-09 10:46:46 -0600
commit9e4bef2ba9e0c5fd0e0ae383f0c0fb0e338aafad (patch)
treed268ad31ca6d9ad5dabdf90d0b92d70a1728903c /io_uring
parentdc314886cb3d0e4ab2858003e8de2917f8a3ccbd (diff)
downloadartpec-9e4bef2ba9e0c5fd0e0ae383f0c0fb0e338aafad.tar.gz
io_uring: cleanup 'ret' handling in io_iopoll_check()
We return 0 for success, or -error when there's an error. Move the 'ret' variable into the loop where we are actually using it, to make it clearer that we don't carry this variable forward for return outside of the loop. While at it, also move the need_resched() break condition out of the while check itself, keeping it with the signal pending check. Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring')
-rw-r--r--io_uring/io_uring.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index ad4ffd3a876fa0..dadd745d389ecc 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -1615,7 +1615,6 @@ static __cold void io_iopoll_try_reap_events(struct io_ring_ctx *ctx)
static int io_iopoll_check(struct io_ring_ctx *ctx, long min)
{
unsigned int nr_events = 0;
- int ret = 0;
unsigned long check_cq;
if (!io_allowed_run_tw(ctx))
@@ -1641,6 +1640,8 @@ static int io_iopoll_check(struct io_ring_ctx *ctx, long min)
return 0;
do {
+ int ret = 0;
+
/*
* If a submit got punted to a workqueue, we can have the
* application entering polling for a command before it gets
@@ -1669,16 +1670,18 @@ static int io_iopoll_check(struct io_ring_ctx *ctx, long min)
break;
}
ret = io_do_iopoll(ctx, !min);
- if (ret < 0)
- break;
- nr_events += ret;
- ret = 0;
+ if (unlikely(ret < 0))
+ return ret;
if (task_sigpending(current))
return -EINTR;
- } while (nr_events < min && !need_resched());
+ if (need_resched())
+ break;
- return ret;
+ nr_events += ret;
+ } while (nr_events < min);
+
+ return 0;
}
void io_req_task_complete(struct io_kiocb *req, struct io_tw_state *ts)