Skip to content

Commit

Permalink
io_uring: inline io_uring_attempt_task_drop()
Browse files Browse the repository at this point in the history
[ Upstream commit 4f793dc ]

A simple preparation change inlining io_uring_attempt_task_drop() into
io_uring_flush().

Cc: stable@vger.kernel.org # 5.5+
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
isilence authored and gregkh committed Jan 30, 2021
1 parent 7bf3fb6 commit 18f3159
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions fs/io_uring.c
Expand Up @@ -8835,23 +8835,6 @@ static void io_uring_del_task_file(struct file *file)
fput(file);
}

/*
* Drop task note for this file if we're the only ones that hold it after
* pending fput()
*/
static void io_uring_attempt_task_drop(struct file *file)
{
if (!current->io_uring)
return;
/*
* fput() is pending, will be 2 if the only other ref is our potential
* task file note. If the task is exiting, drop regardless of count.
*/
if (fatal_signal_pending(current) || (current->flags & PF_EXITING) ||
atomic_long_read(&file->f_count) == 2)
io_uring_del_task_file(file);
}

static void io_uring_remove_task_files(struct io_uring_task *tctx)
{
struct file *file;
Expand Down Expand Up @@ -8943,7 +8926,17 @@ void __io_uring_task_cancel(void)

static int io_uring_flush(struct file *file, void *data)
{
io_uring_attempt_task_drop(file);
if (!current->io_uring)
return 0;

/*
* fput() is pending, will be 2 if the only other ref is our potential
* task file note. If the task is exiting, drop regardless of count.
*/
if (fatal_signal_pending(current) || (current->flags & PF_EXITING) ||
atomic_long_read(&file->f_count) == 2)
io_uring_del_task_file(file);

return 0;
}

Expand Down

0 comments on commit 18f3159

Please sign in to comment.