From: Pavel Begunkov Date: Thu, 1 Apr 2021 14:43:57 +0000 (+0100) Subject: io_uring: lock annotate timeouts and poll X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=e07785b0029165fdb1c72ac12fe42801ba5f9f61;p=linux.git io_uring: lock annotate timeouts and poll Add timeout and poll ->comletion_lock annotations for Sparse, makes life easier while looking at the functions. Signed-off-by: Pavel Begunkov Link: https://lore.kernel.org/r/2345325643093d41543383ba985a735aeb899eac.1617287883.git.asml.silence@gmail.com Signed-off-by: Jens Axboe --- diff --git a/fs/io_uring.c b/fs/io_uring.c index 913929d9d05a1..7c5c3d46c6b71 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -4885,6 +4885,7 @@ static struct io_poll_iocb *io_poll_get_single(struct io_kiocb *req) } static void io_poll_remove_double(struct io_kiocb *req) + __must_hold(&req->ctx->completion_lock) { struct io_poll_iocb *poll = io_poll_get_double(req); @@ -4903,6 +4904,7 @@ static void io_poll_remove_double(struct io_kiocb *req) } static bool io_poll_complete(struct io_kiocb *req, __poll_t mask, int error) + __must_hold(&req->ctx->completion_lock) { struct io_ring_ctx *ctx = req->ctx; unsigned flags = IORING_CQE_F_MORE; @@ -5208,6 +5210,7 @@ static bool io_arm_poll_handler(struct io_kiocb *req) static bool __io_poll_remove_one(struct io_kiocb *req, struct io_poll_iocb *poll, bool do_cancel) + __must_hold(&req->ctx->completion_lock) { bool do_complete = false; @@ -5226,6 +5229,7 @@ static bool __io_poll_remove_one(struct io_kiocb *req, } static bool io_poll_remove_waitqs(struct io_kiocb *req) + __must_hold(&req->ctx->completion_lock) { bool do_complete; @@ -5249,6 +5253,7 @@ static bool io_poll_remove_waitqs(struct io_kiocb *req) } static bool io_poll_remove_one(struct io_kiocb *req) + __must_hold(&req->ctx->completion_lock) { bool do_complete; @@ -5292,6 +5297,7 @@ static bool io_poll_remove_all(struct io_ring_ctx *ctx, struct task_struct *tsk, } static struct io_kiocb *io_poll_find(struct io_ring_ctx *ctx, __u64 sqe_addr) + __must_hold(&ctx->completion_lock) { struct hlist_head *list; struct io_kiocb *req; @@ -5307,6 +5313,7 @@ static struct io_kiocb *io_poll_find(struct io_ring_ctx *ctx, __u64 sqe_addr) } static int io_poll_cancel(struct io_ring_ctx *ctx, __u64 sqe_addr) + __must_hold(&ctx->completion_lock) { struct io_kiocb *req; @@ -5513,6 +5520,7 @@ static enum hrtimer_restart io_timeout_fn(struct hrtimer *timer) static struct io_kiocb *io_timeout_extract(struct io_ring_ctx *ctx, __u64 user_data) + __must_hold(&ctx->completion_lock) { struct io_timeout_data *io; struct io_kiocb *req; @@ -5537,6 +5545,7 @@ static struct io_kiocb *io_timeout_extract(struct io_ring_ctx *ctx, } static int io_timeout_cancel(struct io_ring_ctx *ctx, __u64 user_data) + __must_hold(&ctx->completion_lock) { struct io_kiocb *req = io_timeout_extract(ctx, user_data); @@ -5551,6 +5560,7 @@ static int io_timeout_cancel(struct io_ring_ctx *ctx, __u64 user_data) static int io_timeout_update(struct io_ring_ctx *ctx, __u64 user_data, struct timespec64 *ts, enum hrtimer_mode mode) + __must_hold(&ctx->completion_lock) { struct io_kiocb *req = io_timeout_extract(ctx, user_data); struct io_timeout_data *data;