public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH 4/4] io_uring: Fix leaking linked timeouts
Date: Tue, 19 Nov 2019 23:32:50 +0300	[thread overview]
Message-ID: <ad5bf929b713b8cc17813c6fdcf59c55cc2a589f.1574195129.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

let have a dependant link: REQ -> LINK_TIMEOUT -> LINK_TIMEOUT

1. submission stage: submission references for REQ and LINK_TIMEOUT
are dropped. So, references respectively (1,1,2)

2. io_put(REQ) + FAIL_LINKS stage: calls io_fail_links(), which for all
linked timeouts will call cancel_timeout() and drop 1 reference.
So, references after: (0,0,1). That's a leak.

Make it treat only the first linked timeout as such, and pass others
through __io_double_put_req().

Signed-off-by: Pavel Begunkov <[email protected]>
---
 fs/io_uring.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index aa6c9fb8f640..4de7d0192666 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -934,6 +934,7 @@ static void io_fail_links(struct io_kiocb *req)
 		if ((req->flags & REQ_F_LINK_TIMEOUT) &&
 		    link->submit.sqe->opcode == IORING_OP_LINK_TIMEOUT) {
 			io_link_cancel_timeout(link);
+			req->flags &= ~REQ_F_LINK_TIMEOUT;
 		} else {
 			io_cqring_fill_event(link, -ECANCELED);
 			__io_double_put_req(link);
-- 
2.24.0


  parent reply	other threads:[~2019-11-19 20:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-19 20:32 [PATCHSET 0/4][io_uring-post] cleanup after linked timeouts Pavel Begunkov
2019-11-19 20:32 ` [PATCH 1/4] io_uring: Always REQ_F_FREE_SQE for allocated sqe Pavel Begunkov
2019-11-19 22:10   ` Jens Axboe
2019-11-20  9:03     ` Pavel Begunkov
2019-11-20 14:25       ` Jens Axboe
2019-11-19 20:32 ` [PATCH 2/4] io_uring: break links for failed defer Pavel Begunkov
2019-11-19 20:32 ` [PATCH 3/4] io_uring: remove redundant check Pavel Begunkov
2019-11-19 20:32 ` Pavel Begunkov [this message]
2019-11-19 22:10 ` [PATCHSET 0/4][io_uring-post] cleanup after linked timeouts Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ad5bf929b713b8cc17813c6fdcf59c55cc2a589f.1574195129.git.asml.silence@gmail.com \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox