io\_uring\_clone\_buffers(3) liburing Manual io\_uring\_clone\_buffers(3)

# [NAME](#NAME)

io\_uring\_clone\_buffers - Clones registered buffers between rings

# [SYNOPSIS](#SYNOPSIS)

```
#include <liburing.h>
```

```
int io_uring_clone_buffers(struct io_uring *dst,
                           struct io_uring * src);
```

```
int __io_uring_clone_buffers(struct io_uring *dst,
                             struct io_uring * src,
                             unsigned int flags);
```

```
int io_uring_clone_buffers_offset(struct io_uring *dst,
                                  struct io_uring * src,
                                  unsigned int dst_off,
                                  unsigned int src_off,
                                  unsigned int nr,
                                  unsigned int flags);
```

```
int __io_uring_clone_buffers_offset(struct io_uring *dst,
                                    struct io_uring * src,
                                    unsigned int dst_off,
                                    unsigned int src_off,
                                    unsigned int nr,
                                    unsigned int flags);
```

```

```

# [DESCRIPTION](#DESCRIPTION)

The [**io\_uring\_clone\_buffers**(3)](/man/os/liburing/io_uring_clone_buffers.3) function clones registered buffers from the ring indicated by *src* to the ring indicated by *dst*. Upon successful completion of this operation, *src* and *dst* will have the same set of registered buffers. This operation is identical to performing a [**io\_uring\_register\_buffers**(3)](/man/os/liburing/io_uring_register_buffers.3) operation on the *dst* ring, if the *src* ring previously had that same buffer registration operating done.

The *dst* ring must not have any buffers currently registered. If buffers are currently registered on the destination ring, they must be unregistered with [**io\_uring\_unregister\_buffers**(3)](/man/os/liburing/io_uring_unregister_buffers.3) first.

For [**\_\_io\_uring\_clone\_buffers**(3)](/man/os/liburing/__io_uring_clone_buffers.3)**,** the only difference is that it takes a *flags* argument. By default, if the destination ring has a registered file descriptor through [**io\_uring\_register\_ring\_fd**(3)](/man/os/liburing/io_uring_register_ring_fd.3) AND the calling application is not the thread that registered that ring, then the kernel doesn't know how to look up the destination. This is problematic as [**io\_uring\_clone\_buffers**(3)](/man/os/liburing/io_uring_clone_buffers.3) defaults to using the registered index if the destination is setup as such. Use [**\_\_io\_uring\_clone\_buffers**(3)](/man/os/liburing/__io_uring_clone_buffers.3) which doesn't set **IORING\_REGISTER\_SRC\_REGISTERED** by default. This requires the application to still have the original ring file descriptor open. See below for the flag definition.

Available since kernel 6.12.

The [**io\_uring\_clone\_buffers\_offset**(3)](/man/os/liburing/io_uring_clone_buffers_offset.3) function also clones buffers from the *src* ring to the *dst* ring, however it supports cloning only a subset of the buffers, where [**io\_uring\_clone\_buffers**(3)](/man/os/liburing/io_uring_clone_buffers.3) always clones all of them. *dst\_off* indicates at what offset cloning should start in the destination, *src\_off* indicates at what offset cloning should start in the source, and *nr* indicates how many buffers to clone at the given offset. If both *dst\_off*, *src\_off*, and *nr* are given as **0 ,** then [**io\_uring\_clone\_buffers\_offset**(3)](/man/os/liburing/io_uring_clone_buffers_offset.3) performs the same action as [**io\_uring\_clone\_buffers**(3)](/man/os/liburing/io_uring_clone_buffers.3)**.**

While [**io\_uring\_clone\_buffers\_offset**(3)](/man/os/liburing/io_uring_clone_buffers_offset.3) sets **IORING\_REGISTER\_SRC\_REGISTERED** by default, the [**\_\_io\_uring\_clone\_buffers\_offset**(3)](/man/os/liburing/__io_uring_clone_buffers_offset.3) does not. See the explanation for [**\_\_io\_uring\_clone\_buffers**(3)](/man/os/liburing/__io_uring_clone_buffers.3) for details.

*flags* may be set to the following value:

[**IORING\_REGISTER\_SRC\_REGISTERED**](#IORING_REGISTER_SRC_REGISTERED)

If the source ring is registered AND the calling thread is the one that originally registered its ring fd, then this flag may be set to lookup the registered index rather than use the normal file descriptor. If the normal file descriptor wasn't closed after registering it, there's no need to set this flag.

[**IORING\_REGISTER\_DST\_REPLACE**](#IORING_REGISTER_DST_REPLACE)

If set, cloning may happen for a destination ring that already has a buffer table assigned. In that case, existing nodes that overlap with the specified range will be released and replaced.

Available since kernel 6.13.

# [NOTES](#NOTES)

The source and target ring must shared address spaces, and hence internal kernel accounting.

# [RETURN VALUE](#RETURN_VALUE)

On success [**io\_uring\_clone\_buffers**(3)](/man/os/liburing/io_uring_clone_buffers.3) and [**io\_uring\_clone\_buffers\_offset**(3)](/man/os/liburing/io_uring_clone_buffers_offset.3) return 0. On failure, they returns **-errno**, specifically

[**-EBUSY**](#EBUSY)

The destination ring already has buffers registered, and **IORING\_REGISTER\_DST\_REPLACE** wasn't set.

[**-ENOMEM**](#ENOMEM)

The kernel ran out of memory.

[**-ENXIO**](#ENXIO)

The source ring doesn't have any buffers registered.

# [SEE ALSO](#SEE_ALSO)

[**io\_uring\_register**(2)](/man/os/liburing/io_uring_register.2), [**io\_uring\_unregister\_buffers**(3)](/man/os/liburing/io_uring_unregister_buffers.3), [**io\_uring\_register\_buffers**(3)](/man/os/liburing/io_uring_register_buffers.3), [**io\_uring\_prep\_read\_fixed**(3)](/man/os/liburing/io_uring_prep_read_fixed.3), [**io\_uring\_prep\_write\_fixed**(3)](/man/os/liburing/io_uring_prep_write_fixed.3)

September 12, 2024 liburing-2.9

---

Document: io_uring_clone_buffers(3) from liburing 2.15-r5 (Chainguard OS)
Source: https://github.com/axboe/liburing.git
