stable-5.12 backport fixes
Subsystems (2)
cover stable-5.12 backport fixes
a298232ee6b9a1 ("io_uring: fix link timeout refs") was backported, however the second chunk of it got discarded, which breaks io_uring. It depends on another patch, so backport it first (patch 1/2) and then apply a298232ee6b9a1 again (patch 2/2).
It's a bit messy, the patch will be in the tree twice. Let me know if there is a better way.
Pavel Begunkov (2):
io_uring: put link timeout req consistently
io_uring: fix link timeout refs
fs/io_uring.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
Signature · 1 line
2.32.0
PATCH 1/2 io_uring: put link timeout req consistently
[ Upstream commit df9727affa058f4f18e388b30247650f8ae13cd8 ]
Don't put linked timeout req in io_async_find_and_cancel() but do it in io_link_timeout_fn(), so we have only one point for that and won't have to do it differently as it's now (put vs put_deferred). Btw, improve a bit io_async_find_and_cancel()'s locking.
--- fs/io_uring.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
fs/io_uring.c +3 -7
@@ -5727,12 +5727,9 @@ static void io_async_find_and_cancel(struct io_ring_ctx *ctx,int ret; ret =io_async_cancel_one (req->task->io_uring, sqe_addr, ctx); -if (ret != -ENOENT ) { -spin_lock_irqsave (&ctx->completion_lock, flags); - goto done; - } -spin_lock_irqsave (&ctx->completion_lock, flags); +if (ret != -ENOENT ) + goto done; ret =io_timeout_cancel (ctx, sqe_addr);if (ret != -ENOENT ) goto done;
@@ -5747,7 +5744,6 @@ static void io_async_find_and_cancel(struct io_ring_ctx *ctx,if (ret <0 )req_set_fail_links (req); -io_put_req (req); } static int io_async_cancel_prep(struct io_kiocb *req,
@@ -6310,8 +6306,8 @@ static enum hrtimer_restart io_link_timeout_fn(struct hrtimer *timer)io_put_req_deferred (req,1 ); }else {io_req_complete_post (req, -ETIME ,0 ); -io_put_req_deferred (req,1 ); } +io_put_req_deferred (req,1 );return HRTIMER_NORESTART ; }
Signature · 1 line
2.32.0
PATCH 2/2 io_uring: fix link timeout refs
In reply to Pavel Begunkov[ Upstream commit a298232ee6b9a1d5d732aa497ff8be0d45b5bd82 ]
WARNING: CPU: 0 PID: 10242 at lib/refcount.c:28 refcount_warn_saturate+0x15b/0x1a0 lib/refcount.c:28 RIP: 0010:refcount_warn_saturate+0x15b/0x1a0 lib/refcount.c:28 Call Trace: __refcount_sub_and_test include/linux/refcount.h:283 [inline] __refcount_dec_and_test include/linux/refcount.h:315 [inline] refcount_dec_and_test include/linux/refcount.h:333 [inline] io_put_req fs/io_uring.c:2140 [inline] io_queue_linked_timeout fs/io_uring.c:6300 [inline] __io_queue_sqe+0xbef/0xec0 fs/io_uring.c:6354 io_submit_sqe fs/io_uring.c:6534 [inline] io_submit_sqes+0x2bbd/0x7c50 fs/io_uring.c:6660 __do_sys_io_uring_enter fs/io_uring.c:9240 [inline] __se_sys_io_uring_enter+0x256/0x1d60 fs/io_uring.c:9182
io_link_timeout_fn() should put only one reference of the linked timeout request, however in case of racing with the master request's completion first io_req_complete() puts one and then io_put_req_deferred() is called.
--- fs/io_uring.c | 1 - 1 file changed, 1 deletion(-)
fs/io_uring.c +0 -1
@@ -6307,7 +6307,6 @@ static enum hrtimer_restart io_link_timeout_fn(struct hrtimer *timer) }else {io_req_complete_post (req, -ETIME ,0 ); } -io_put_req_deferred (req,1 );return HRTIMER_NORESTART ; }
Signature · 1 line
2.32.0
Quoted 8 lines · Pavel Begunkov
a298232ee6b9a1("io_uring: fix link timeout refs") was backported, however the second chunk of it got discarded, which breaksio_uring. It depends on another patch, so backport it first (patch 1/2) and then applya298232ee6b9a1again (patch 2/2).It's a bit messy, the patch will be in the tree twice. Let me know if there is a better way.
Quoted 6 lines
Pavel Begunkov (2):
io_uring: put link timeout req consistently
io_uring: fix link timeout refsfs/io_uring.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
Not a problem, thanks for these. This is going to be the last 5.12.y release, so it shouldn't be that confusing.
thanks,
greg k-h
Quoted 13 lines · Greg KH
Quoted 12 lines · Pavel Begunkov
a298232ee6b9a1("io_uring: fix link timeout refs") was backported, however the second chunk of it got discarded, which breaksio_uring. It depends on another patch, so backport it first (patch 1/2) and then applya298232ee6b9a1again (patch 2/2).It's a bit messy, the patch will be in the tree twice. Let me know if there is a better way.
Pavel Begunkov (2):
io_uring: put link timeout req consistently
io_uring: fix link timeout refs
Quoted 5 lines
Quoted 2 lines
fs/io_uring.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)Not a problem, thanks for these. This is going to be the last 5.12.y release, so it shouldn't be that confusing.
Perfect, thanks Greg
Signature · 1 line
Pavel Begunkov