io_uring: clear IOCB_WAITQ for non -EIOCBQUEUED return

[ Upstream commit b5b0ecb736 ]

The callback can only be armed, if we get -EIOCBQUEUED returned. It's
important that we clear the WAITQ bit for other cases, otherwise we can
queue for async retry and filemap will assume that we're armed and
return -EAGAIN instead of just blocking for the IO.

Cc: stable@vger.kernel.org # 5.9+
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Jens Axboe 2021-03-04 21:02:58 -07:00 committed by Greg Kroah-Hartman
parent 3c08f772ad
commit 76f496681d

View File

@ -3501,6 +3501,7 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,
goto out_free;
} else if (ret > 0 && ret < io_size) {
/* we got some bytes, but not all. retry. */
kiocb->ki_flags &= ~IOCB_WAITQ;
goto retry;
}
done: