From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>,
[email protected], [email protected]
Subject: [PATCH 2/3] io_uring: rename io_file_put()
Date: Sun, 17 May 2020 14:13:41 +0300 [thread overview]
Message-ID: <b9125175eb3c0e218e4d56958df09fa0220c691c.1589713554.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
io_file_put() deals with flushing state's file refs, adding "state" to
its name makes it a bit clearer. Also, avoid double check of
state->file in __io_file_get() in some cases.
Signed-off-by: Pavel Begunkov <[email protected]>
---
fs/io_uring.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 739aae7070c1..9c5a95414cbd 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -1999,15 +1999,19 @@ static void io_iopoll_req_issued(struct io_kiocb *req)
wake_up(&ctx->sqo_wait);
}
-static void io_file_put(struct io_submit_state *state)
+static void __io_state_file_put(struct io_submit_state *state)
{
- if (state->file) {
- int diff = state->has_refs - state->used_refs;
+ int diff = state->has_refs - state->used_refs;
- if (diff)
- fput_many(state->file, diff);
- state->file = NULL;
- }
+ if (diff)
+ fput_many(state->file, diff);
+ state->file = NULL;
+}
+
+static inline void io_state_file_put(struct io_submit_state *state)
+{
+ if (state->file)
+ __io_state_file_put(state);
}
/*
@@ -2026,7 +2030,7 @@ static struct file *__io_file_get(struct io_submit_state *state, int fd)
state->ios_left--;
return state->file;
}
- io_file_put(state);
+ __io_state_file_put(state);
}
state->file = fget_many(fd, state->ios_left);
if (!state->file)
@@ -5799,7 +5803,7 @@ static int io_submit_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
static void io_submit_state_end(struct io_submit_state *state)
{
blk_finish_plug(&state->plug);
- io_file_put(state);
+ io_state_file_put(state);
if (state->free_reqs)
kmem_cache_free_bulk(req_cachep, state->free_reqs, state->reqs);
}
--
2.24.0
next prev parent reply other threads:[~2020-05-17 11:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-17 11:13 [PATCH for-next 0/3] unrelated cleanups for next Pavel Begunkov
2020-05-17 11:13 ` [PATCH 1/3] io_uring: remove req->needs_fixed_files Pavel Begunkov
2020-05-17 11:13 ` Pavel Begunkov [this message]
2020-05-17 11:13 ` [PATCH 3/3] io_uring: don't repeat valid flag list Pavel Begunkov
2020-05-17 20:24 ` [PATCH for-next 0/3] unrelated cleanups for next 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=b9125175eb3c0e218e4d56958df09fa0220c691c.1589713554.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