Struct io_uring::Submitter

source ·
pub struct Submitter<'a> { /* private fields */ }
Expand description

Interface for submitting submission queue events in an io_uring instance to the kernel for executing and registering files or buffers with the instance.

io_uring supports both directly performing I/O on buffers and file descriptors and registering them beforehand. Registering is slow, but it makes performing the actual I/O much faster.

Implementations§

source§

impl<'a> Submitter<'a>

source

pub unsafe fn enter<T: Sized>( &self, to_submit: u32, min_complete: u32, flag: u32, arg: Option<&T> ) -> Result<usize>

Initiate and/or complete asynchronous I/O. This is a low-level wrapper around io_uring_enter - see man io_uring_enter (or its online version for more details.

You will probably want to use a more high-level API such as submit or submit_and_wait.

Safety

This provides a raw interface so developer must ensure that parameters are correct.

source

pub fn submit(&self) -> Result<usize>

Submit all queued submission queue events to the kernel.

source

pub fn submit_and_wait(&self, want: usize) -> Result<usize>

Submit all queued submission queue events to the kernel and wait for at least want completion events to complete.

source

pub fn submit_with_args( &self, want: usize, args: &SubmitArgs<'_, '_> ) -> Result<usize>

source

pub fn squeue_wait(&self) -> Result<usize>

Wait for the submission queue to have free entries.

source

pub fn register_buffers(&self, bufs: &[iovec]) -> Result<()>

Register in-memory user buffers for I/O with the kernel. You can use these buffers with the ReadFixed and WriteFixed operations.

source

pub fn register_files_sparse(&self, nr: u32) -> Result<()>

Registers an empty file table of nr_files number of file descriptors. The sparse variant is available in kernels 5.19 and later.

Registering a file table is a prerequisite for using any request that uses direct descriptors.

source

pub fn register_files(&self, fds: &[RawFd]) -> Result<()>

Register files for I/O. You can use the registered files with Fixed.

Each fd may be -1, in which case it is considered “sparse”, and can be filled in later with register_files_update.

Note that this will wait for the ring to idle; it will only return once all active requests are complete. Use register_files_update to avoid this.

source

pub fn register_files_update(&self, offset: u32, fds: &[RawFd]) -> Result<usize>

This operation replaces existing files in the registered file set with new ones, either turning a sparse entry (one where fd is equal to -1) into a real one, removing an existing entry (new one is set to -1), or replacing an existing entry with a new existing entry. The offset parameter specifies the offset into the list of registered files at which to start updating files.

You can also perform this asynchronously with the FilesUpdate opcode.

source

pub fn register_eventfd(&self, eventfd: RawFd) -> Result<()>

Register an eventfd created by eventfd with the io_uring instance.

source

pub fn register_eventfd_async(&self, eventfd: RawFd) -> Result<()>

This works just like register_eventfd, except notifications are only posted for events that complete in an async manner, so requests that complete immediately will not cause a notification.

source

pub fn register_probe(&self, probe: &mut Probe) -> Result<()>

Fill in the given Probe with information about the opcodes supported by io_uring on the running kernel.

Examples
let io_uring = io_uring::IoUring::new(1)?;
let mut probe = io_uring::Probe::new();
io_uring.submitter().register_probe(&mut probe)?;

if probe.is_supported(io_uring::opcode::Read::CODE) {
    println!("Reading is supported!");
}
source

pub fn register_personality(&self) -> Result<u16>

Register credentials of the running application with io_uring, and get an id associated with these credentials. This ID can then be passed into submission queue entries to issue the request with this process’ credentials.

By default, if Parameters::is_feature_cur_personality is set then requests will use the credentials of the task that called Submitter::enter, otherwise they will use the credentials of the task that originally registered the io_uring.

source

pub fn unregister_buffers(&self) -> Result<()>

Unregister all previously registered buffers.

You do not need to explicitly call this before dropping the IoUring, as it will be cleaned up by the kernel automatically.

source

pub fn unregister_files(&self) -> Result<()>

Unregister all previously registered files.

You do not need to explicitly call this before dropping the IoUring, as it will be cleaned up by the kernel automatically.

source

pub fn unregister_eventfd(&self) -> Result<()>

Unregister an eventfd file descriptor to stop notifications.

source

pub fn unregister_personality(&self, personality: u16) -> Result<()>

Unregister a previously registered personality.

source

pub fn register_restrictions(&self, res: &mut [Restriction]) -> Result<()>

Permanently install a feature allowlist. Once this has been called, attempting to perform an operation not on the allowlist will fail with -EACCES.

This can only be called once, to prevent untrusted code from removing restrictions.

source

pub fn register_enable_rings(&self) -> Result<()>

Enable the rings of the io_uring instance if they have been disabled with setup_r_disabled.

source

pub fn register_iowq_max_workers(&self, max: &mut [u32; 2]) -> Result<()>

Get and/or set the limit for number of io_uring worker threads per NUMA node. max[0] holds the limit for bounded workers, which process I/O operations expected to be bound in time, that is I/O on regular files or block devices. While max[1] holds the limit for unbounded workers, which carry out I/O operations that can never complete, for instance I/O on sockets. Passing 0 does not change the current limit. Returns previous limits on success.

source

pub fn register_buf_ring( &self, ring_addr: u64, ring_entries: u16, bgid: u16 ) -> Result<()>

Register buffer ring for provided buffers.

Details can be found in the io_uring_register_buf_ring.3 man page.

If the register command is not supported, or the ring_entries value exceeds 32768, the InvalidInput error is returned.

Available since 5.19.

source

pub fn unregister_buf_ring(&self, bgid: u16) -> Result<()>

Unregister a previously registered buffer ring.

Available since 5.19.

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for Submitter<'a>

§

impl<'a> !Send for Submitter<'a>

§

impl<'a> !Sync for Submitter<'a>

§

impl<'a> Unpin for Submitter<'a>

§

impl<'a> UnwindSafe for Submitter<'a>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.