diff --git a/fs/io_uring.c b/fs/io_uring.c index 7734f5fdd73997b957722808448428f74d5de347..1e6a8402e0c14dd1ad857108926633de68e4f376 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -5076,11 +5076,14 @@ static int io_sqe_files_unregister(struct io_ring_ctx *ctx) return -ENXIO; /* protect against inflight atomic switch, which drops the ref */ - flush_work(&data->ref_work); percpu_ref_get(&data->refs); + /* wait for existing switches */ + flush_work(&data->ref_work); percpu_ref_kill_and_confirm(&data->refs, io_file_ref_kill); wait_for_completion(&data->done); percpu_ref_put(&data->refs); + /* flush potential new switch */ + flush_work(&data->ref_work); percpu_ref_exit(&data->refs); __io_sqe_files_unregister(ctx);