From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH 4/6] io_uring: remove work flags after cleanup
Date: Mon, 1 Feb 2021 18:59:54 +0000 [thread overview]
Message-ID: <9329c4fd29793aeb05910f92625d8c62dd7d3312.1612205712.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
Shouldn't be a problem now, but it's better to clean
REQ_F_WORK_INITIALIZED and work->flags only after relevant resources are
killed, so cancellation see them.
Signed-off-by: Pavel Begunkov <[email protected]>
---
fs/io_uring.c | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 0ee452d43817..7dc3d4260158 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -1374,22 +1374,14 @@ static void io_req_clean_work(struct io_kiocb *req)
if (!(req->flags & REQ_F_WORK_INITIALIZED))
return;
- req->flags &= ~REQ_F_WORK_INITIALIZED;
-
- if (req->work.flags & IO_WQ_WORK_MM) {
+ if (req->work.flags & IO_WQ_WORK_MM)
mmdrop(req->work.identity->mm);
- req->work.flags &= ~IO_WQ_WORK_MM;
- }
#ifdef CONFIG_BLK_CGROUP
- if (req->work.flags & IO_WQ_WORK_BLKCG) {
+ if (req->work.flags & IO_WQ_WORK_BLKCG)
css_put(req->work.identity->blkcg_css);
- req->work.flags &= ~IO_WQ_WORK_BLKCG;
- }
#endif
- if (req->work.flags & IO_WQ_WORK_CREDS) {
+ if (req->work.flags & IO_WQ_WORK_CREDS)
put_cred(req->work.identity->creds);
- req->work.flags &= ~IO_WQ_WORK_CREDS;
- }
if (req->work.flags & IO_WQ_WORK_FS) {
struct fs_struct *fs = req->work.identity->fs;
@@ -1399,12 +1391,10 @@ static void io_req_clean_work(struct io_kiocb *req)
spin_unlock(&req->work.identity->fs->lock);
if (fs)
free_fs_struct(fs);
- req->work.flags &= ~IO_WQ_WORK_FS;
}
if (req->work.flags & IO_WQ_WORK_FILES) {
put_files_struct(req->work.identity->files);
put_nsproxy(req->work.identity->nsproxy);
- req->work.flags &= ~IO_WQ_WORK_FILES;
}
if (req->flags & REQ_F_INFLIGHT) {
struct io_ring_ctx *ctx = req->ctx;
@@ -1419,6 +1409,9 @@ static void io_req_clean_work(struct io_kiocb *req)
wake_up(&tctx->wait);
}
+ req->flags &= ~REQ_F_WORK_INITIALIZED;
+ req->work.flags &= ~(IO_WQ_WORK_MM | IO_WQ_WORK_BLKCG | IO_WQ_WORK_FS |
+ IO_WQ_WORK_CREDS | IO_WQ_WORK_FILES);
io_put_identity(req->task->io_uring, req);
}
--
2.24.0
next prev parent reply other threads:[~2021-02-01 19:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-01 18:59 [PATCH 0/6] for-5.12 stuff Pavel Begunkov
2021-02-01 18:59 ` [PATCH 1/6] io_uring: fix inconsistent lock state Pavel Begunkov
2021-02-01 18:59 ` [PATCH 2/6] io_uring: kill not used needs_file_no_error Pavel Begunkov
2021-02-01 18:59 ` [PATCH 3/6] io_uring: inline io_req_drop_files() Pavel Begunkov
2021-02-01 18:59 ` Pavel Begunkov [this message]
2021-02-01 18:59 ` [PATCH 5/6] io_uring: deduplicate adding to REQ_F_INFLIGHT Pavel Begunkov
2021-02-01 18:59 ` [PATCH 6/6] io_uring: simplify do_read return parsing Pavel Begunkov
2021-02-01 20:11 ` [PATCH 0/6] for-5.12 stuff 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=9329c4fd29793aeb05910f92625d8c62dd7d3312.1612205712.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