From: Keith Busch <kbusch@meta.com>
To: <ming.lei@redhat.com>, <asml.silence@gmail.com>,
<axboe@kernel.dk>, <linux-block@vger.kernel.org>,
<io-uring@vger.kernel.org>
Cc: <bernd@bsbernd.com>, Keith Busch <kbusch@kernel.org>
Subject: [PATCHv2 2/6] io_uring: create resource release callback
Date: Mon, 10 Feb 2025 16:56:42 -0800 [thread overview]
Message-ID: <20250211005646.222452-3-kbusch@meta.com> (raw)
In-Reply-To: <20250211005646.222452-1-kbusch@meta.com>
From: Keith Busch <kbusch@kernel.org>
When a registered resource is about to be freed, check if it has
registered a release function, and call it if so. This is preparing for
resources that are related to an external component.
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
io_uring/rsrc.c | 2 ++
io_uring/rsrc.h | 3 +++
2 files changed, 5 insertions(+)
diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
index 4d0e1c06c8bc6..30f08cf13ef60 100644
--- a/io_uring/rsrc.c
+++ b/io_uring/rsrc.c
@@ -455,6 +455,8 @@ void io_free_rsrc_node(struct io_ring_ctx *ctx, struct io_rsrc_node *node)
case IORING_RSRC_BUFFER:
if (node->buf)
io_buffer_unmap(ctx, node);
+ if (node->release)
+ node->release(node->priv);
break;
default:
WARN_ON_ONCE(1);
diff --git a/io_uring/rsrc.h b/io_uring/rsrc.h
index abd0d5d42c3e1..a3826ab84e666 100644
--- a/io_uring/rsrc.h
+++ b/io_uring/rsrc.h
@@ -24,6 +24,9 @@ struct io_rsrc_node {
unsigned long file_ptr;
struct io_mapped_ubuf *buf;
};
+
+ void (*release)(void *);
+ void *priv;
};
struct io_mapped_ubuf {
--
2.43.5
next prev parent reply other threads:[~2025-02-11 0:57 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-11 0:56 [PATCHv2 0/6] ublk zero-copy support Keith Busch
2025-02-11 0:56 ` [PATCHv2 1/6] io_uring: use node for import Keith Busch
2025-02-11 0:56 ` Keith Busch [this message]
2025-02-13 1:31 ` [PATCHv2 2/6] io_uring: create resource release callback Pavel Begunkov
2025-02-13 1:58 ` Keith Busch
2025-02-13 13:06 ` Pavel Begunkov
2025-02-11 0:56 ` [PATCHv2 3/6] io_uring: add support for kernel registered bvecs Keith Busch
2025-02-13 1:33 ` Pavel Begunkov
2025-02-14 3:30 ` Ming Lei
2025-02-14 15:26 ` Keith Busch
2025-02-15 1:34 ` Ming Lei
2025-02-18 20:34 ` Keith Busch
2025-02-11 0:56 ` [PATCHv2 4/6] ublk: zc register/unregister bvec Keith Busch
2025-02-12 2:49 ` Ming Lei
2025-02-12 4:11 ` Keith Busch
2025-02-12 9:24 ` Ming Lei
2025-02-12 14:59 ` Keith Busch
2025-02-13 2:12 ` Pavel Begunkov
2025-02-11 0:56 ` [PATCHv2 5/6] io_uring: add abstraction for buf_table rsrc data Keith Busch
2025-02-11 0:56 ` [PATCHv2 6/6] io_uring: cache nodes and mapped buffers Keith Busch
2025-02-11 16:47 ` Keith Busch
2025-02-12 2:29 ` [PATCHv2 0/6] ublk zero-copy support Ming Lei
2025-02-12 15:28 ` Keith Busch
2025-02-12 16:06 ` Pavel Begunkov
2025-02-13 1:52 ` Ming Lei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250211005646.222452-3-kbusch@meta.com \
--to=kbusch@meta.com \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=bernd@bsbernd.com \
--cc=io-uring@vger.kernel.org \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).