From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>,
[email protected], [email protected]
Cc: [email protected]
Subject: [PATCH 2/2] io_uring: cancel by ->task not pid
Date: Mon, 15 Jun 2020 10:33:14 +0300 [thread overview]
Message-ID: <356acaf3ea3a0f62e77a65e10c940e4656aa6b81.1592206077.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
For an exiting process it tries to cancel all its inflight requests.
Use req->task to match such instead of work.pid. We always have
req->task set, and it will be valid because we're matching only
current exiting task.
Also, remove work.pid and everything related, it's useless now
Reported-by: Eric W. Biederman <[email protected]>
Signed-off-by: Pavel Begunkov <[email protected]>
---
fs/io-wq.h | 1 -
fs/io_uring.c | 16 ++++++----------
2 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/fs/io-wq.h b/fs/io-wq.h
index b72538fe5afd..071f1a997800 100644
--- a/fs/io-wq.h
+++ b/fs/io-wq.h
@@ -90,7 +90,6 @@ struct io_wq_work {
const struct cred *creds;
struct fs_struct *fs;
unsigned flags;
- pid_t task_pid;
};
static inline struct io_wq_work *wq_next_work(struct io_wq_work *work)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index f05d2e45965e..54addaba742d 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -1065,8 +1065,6 @@ static inline void io_req_work_grab_env(struct io_kiocb *req,
}
spin_unlock(¤t->fs->lock);
}
- if (!req->work.task_pid)
- req->work.task_pid = task_pid_vnr(current);
}
static inline void io_req_work_drop_env(struct io_kiocb *req)
@@ -7455,11 +7453,12 @@ static void io_uring_cancel_files(struct io_ring_ctx *ctx,
}
}
-static bool io_cancel_pid_cb(struct io_wq_work *work, void *data)
+static bool io_cancel_task_cb(struct io_wq_work *work, void *data)
{
- pid_t pid = (pid_t) (unsigned long) data;
+ struct io_kiocb *req = container_of(work, struct io_kiocb, work);
+ struct task_struct *task = data;
- return work->task_pid == pid;
+ return req->task == task;
}
static int io_uring_flush(struct file *file, void *data)
@@ -7471,11 +7470,8 @@ static int io_uring_flush(struct file *file, void *data)
/*
* If the task is going away, cancel work it may have pending
*/
- if (fatal_signal_pending(current) || (current->flags & PF_EXITING)) {
- void *data = (void *) (unsigned long)task_pid_vnr(current);
-
- io_wq_cancel_cb(ctx->io_wq, io_cancel_pid_cb, data, true);
- }
+ if (fatal_signal_pending(current) || (current->flags & PF_EXITING))
+ io_wq_cancel_cb(ctx->io_wq, io_cancel_task_cb, current, true);
return 0;
}
--
2.24.0
next prev parent reply other threads:[~2020-06-15 7:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-15 7:33 [PATCH 0/2] don't use pid for request cancellation Pavel Begunkov
2020-06-15 7:33 ` [PATCH 1/2] io_uring: lazy get task Pavel Begunkov
2020-06-15 7:33 ` Pavel Begunkov [this message]
2020-06-15 15:04 ` [PATCH 0/2] don't use pid for request cancellation Jens Axboe
2020-06-15 16:01 ` Pavel Begunkov
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=356acaf3ea3a0f62e77a65e10c940e4656aa6b81.1592206077.git.asml.silence@gmail.com \
[email protected] \
[email protected] \
[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