Skip to content

Commit

Permalink
io_uring/rw: treat -EOPNOTSUPP for IOCB_NOWAIT like -EAGAIN
Browse files Browse the repository at this point in the history
Some file systems, ocfs2 in this case, will return -EOPNOTSUPP for
an IOCB_NOWAIT read/write attempt. While this can be argued to be
correct, the usual return value for something that requires blocking
issue is -EAGAIN.

A refactoring io_uring commit dropped calling kiocb_done() for
negative return values, which is otherwise where we already do that
transformation. To ensure we catch it in both spots, check it in
__io_read() itself as well.

Reported-by: Robert Sander <[email protected]>
Link: https://fosstodon.org/@[email protected]/113112431889638440
Cc: [email protected]
Fixes: a08d195 ("io_uring/rw: split io_read() into a helper")
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Sep 10, 2024
1 parent f011c9c commit c0a9d49
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions io_uring/rw.c
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,14 @@ static int __io_read(struct io_kiocb *req, unsigned int issue_flags)

ret = io_iter_do_read(rw, &io->iter);

/*
* Some file systems like to return -EOPNOTSUPP for an IOCB_NOWAIT
* issue, even though they should be returning -EAGAIN. To be safe,
* retry from blocking context for either.
*/
if (ret == -EOPNOTSUPP && force_nonblock)
ret = -EAGAIN;

if (ret == -EAGAIN || (req->flags & REQ_F_REISSUE)) {
req->flags &= ~REQ_F_REISSUE;
/* If we can poll, just do that. */
Expand Down

0 comments on commit c0a9d49

Please sign in to comment.