diff options
author | Jens Axboe <axboe@kernel.dk> | 2021-03-17 08:17:19 -0600 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2021-04-11 17:42:00 -0600 |
commit | b2cb805f6dd40938c0398c94787741a08ed5e921 (patch) | |
tree | 214990f1e57997986fde4ae082c7ba131937079c /fs/io_uring.c | |
parent | 5082620fb2cab74b623c3bf5da5a222add564871 (diff) | |
download | lwn-b2cb805f6dd40938c0398c94787741a08ed5e921.tar.gz lwn-b2cb805f6dd40938c0398c94787741a08ed5e921.zip |
io_uring: abstract out a io_poll_find_helper()
We'll need this helper for another purpose, for now just abstract it
out and have io_poll_cancel() use it for lookups.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io_uring.c')
-rw-r--r-- | fs/io_uring.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index e23549330904..3c54e8c9f81f 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -5286,7 +5286,7 @@ static bool io_poll_remove_all(struct io_ring_ctx *ctx, struct task_struct *tsk, return posted != 0; } -static int io_poll_cancel(struct io_ring_ctx *ctx, __u64 sqe_addr) +static struct io_kiocb *io_poll_find(struct io_ring_ctx *ctx, __u64 sqe_addr) { struct hlist_head *list; struct io_kiocb *req; @@ -5295,12 +5295,23 @@ static int io_poll_cancel(struct io_ring_ctx *ctx, __u64 sqe_addr) hlist_for_each_entry(req, list, hash_node) { if (sqe_addr != req->user_data) continue; - if (io_poll_remove_one(req)) - return 0; - return -EALREADY; + return req; } - return -ENOENT; + return NULL; +} + +static int io_poll_cancel(struct io_ring_ctx *ctx, __u64 sqe_addr) +{ + struct io_kiocb *req; + + req = io_poll_find(ctx, sqe_addr); + if (!req) + return -ENOENT; + if (io_poll_remove_one(req)) + return 0; + + return -EALREADY; } static int io_poll_remove_prep(struct io_kiocb *req, |