From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>,
[email protected], [email protected]
Subject: [PATCH v3 3/6] io_uring: move ring_fd into io_submit_state
Date: Sat, 1 Feb 2020 01:15:52 +0300 [thread overview]
Message-ID: <b5f01a0c66b53f5bdc503fb0fbda848dbd6d3ece.1580508735.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
ring_fd and ring_file are set per submission, so move them into
the submission state.
Signed-off-by: Pavel Begunkov <[email protected]>
---
fs/io_uring.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 6109969709ff..725e852e22c5 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -216,6 +216,9 @@ struct io_submit_state {
unsigned int has_refs;
unsigned int used_refs;
unsigned int ios_left;
+
+ struct file *ring_file;
+ int ring_fd;
};
struct io_ring_ctx {
@@ -274,8 +277,6 @@ struct io_ring_ctx {
*/
struct fixed_file_data *file_data;
unsigned nr_user_files;
- int ring_fd;
- struct file *ring_file;
/* if used, fixed mapped user buffers */
unsigned nr_user_bufs;
@@ -2822,7 +2823,7 @@ static int io_close_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
req->close.fd = READ_ONCE(sqe->fd);
if (req->file->f_op == &io_uring_fops ||
- req->close.fd == req->ctx->ring_fd)
+ req->close.fd == req->ctx->submit_state.ring_fd)
return -EBADF;
return 0;
@@ -4517,10 +4518,11 @@ static int io_grab_files(struct io_kiocb *req)
{
int ret = -EBADF;
struct io_ring_ctx *ctx = req->ctx;
+ struct io_submit_state *state = &ctx->submit_state;
if (req->work.files)
return 0;
- if (!ctx->ring_file)
+ if (!state->ring_file)
return -EBADF;
rcu_read_lock();
@@ -4531,7 +4533,7 @@ static int io_grab_files(struct io_kiocb *req)
* the fd has changed since we started down this path, and disallow
* this operation if it has.
*/
- if (fcheck(ctx->ring_fd) == ctx->ring_file) {
+ if (fcheck(state->ring_fd) == state->ring_file) {
list_add(&req->inflight_entry, &ctx->inflight_list);
req->flags |= REQ_F_INFLIGHT;
req->work.files = current->files;
@@ -4839,13 +4841,17 @@ static void io_submit_end(struct io_ring_ctx *ctx)
/*
* Start submission side cache.
*/
-static void io_submit_start(struct io_ring_ctx *ctx, unsigned int max_ios)
+static void io_submit_start(struct io_ring_ctx *ctx, unsigned int max_ios,
+ struct file *ring_file, int ring_fd)
{
struct io_submit_state *state = &ctx->submit_state;
state->free_reqs = 0;
state->file = NULL;
state->ios_left = max_ios;
+
+ state->ring_file = ring_file;
+ state->ring_fd = ring_fd;
}
static void io_commit_sqring(struct io_ring_ctx *ctx)
@@ -4926,13 +4932,10 @@ static int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr,
if (!percpu_ref_tryget_many(&ctx->refs, nr))
return -EAGAIN;
- io_submit_start(ctx, nr);
+ io_submit_start(ctx, nr, ring_file, ring_fd);
if (nr > IO_PLUG_THRESHOLD)
blk_start_plug(&plug);
- ctx->ring_fd = ring_fd;
- ctx->ring_file = ring_file;
-
for (i = 0; i < nr; i++) {
const struct io_uring_sqe *sqe;
struct io_kiocb *req;
--
2.24.0
next prev parent reply other threads:[~2020-01-31 22:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-31 22:15 [PATCH v3 0/6] add persistent submission state Pavel Begunkov
2020-01-31 22:15 ` [PATCH v3 1/6] io_uring: always pass non-null io_submit_state Pavel Begunkov
2020-01-31 22:15 ` [PATCH v3 2/6] io_uring: place io_submit_state into ctx Pavel Begunkov
2020-01-31 22:15 ` Pavel Begunkov [this message]
2020-01-31 22:15 ` [PATCH v3 4/6] io_uring: move *link into io_submit_state Pavel Begunkov
2020-01-31 22:15 ` [PATCH v3 5/6] io_uring: persistent req bulk allocation cache Pavel Begunkov
2020-01-31 22:15 ` [PATCH v3 6/6] io_uring: optimise " Pavel Begunkov
2020-01-31 22:22 ` [PATCH v3 0/6] add persistent submission state Jens Axboe
2020-01-31 22:32 ` Pavel Begunkov
2020-02-01 0:31 ` Pavel Begunkov
2020-02-01 2:10 ` Jens Axboe
2020-02-01 11:42 ` 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=b5f01a0c66b53f5bdc503fb0fbda848dbd6d3ece.1580508735.git.asml.silence@gmail.com \
[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