diff options
author | Pavel Begunkov <asml.silence@gmail.com> | 2023-04-11 12:06:08 +0100 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2023-04-12 12:09:41 -0600 |
commit | d581076b6a85c6f8308a4ba2bdcd82651f5183df (patch) | |
tree | b10345de51c30b4f7a2230a44e5cbc0e4f3a81b4 /io_uring | |
parent | 2933ae6eaa05e8db6ad33a3ca12af18d2a25358c (diff) | |
download | linux-stable-d581076b6a85c6f8308a4ba2bdcd82651f5183df.tar.gz linux-stable-d581076b6a85c6f8308a4ba2bdcd82651f5183df.tar.bz2 linux-stable-d581076b6a85c6f8308a4ba2bdcd82651f5183df.zip |
io_uring/rsrc: extract SCM file put helper
SCM file accounting is a slow path and is only used for UNIX files.
Extract a helper out of io_rsrc_file_put() that does the SCM
unaccounting.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/58cc7bffc2ee96bec8c2b89274a51febcbfa5556.1681210788.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring')
-rw-r--r-- | io_uring/rsrc.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c index f2c660ffea74..11058e20bdcc 100644 --- a/io_uring/rsrc.c +++ b/io_uring/rsrc.c @@ -832,20 +832,14 @@ int __io_scm_file_account(struct io_ring_ctx *ctx, struct file *file) return 0; } -static void io_rsrc_file_put(struct io_ring_ctx *ctx, struct io_rsrc_put *prsrc) +static __cold void io_rsrc_file_scm_put(struct io_ring_ctx *ctx, struct file *file) { - struct file *file = prsrc->file; #if defined(CONFIG_UNIX) struct sock *sock = ctx->ring_sock->sk; struct sk_buff_head list, *head = &sock->sk_receive_queue; struct sk_buff *skb; int i; - if (!io_file_need_scm(file)) { - fput(file); - return; - } - __skb_queue_head_init(&list); /* @@ -895,11 +889,19 @@ static void io_rsrc_file_put(struct io_ring_ctx *ctx, struct io_rsrc_put *prsrc) __skb_queue_tail(head, skb); spin_unlock_irq(&head->lock); } -#else - fput(file); #endif } +static void io_rsrc_file_put(struct io_ring_ctx *ctx, struct io_rsrc_put *prsrc) +{ + struct file *file = prsrc->file; + + if (likely(!io_file_need_scm(file))) + fput(file); + else + io_rsrc_file_scm_put(ctx, file); +} + int io_sqe_files_register(struct io_ring_ctx *ctx, void __user *arg, unsigned nr_args, u64 __user *tags) { |