[PATCHv2 2/6] io_uring: create resource release callback

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Keith Busch <kbusch@xxxxxxxxxx>

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@xxxxxxxxxx>
---
 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






[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux