From: Diangang Li On nonblocking issue, io_attach_dmabuf_map() returns -EAGAIN if no map is available. This happens before io_rw_init_file() sets REQ_F_NOWAIT, so an RWF_NOWAIT request is punted to io-wq and can block instead of completing with -EAGAIN. Set REQ_F_NOWAIT on this path to prevent the retry. Requests issued directly from io-wq can still create the map in blocking mode. Fixes: 62e4bf5b25d4 ("io_uring/rsrc: add dmabuf backed registered buffers") Assisted-by: LLM Signed-off-by: Diangang Li --- io_uring/rw.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/io_uring/rw.c b/io_uring/rw.c index 3ecb842147a4..6e4e8fbc9ff1 100644 --- a/io_uring/rw.c +++ b/io_uring/rw.c @@ -368,8 +368,16 @@ static int io_init_rw_fixed(struct io_kiocb *req, unsigned int issue_flags, } ret = io_attach_dmabuf_map(req, &io->iter, issue_flags); - if (ret) + if (unlikely(ret)) { + /* + * This runs before io_rw_init_file() sets REQ_F_NOWAIT. Set it + * here for RWF_NOWAIT, or -EAGAIN for a map that doesn't exist + * yet punts the request to io-wq, where it will block. + */ + if (ret == -EAGAIN && (rw->flags & RWF_NOWAIT)) + io_req_set_flags(req, REQ_F_NOWAIT); return ret; + } return 0; } -- 2.39.5