It's hard to implement cloning if the internal structure needs to be mutable and/or relies on other ring resources. In preparation to such buffer types, add a flag indicating that the buffer can't be cloned. It might be possible to add cloning in the future for them, but that would likely need reallocating the structure and reacquiring resources in case by case manner.
Signed-off-by: Pavel Begunkov <[email protected]> --- io_uring/rsrc.c | 5 +++++ io_uring/rsrc.h | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c index 24fc3232a66a..d57e8a0380b5 100644 --- a/io_uring/rsrc.c +++ b/io_uring/rsrc.c @@ -1381,6 +1381,11 @@ static int io_clone_buffers(struct io_ring_ctx *ctx, struct io_ring_ctx *src_ctx if (!src_node) { dst_node = NULL; } else { + if (src_node->buf->flags & IO_REGBUF_F_UNCLONEABLE) { + io_rsrc_data_free(ctx, &data); + return -ENOMEM; + } + dst_node = io_rsrc_node_alloc(ctx, IORING_RSRC_BUFFER); if (!dst_node) { io_rsrc_data_free(ctx, &data); diff --git a/io_uring/rsrc.h b/io_uring/rsrc.h index 98ae8ef51009..83aa86e6f320 100644 --- a/io_uring/rsrc.h +++ b/io_uring/rsrc.h @@ -29,7 +29,8 @@ enum { }; enum { - IO_REGBUF_F_KBUF = 1, + IO_REGBUF_F_KBUF = 1 << 0, + IO_REGBUF_F_UNCLONEABLE = 1 << 1, }; struct io_mapped_ubuf { -- 2.54.0

