Skip to content

Commit 3e69426

Browse files
committed
io_uring: punt even fadvise() WILLNEED to async context
Andres correctly points out that read-ahead can block, if it needs to read in meta data (or even just through the page cache page allocations). Play it safe for now and just ensure WILLNEED is also punted to async context. While in there, allow the file settings hints from non-blocking context. They don't need to start/do IO, and we can safely do them inline. Fixes: 4840e41 ("io_uring: add IORING_OP_FADVISE") Reported-by: Andres Freund <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 1a417f4 commit 3e69426

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

fs/io_uring.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2730,9 +2730,16 @@ static int io_fadvise(struct io_kiocb *req, struct io_kiocb **nxt,
27302730
struct io_fadvise *fa = &req->fadvise;
27312731
int ret;
27322732

2733-
/* DONTNEED may block, others _should_ not */
2734-
if (fa->advice == POSIX_FADV_DONTNEED && force_nonblock)
2735-
return -EAGAIN;
2733+
if (force_nonblock) {
2734+
switch (fa->advice) {
2735+
case POSIX_FADV_NORMAL:
2736+
case POSIX_FADV_RANDOM:
2737+
case POSIX_FADV_SEQUENTIAL:
2738+
break;
2739+
default:
2740+
return -EAGAIN;
2741+
}
2742+
}
27362743

27372744
ret = vfs_fadvise(req->file, fa->offset, fa->len, fa->advice);
27382745
if (ret < 0)

0 commit comments

Comments
 (0)