Skip to main content

io_uring_clone_buffers

Struct io_uring_clone_buffers 

Source
#[repr(C)]
pub struct io_uring_clone_buffers { pub src_fd: __u32, pub flags: __u32, pub src_off: __u32, pub dst_off: __u32, pub nr: __u32, pub pad: [__u32; 3], }
Expand description

Clones registered buffers between rings

§DESCRIPTION

The io_uring_clone_buffers() 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 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 first.

For __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 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() defaults to using the registered index if the destination is setup as such. Use __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 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() 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 performs the same action as io_uring_clone_buffers().

While io_uring_clone_buffers_offset sets IORING_REGISTER_SRC_REGISTERED by default, the __io_uring_clone_buffers_offset(3) does not. See the explanation for __io_uring_clone_buffers(3) for details.

flags may be set to the following value:

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

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

§RETURN VALUE

On success io_uring_clone_buffers() and io_uring_clone_buffers_offset return 0. On failure, they returns -errno, specifically

-EBUSY
The destination ring already has buffers registered, and IORING_REGISTER_DST_REPLACE wasn’t set.

-ENOMEM
The kernel ran out of memory.

-ENXIO
The source ring doesn’t have any buffers registered.

§SEE ALSO

io_uring_register, io_uring_unregister_buffers, io_uring_register_buffers, io_uring_prep_read_fixed, io_uring_prep_write_fixed

Fields§

§src_fd: __u32§flags: __u32§src_off: __u32§dst_off: __u32§nr: __u32§pad: [__u32; 3]

Trait Implementations§

Source§

impl Clone for io_uring_clone_buffers

Source§

fn clone(&self) -> io_uring_clone_buffers

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for io_uring_clone_buffers

Source§

impl Debug for io_uring_clone_buffers

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for io_uring_clone_buffers

Source§

fn default() -> io_uring_clone_buffers

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.