io_uring: clear IOCB_WAITQ for non -EIOCBQUEUED return
authorJens Axboe <axboe@kernel.dk>
Fri, 5 Mar 2021 04:02:58 +0000 (21:02 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Mar 2021 08:04:13 +0000 (09:04 +0100)
[ Upstream commit b5b0ecb736f1ce1e68eb50613c0cfecff10198eb ]

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>
fs/io_uring.c

index 7625b3e..06e9c21 100644 (file)
@@ -3501,6 +3501,7 @@ retry:
                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: