]> git.baikalelectronics.ru Git - kernel.git/commit
io_uring: fix potential hang with polled IO
authorJens Axboe <axboe@kernel.dk>
Mon, 19 Aug 2019 18:15:59 +0000 (12:15 -0600)
committerJens Axboe <axboe@kernel.dk>
Tue, 20 Aug 2019 17:01:58 +0000 (11:01 -0600)
commit12c5428296f623b7b4931cef9f10276b70c9a10a
treef73f93d0f7d5a76b4f71dfc70fa30008a93d204c
parent75eaf80f84ebc7588c50189fc3b72bcd0f66e5fc
io_uring: fix potential hang with polled IO

If a request issue ends up being punted to async context to avoid
blocking, we can get into a situation where the original application
enters the poll loop for that very request before it has been issued.
This should not be an issue, except that the polling will hold the
io_uring uring_ctx mutex for the duration of the poll. When the async
worker has actually issued the request, it needs to acquire this mutex
to add the request to the poll issued list. Since the application
polling is already holding this mutex, the workqueue sleeps on the
mutex forever, and the application thus never gets a chance to poll for
the very request it was interested in.

Fix this by ensuring that the polling drops the uring_ctx occasionally
if it's not making any progress.

Reported-by: Jeffrey M. Birnbaum <jmbnyc@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c