* [PATCH 1/2] io_uring/dma-buf: release the I/O context before the target file
@ 2026-11-30 7:28 Diangang Li
2026-11-30 7:28 ` [PATCH 2/2] io_uring/rw: honour RWF_NOWAIT when a dma-buf map is missing Diangang Li
0 siblings, 1 reply; 2+ messages in thread
From: Diangang Li @ 2026-11-30 7:28 UTC (permalink / raw)
To: axboe, asml.silence; +Cc: io-uring, linux-kernel, Diangang Li
From: Diangang Li <lidiangang@bytedance.com>
io_release_dmabuf() drops the target file before destroying the I/O
context. If the final file release runs via delayed_fput_work, it can
drop the importer's module reference before the ->unmap() and ->release()
callbacks have completed.
Release the context first so the target file pins the module throughout
teardown.
Fixes: 62e4bf5b25d4 ("io_uring/rsrc: add dmabuf backed registered buffers")
Assisted-by: LLM
Signed-off-by: Diangang Li <lidiangang@bytedance.com>
---
io_uring/dma-buf.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/io_uring/dma-buf.c b/io_uring/dma-buf.c
index 61825d59e384..255767cdb1ca 100644
--- a/io_uring/dma-buf.c
+++ b/io_uring/dma-buf.c
@@ -4,8 +4,9 @@ static inline void io_release_dmabuf(void *priv)
{
struct io_buf_dma *bd = priv;
- fput(bd->target_file);
+ /* the open target file keeps the importer's module loaded */
dma_buf_io_ctx_release(bd->ctx);
+ fput(bd->target_file);
kfree(bd);
}
--
2.39.5
^ permalink raw reply [flat|nested] 2+ messages in thread* [PATCH 2/2] io_uring/rw: honour RWF_NOWAIT when a dma-buf map is missing
2026-11-30 7:28 [PATCH 1/2] io_uring/dma-buf: release the I/O context before the target file Diangang Li
@ 2026-11-30 7:28 ` Diangang Li
0 siblings, 0 replies; 2+ messages in thread
From: Diangang Li @ 2026-11-30 7:28 UTC (permalink / raw)
To: axboe, asml.silence; +Cc: io-uring, linux-kernel, Diangang Li
From: Diangang Li <lidiangang@bytedance.com>
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 <lidiangang@bytedance.com>
---
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-30 7:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-30 7:28 [PATCH 1/2] io_uring/dma-buf: release the I/O context before the target file Diangang Li
2026-11-30 7:28 ` [PATCH 2/2] io_uring/rw: honour RWF_NOWAIT when a dma-buf map is missing Diangang Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®