summaryrefslogtreecommitdiffstats
path: root/fs/io_uring.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2020-02-07 15:45:22 -0700
committerJens Axboe <axboe@kernel.dk>2020-02-08 13:06:58 -0700
commitfaac996ccd5da95bc56b91aa80f2643c2d0a1c56 (patch)
treec72e65a137a614e78055b7460e96c719f9488bb0 /fs/io_uring.c
parent8fef80bf56a49c60b457dedb99fd6c5279a5dbe1 (diff)
downloadlinux-stable-faac996ccd5da95bc56b91aa80f2643c2d0a1c56.tar.gz
linux-stable-faac996ccd5da95bc56b91aa80f2643c2d0a1c56.tar.bz2
linux-stable-faac996ccd5da95bc56b91aa80f2643c2d0a1c56.zip
io_uring: retry raw bdev writes if we hit -EOPNOTSUPP
For non-blocking issue, we set IOCB_NOWAIT in the kiocb. However, on a raw block device, this yields an -EOPNOTSUPP return, as non-blocking writes aren't supported. Turn this -EOPNOTSUPP into -EAGAIN, so we retry from blocking context with IOCB_NOWAIT cleared. Cc: stable@vger.kernel.org # 5.5 Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io_uring.c')
-rw-r--r--fs/io_uring.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index e6829d1bf4b4..1a3ca6577a10 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2340,6 +2340,12 @@ static int io_write(struct io_kiocb *req, struct io_kiocb **nxt,
ret2 = call_write_iter(req->file, kiocb, &iter);
else
ret2 = loop_rw_iter(WRITE, req->file, kiocb, &iter);
+ /*
+ * Raw bdev writes will -EOPNOTSUPP for IOCB_NOWAIT. Just
+ * retry them without IOCB_NOWAIT.
+ */
+ if (ret2 == -EOPNOTSUPP && (kiocb->ki_flags & IOCB_NOWAIT))
+ ret2 = -EAGAIN;
if (!force_nonblock || ret2 != -EAGAIN) {
kiocb_done(kiocb, ret2, nxt, req->in_async);
} else {