io_uring: ensure IOSQE_ASYNC file table grabbing works with SQPOLL
Fd instantiating commands like IORING_OP_ACCEPT now work with SQPOLL, but
we have an error in grabbing that if IOSQE_ASYNC is set. Ensure we assign
the ring fd/file appropriately so we can defer grab them.
Hook off fops->flush() for managing the ring fd/file. If the original
ring fd is closed, then clear the existing entry and mark us as needing
a new assignment. This process works just like any other need the SQPOLL
thread has for needing the application to enter the kernel, using the
NEED_WAKEUP flag. In the interim, this ctx isn't processing new
submissions. Once the application enters the kernel and sees the need
to assign new ring fd/file values, it'll do so and submission
processing can resume.
If an application wishes to use SQPOLL without registered files, and it
dups/receives/whatever a new descriptor for the ring without closing
the other one, it must ensure that io_uring_enter() is called to update
the ring fd. This is done automatically, the application just has to
ensure that the call is made (eg through manual io_uring_enter() call,
or forcing IORING_ENTER_SQ_WAKEUP if using liburing).
Reported-by: Josef Grieb <josef.grieb@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>