Skip to content

Commit 6b5733e

Browse files
isilenceaxboe
authored andcommitted
io_uring: add warn_once for io_uring_flush()
files_cancel() should cancel all relevant requests and drop file notes, so we should never have file notes after that, including on-exit fput and flush. Add a WARN_ONCE to be sure. Signed-off-by: Pavel Begunkov <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 4f793dc commit 6b5733e

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

fs/io_uring.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9055,17 +9055,23 @@ void __io_uring_task_cancel(void)
90559055

90569056
static int io_uring_flush(struct file *file, void *data)
90579057
{
9058-
if (!current->io_uring)
9058+
struct io_uring_task *tctx = current->io_uring;
9059+
9060+
if (!tctx)
90599061
return 0;
90609062

9063+
/* we should have cancelled and erased it before PF_EXITING */
9064+
WARN_ON_ONCE((current->flags & PF_EXITING) &&
9065+
xa_load(&tctx->xa, (unsigned long)file));
9066+
90619067
/*
90629068
* fput() is pending, will be 2 if the only other ref is our potential
90639069
* task file note. If the task is exiting, drop regardless of count.
90649070
*/
9065-
if (fatal_signal_pending(current) || (current->flags & PF_EXITING) ||
9066-
atomic_long_read(&file->f_count) == 2)
9067-
io_uring_del_task_file(file);
9071+
if (atomic_long_read(&file->f_count) != 2)
9072+
return 0;
90689073

9074+
io_uring_del_task_file(file);
90699075
return 0;
90709076
}
90719077

0 commit comments

Comments
 (0)