---
name: "io_uring_enter"
section: "2"
platform: "linux"
package: "liburing"
version: "2.15-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/io_uring_enter"
---

# io\_uring\_enter(2)

initiate and/or complete asynchronous I/O

## NAME

io\_uring\_enter - initiate and/or complete asynchronous I/O

## SYNOPSIS

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

**int io\_uring\_enter(unsigned int** *fd***, unsigned int** *to\_submit***,**                    **unsigned int** *min\_complete***, unsigned int** *flags***,**                    **sigset\_t \****sig***);**

**int io\_uring\_enter2(unsigned int** *fd***, unsigned int** *to\_submit***,**                     **unsigned int** *min\_complete***, unsigned int** *flags***,**                     **void \****arg***, size\_t** *sz***);**

## DESCRIPTION

[**io\_uring\_enter**(2)](/io_uring_enter/2.md) is used to initiate and complete I/O using the shared submission and completion queues setup by a call to [**io\_uring\_setup**(2)](/io_uring_setup/2.md). A single call can both submit new I/O and wait for completions of I/O initiated by this call or previous calls to [**io\_uring\_enter**(2)](/io_uring_enter/2.md).

*fd* is the file descriptor returned by [**io\_uring\_setup**(2)](/io_uring_setup/2.md). *to\_submit* specifies the number of I/Os to submit from the submission queue. *flags* is a bitmask of the following values:

- **IORING\_ENTER\_GETEVENTS**

  If this flag is set, then the system call will wait for the specified number of events in *min\_complete* before returning. This flag can be set along with *to\_submit* to both submit and complete events in a single system call. If this flag is set either the flag **IORING\_SETUP\_DEFER\_TASKRUN** must not be set or the thread issuing the syscall must be the thread that created the io\_uring associated with *fd,* or be the thread that enabled the ring originally created with **IORING\_SETUP\_R\_DISABLED** via [**io\_uring\_register**(2)](/io_uring_register/2.md) or [**io\_uring\_enable\_rings**(3)](/io_uring_enable_rings/3.md).

- **IORING\_ENTER\_SQ\_WAKEUP**

  If the ring has been created with **IORING\_SETUP\_SQPOLL,** then this flag asks the kernel to wakeup the SQ kernel thread to submit IO.

- **IORING\_ENTER\_SQ\_WAIT**

  If the ring has been created with **IORING\_SETUP\_SQPOLL,** then the application has no real insight into when the SQ kernel thread has consumed entries from the SQ ring. This can lead to a situation where the application can no longer get a free SQE entry to submit, without knowing when one will become available as the SQ kernel thread consumes them. If the system call is used with this flag set, then it will wait until at least one entry is free in the SQ ring.

- **IORING\_ENTER\_EXT\_ARG**

  By default, *arg* is a *sigset\_t* pointer. If **IORING\_ENTER\_EXT\_ARG** is set (supported since kernel 5.11), then *arg* is instead a pointer to a *struct io\_uring\_getevents\_arg* and *argsz* must be set to the size of this structure. The definition is as follows:

  ```
  struct io_uring_getevents_arg {
          __u64   sigmask;
          __u32   sigmask_sz;
          __u32   pad;
          __u64   ts;
  };
  ```

  which allows passing in both a signal mask as well as pointer to a *struct \_\_kernel\_timespec* timeout value. If *ts* is set to a valid pointer, then this time value indicates the timeout for waiting on events. If an application is waiting on events and wishes to stop waiting after a specified amount of time, then this can be accomplished directly in version 5.11 and newer by using this feature.

- **IORING\_ENTER\_REGISTERED\_RING**

  If the ring file descriptor has been registered through use of **IORING\_REGISTER\_RING\_FDS**, then setting this flag will tell the kernel that the *ring\_fd* passed in is the registered ring offset rather than a normal file descriptor.

- **IORING\_ENTER\_ABS\_TIMER**

  When this flag is set, the timeout argument passed in *struct io\_uring\_getevents\_arg* will be interpreted as an absolute time of the registered clock (see **IORING\_REGISTER\_CLOCK)** until which the waiting should end.

  Available since 6.12

- **IORING\_ENTER\_EXT\_ARG\_REG**

  When this flag is set, *arg* is not a pointer to a *struct*io\_uring\_getevents\_arg*,* but merely an offset into an area of wait regions previously registered with [**io\_uring\_register**(2)](/io_uring_register/2.md) using the **IORING\_REGISTER\_MEM\_REGION** operation.

  Available since 6.13

- **IORING\_ENTER\_NO\_IOWAIT**

  When this flag is set, the system call will not mark the waiting task as being in iowait if it is sleeping waiting on events and there are pending requests. This is useful if iowait isn't expected when waiting for events. It can also prevent extra power usage by allowing the CPU to enter lower sleep states. This flag is only available if the kernel supports the **IORING\_FEAT\_NO\_IOWAIT** feature.

  Available since 6.15.

If the io\_uring instance was configured for polling, by specifying **IORING\_SETUP\_IOPOLL** in the call to [**io\_uring\_setup**(2)](/io_uring_setup/2.md), then min\_complete has a slightly different meaning.  Passing a value of 0 instructs the kernel to return any events which are already complete, without blocking.  If *min\_complete* is a non-zero value, the kernel will still return immediately if any completion events are available.  If no event completions are available, then the call will poll either until one or more completions become available, or until the process has exceeded its scheduler time slice.

Note that, for interrupt driven I/O (where **IORING\_SETUP\_IOPOLL** was not specified in the call to [**io\_uring\_setup**(2)](/io_uring_setup/2.md)), an application may check the completion queue for event completions without entering the kernel at all.

When the system call returns that a certain amount of SQEs have been consumed and submitted, it's safe to reuse SQE entries in the ring. This is true even if the actual IO submission had to be punted to async context, which means that the SQE may in fact not have been submitted yet. If the kernel requires later use of a particular SQE entry, it will have made a private copy of it.

*sig* is a pointer to a signal mask (see [**sigprocmask**(2)](/sigprocmask/2.md)); if *sig* is not NULL, [**io\_uring\_enter**(2)](/io_uring_enter/2.md) first replaces the current signal mask by the one pointed to by *sig*, then waits for events to become available in the completion queue, and then restores the original signal mask.  The following [**io\_uring\_enter**(2)](/io_uring_enter/2.md) call:

```
ret = io_uring_enter(fd, 0, 1, IORING_ENTER_GETEVENTS, &sig);
```

is equivalent to *atomically* executing the following calls:

```
pthread_sigmask(SIG_SETMASK, &sig, &orig);
ret = io_uring_enter(fd, 0, 1, IORING_ENTER_GETEVENTS, NULL);
pthread_sigmask(SIG_SETMASK, &orig, NULL);
```

See the description of [**pselect**(2)](/pselect/2.md) for an explanation of why the *sig* parameter is necessary.

Submission queue entries are represented using the following data structure:

```
/*
 * IO submission data structure (Submission Queue Entry)
 */
struct io_uring_sqe {
	__u8	opcode;		/* type of operation for this sqe */
	__u8	flags;		/* IOSQE_ flags */
	__u16	ioprio;		/* ioprio for the request */
	__s32	fd;		/* file descriptor to do IO on */
	union {
		__u64	off;	/* offset into file */
		__u64	addr2;
		struct {
			__u32	cmd_op;
			__u32	__pad1;
		};
	};
	union {
		__u64	addr;	/* pointer to buffer or iovecs */
		__u64	splice_off_in;
		struct {
			__u32	level;
			__u32	optname;
		};
	};
	__u32	len;		/* buffer size or number of iovecs */
	union {
		__kernel_rwf_t	rw_flags;
		__u32		fsync_flags;
		__u16		poll_events;	/* compatibility */
		__u32		poll32_events;	/* word-reversed for BE */
		__u32		sync_range_flags;
		__u32		msg_flags;
		__u32		timeout_flags;
		__u32		accept_flags;
		__u32		cancel_flags;
		__u32		open_flags;
		__u32		statx_flags;
		__u32		fadvise_advice;
		__u32		splice_flags;
		__u32		rename_flags;
		__u32		unlink_flags;
		__u32		hardlink_flags;
		__u32		xattr_flags;
		__u32		msg_ring_flags;
		__u32		uring_cmd_flags;
		__u32		waitid_flags;
		__u32		futex_flags;
		__u32		install_fd_flags;
		__u32		nop_flags;
	};
	__u64	user_data;	/* data to be passed back at completion time */
	/* pack this to avoid bogus arm OABI complaints */
	union {
		/* index into fixed buffers, if used */
		__u16	buf_index;
		/* for grouped buffer selection */
		__u16	buf_group;
	} __attribute__((packed));
	/* personality to use, if used */
	__u16	personality;
	union {
		__s32	splice_fd_in;
		__u32	file_index;
		__u32	optlen;
		struct {
			__u16	addr_len;
			__u16	__pad3[1];
		};
	};
	union {
		struct {
			__u64	addr3;
			__u64	__pad2[1];
		};
		__u64	optval;
		/*
		 * If the ring is initialized with IORING_SETUP_SQE128, then
		 * this field is used for 80 bytes of arbitrary command data
		 */
		__u8	cmd[0];
	};
};
```

The *opcode* describes the operation to be performed.  It can be one of:

- **IORING\_OP\_NOP**

  Do not perform any I/O.  This is useful for testing the performance of the io\_uring implementation itself.

- **IORING\_OP\_READV**

  - **IORING\_OP\_WRITEV**

  Vectored read and write operations, similar to [**preadv2**(2)](/preadv2/2.md) and [**pwritev2**(2)](/pwritev2/2.md). If the file is not seekable, *off* must be set to zero or -1.

- **IORING\_OP\_READ\_FIXED**

  - **IORING\_OP\_WRITE\_FIXED**

  Read from or write to pre-mapped buffers.  See [**io\_uring\_register**(2)](/io_uring_register/2.md) for details on how to setup a context for fixed reads and writes.

- **IORING\_OP\_FSYNC**

  File sync.  See also [**fsync**(2)](/fsync/2.md). Optionally *off* and *len* can be used to specify a range within the file to be synced rather than syncing the entire file, which is the default behavior. Note that, while I/O is initiated in the order in which it appears in the submission queue, completions are unordered.  For example, an application which places a write I/O followed by an fsync in the submission queue cannot expect the fsync to apply to the write.  The two operations execute in parallel, so the fsync may complete before the write is issued to the storage.  The same is also true for previously issued writes that have not completed prior to the fsync. To enforce ordering one may utilize linked SQEs, **IOSQE\_IO\_DRAIN** or wait for the arrival of CQEs of requests which have to be ordered before a given request before submitting its SQE.

- **IORING\_OP\_POLL\_ADD**

  Poll the *fd* specified in the submission queue entry for the events specified in the *poll\_events* field.  Unlike poll or epoll without **EPOLLONESHOT**, by default this interface always works in one shot mode.  That is, once the poll operation is completed, it will have to be resubmitted.

  If **IORING\_POLL\_ADD\_MULTI** is set in the SQE *len* field, then the poll will work in multi shot mode instead. That means it'll repatedly trigger when the requested event becomes true, and hence multiple CQEs can be generated from this single SQE. The CQE *flags* field will have **IORING\_CQE\_F\_MORE** set on completion if the application should expect further CQE entries from the original request. If this flag isn't set on completion, then the poll request has been terminated and no further events will be generated. This mode is available since 5.13.

  This command works like an async **[poll(2)](/poll/2.md)** and the completion event result is the returned mask of events.

  Without **IORING\_POLL\_ADD\_MULTI** and the initial poll operation with **IORING\_POLL\_ADD\_MULTI** the operation is level triggered, i.e. if there is data ready or events pending etc. at the time of submission a corresponding CQE will be posted. Potential further completions beyond the first caused by a **IORING\_POLL\_ADD\_MULTI** are edge triggered.

- **IORING\_OP\_POLL\_REMOVE**

  Remove or update an existing poll request.  If found, the *res* field of the *struct io\_uring\_cqe* will contain 0.  If not found, *res* will contain **-ENOENT,** or **-EALREADY** if the poll request was in the process of completing already.

  If **IORING\_POLL\_UPDATE\_EVENTS** is set in the SQE *len* field, then the request will update an existing poll request with the mask of events passed in with this request. The lookup is based on the *user\_data* field of the original SQE submitted, and this values is passed in the *addr* field of the SQE. If **IORING\_POLL\_UPDATE\_USER\_DATA** is set in the SQE *len* field, then the request will update the *user\_data* of an existing poll request based on the value passed in the *off* field. Updating an existing poll is available since 5.13.

- **IORING\_OP\_EPOLL\_CTL**

  Add, remove or modify entries in the interest list of [**epoll**(7)](/epoll/7.md). See [**epoll\_ctl**(2)](/epoll_ctl/2.md) for details of the system call. *fd* holds the file descriptor that represents the epoll instance, *off* holds the file descriptor to add, remove or modify, *len* holds the operation ( **EPOLL\_CTL\_ADD**, **EPOLL\_CTL\_DEL**, **EPOLL\_CTL\_MOD**) to perform and, *addr* holds a pointer to the *epoll\_event* structure. Available since 5.6.

- **IORING\_OP\_SYNC\_FILE\_RANGE**

  Issue the equivalent of a **sync\_file\_range** (2) on the file descriptor. The *fd* field is the file descriptor to sync, the *off* field holds the offset in bytes, the *len* field holds the length in bytes, and the *sync\_range\_flags* field holds the flags for the command. See also [**sync\_file\_range**(2)](/sync_file_range/2.md) for the general description of the related system call. Available since 5.2.

- **IORING\_OP\_SENDMSG**

  Issue the equivalent of a **[sendmsg(2)](/sendmsg/2.md)** system call. *fd* must be set to the socket file descriptor, *addr* must contain a pointer to the msghdr structure, and *msg\_flags* holds the flags associated with the system call. See also [**sendmsg**(2)](/sendmsg/2.md) for the general description of the related system call. Available since 5.3.

  This command also supports the following modifiers in *ioprio:*

**IORING\_RECVSEND\_POLL\_FIRST** If set, io\_uring will assume the socket is currently full and attempting to send data will be unsuccessful. For this case, io\_uring will arm internal poll and trigger a send of the data when there is enough space available. This initial send attempt can be wasteful for the case where the socket is expected to be full, setting this flag will bypass the initial send attempt and go straight to arming poll. If poll does indicate that data can be sent, the operation will proceed.

- **IORING\_OP\_RECVMSG**

  Works just like IORING\_OP\_SENDMSG, except for **[recvmsg(2)](/recvmsg/2.md)** instead. See the description of IORING\_OP\_SENDMSG. Available since 5.3.

  This command also supports the following modifiers in *ioprio:*

**IORING\_RECVSEND\_POLL\_FIRST** If set, io\_uring will assume the socket is currently empty and attempting to receive data will be unsuccessful. For this case, io\_uring will arm internal poll and trigger a receive of the data when the socket has data to be read. This initial receive attempt can be wasteful for the case where the socket is expected to be empty, setting this flag will bypass the initial receive attempt and go straight to arming poll. If poll does indicate that data is ready to be received, the operation will proceed.

- **IORING\_OP\_SEND**

  Issue the equivalent of a **[send(2)](/send/2.md)** system call. *fd* must be set to the socket file descriptor, *addr* must contain a pointer to the buffer, *len* denotes the length of the buffer to send, and *msg\_flags* holds the flags associated with the system call. See also **[send(2)](/send/2.md)** for the general description of the related system call. Available since 5.6.

  This command also supports the following modifiers in *ioprio:*

**IORING\_RECVSEND\_POLL\_FIRST** If set, io\_uring will assume the socket is currently full and attempting to send data will be unsuccessful. For this case, io\_uring will arm internal poll and trigger a send of the data when there is enough space available. This initial send attempt can be wasteful for the case where the socket is expected to be full, setting this flag will bypass the initial send attempt and go straight to arming poll. If poll does indicate that data can be sent, the operation will proceed.

- **IORING\_OP\_RECV**

  Works just like IORING\_OP\_SEND, except for **[recv(2)](/recv/2.md)** instead. See the description of IORING\_OP\_SEND. Available since 5.6.

  This command also supports the following modifiers in *ioprio:*

**IORING\_RECVSEND\_POLL\_FIRST** If set, io\_uring will assume the socket is currently empty and attempting to receive data will be unsuccessful. For this case, io\_uring will arm internal poll and trigger a receive of the data when the socket has data to be read. This initial receive attempt can be wasteful for the case where the socket is expected to be empty, setting this flag will bypass the initial receive attempt and go straight to arming poll. If poll does indicate that data is ready to be received, the operation will proceed.

- **IORING\_OP\_TIMEOUT**

  This command will register a timeout operation. The *addr* field must contain a pointer to a struct \_\_kernel\_timespec structure, *len* must contain 1 to signify one \_\_kernel\_timespec structure, *timeout\_flags* may contain **IORING\_TIMEOUT\_ABS** for an absolute timeout value, or 0 for a relative timeout. *off* may contain a completion event count. A timeout will trigger a wakeup event on the completion ring for anyone waiting for events. A timeout condition is met when either the specified timeout expires, or the specified number of events have completed. Either condition will trigger the event. If set to 0, completed events are not counted, which effectively acts like a timer. io\_uring timeouts use the **CLOCK\_MONOTONIC** as the default clock source. The request will complete with **-ETIME** if the timeout got completed through expiration of the timer, or *0* if the timeout got completed through requests completing on their own. If the timeout was canceled before it expired, the request will complete with **-ECANCELED.** Available since 5.4.

  Since 5.15, this command also supports the following modifiers in *timeout\_flags:*

**IORING\_TIMEOUT\_BOOTTIME** If set, then the clocksource used is **CLOCK\_BOOTTIME** instead of **CLOCK\_MONOTONIC**. This clocksource differs in that it includes time elapsed if the system was suspend while having a timeout request in-flight.

**IORING\_TIMEOUT\_REALTIME** If set, then the clocksource used is **CLOCK\_REALTIME** instead of **CLOCK\_MONOTONIC**.

Since 5.16, **IORING\_TIMEOUT\_ETIME\_SUCCESS** can be set in *timeout\_flags*, which will result in the expiration of the timer and subsequent completion with **-ETIME** not being interpreted as an error. This is mostly relevant for linked SQEs, as subsequent requests in the chain would not get canceled by the timeout, if this flag is set. See **IOSQE\_IO\_LINK** for more details on linked SQEs.

Since 6.4, **IORING\_TIMEOUT\_MULTISHOT** can be set in *timeout\_flags*, which will result in the timer producing multiple consecutive completions like other multi shot operations e.g. **IORING\_OP\_READ\_MULTISHOT** or **IORING\_POLL\_ADD\_MULTI**. *off* must be set to the amount of desired completions. **IORING\_TIMEOUT\_MULTISHOT** must not be used with **IORING\_TIMEOUT\_ABS**.

Since kernel 7.1, **IORING\_TIMEOUT\_IMMEDIATE\_ARG** can be set in *timeout\_flags*, which causes the *addr* field to be interpreted as a timeout value in nanoseconds rather than a pointer to a **struct \_\_kernel\_timespec.** This avoids the need to keep a timespec structure valid in user memory until the request is submitted.

- **IORING\_OP\_TIMEOUT\_REMOVE**

  If *timeout\_flags* are zero, then it attempts to remove an existing timeout operation. *addr* must contain the *user\_data* field of the previously issued timeout operation. If the specified timeout request is found and canceled successfully, this request will terminate with a result value of *0* If the timeout request was found but expiration was already in progress, this request will terminate with a result value of **-EBUSY** If the timeout request wasn't found, the request will terminate with a result value of **-ENOENT** Available since 5.5.

  If *timeout\_flags* contain **IORING\_TIMEOUT\_UPDATE**, instead of removing an existing operation, it updates it. *addr* and return values are same as before. *addr2* field must contain a pointer to a struct \_\_kernel\_timespec structure. *timeout\_flags* may also contain IORING\_TIMEOUT\_ABS, in which case the value given is an absolute one, not a relative one. Available since 5.11.

- **IORING\_OP\_ACCEPT**

  Issue the equivalent of an [**accept4**(2)](/accept4/2.md) system call. *fd* must be set to the socket file descriptor, *addr* must contain the pointer to the sockaddr structure, and *addr2* must contain a pointer to the socklen\_t addrlen field. Flags can be passed using the *accept\_flags* field. See also [**accept4**(2)](/accept4/2.md) for the general description of the related system call. Available since 5.5.

  If the *file\_index* field is set to a positive number, the file won't be installed into the normal file table as usual but will be placed into the fixed file table at index *file\_index* - 1. In this case, instead of returning a file descriptor, the result will contain either 0 on success or an error. If the index points to a valid empty slot, the installation is guaranteed to not fail. If there is already a file in the slot, it will be replaced, similar to **IORING\_OP\_FILES\_UPDATE.** Please note that only io\_uring has access to such files and no other syscall can use them. See **IOSQE\_FIXED\_FILE** and **IORING\_REGISTER\_FILES**.

  Available since 5.5.

- **IORING\_OP\_ASYNC\_CANCEL**

  Attempt to cancel an already issued request. *addr* must contain the *user\_data* field of the request that should be canceled. The cancelation request will complete with one of the following results codes. If found, the *res* field of the cqe will contain 0. If not found, *res* will contain **-ENOENT**. If found and attempted canceled, the *res* field will contain **-EALREADY**. In this case, the request may or may not terminate. In general, requests that are interruptible (like socket IO) will get canceled, while disk IO requests cannot be canceled if already started. Available since 5.5.

- **IORING\_OP\_LINK\_TIMEOUT**

  This request must be linked with another request through **IOSQE\_IO\_LINK** which is described below. Unlike **IORING\_OP\_TIMEOUT**, **IORING\_OP\_LINK\_TIMEOUT** acts on the linked request, not the completion queue. The format of the command is otherwise like **IORING\_OP\_TIMEOUT**, except there's no completion event count as it's tied to a specific request. If used, the timeout specified in the command will cancel the linked command, unless the linked command completes before the timeout. The timeout will complete with **-ETIME** if the timer expired and the linked request was attempted canceled, or **-ECANCELED** if the timer got canceled because of completion of the linked request. Like **IORING\_OP\_TIMEOUT** the clock source used is **CLOCK\_MONOTONIC** Available since 5.5.

- **IORING\_OP\_CONNECT**

  Issue the equivalent of a [**connect**(2)](/connect/2.md) system call. *fd* must be set to the socket file descriptor, *addr* must contain the const pointer to the sockaddr structure, and *off* must contain the socklen\_t addrlen field. See also [**connect**(2)](/connect/2.md) for the general description of the related system call. Available since 5.5.

- **IORING\_OP\_FALLOCATE**

  Issue the equivalent of a [**fallocate**(2)](/fallocate/2.md) system call. *fd* must be set to the file descriptor, *len* must contain the mode associated with the operation, *off* must contain the offset on which to operate, and *addr* must contain the length. See also [**fallocate**(2)](/fallocate/2.md) for the general description of the related system call. Available since 5.6.

- **IORING\_OP\_FADVISE**

  Issue the equivalent of a [**posix\_fadvise**(2)](/posix_fadvise/2.md) system call. *fd* must be set to the file descriptor, *off* must contain the offset on which to operate, *len* must contain the length, and *fadvise\_advice* must contain the advice associated with the operation. See also [**posix\_fadvise**(2)](/posix_fadvise/2.md) for the general description of the related system call. Available since 5.6.

- **IORING\_OP\_MADVISE**

  Issue the equivalent of a [**madvise**(2)](/madvise/2.md) system call. *addr* must contain the address to operate on, *len* must contain the length on which to operate, and *fadvise\_advice* must contain the advice associated with the operation. See also [**madvise**(2)](/madvise/2.md) for the general description of the related system call. Available since 5.6.

- **IORING\_OP\_OPENAT**

  Issue the equivalent of a [**openat**(2)](/openat/2.md) system call. *fd* is the *dirfd* argument, *addr* must contain a pointer to the *\*pathname* argument, *open\_flags* should contain any flags passed in, and *len* is access mode of the file. See also [**openat**(2)](/openat/2.md) for the general description of the related system call. Available since 5.6.

  If the *file\_index* field is set to a positive number, the file won't be installed into the normal file table as usual but will be placed into the fixed file table at index *file\_index - 1.* In this case, instead of returning a file descriptor, the result will contain either 0 on success or an error. If the index points to a valid empty slot, the installation is guaranteed to not fail. If there is already a file in the slot, it will be replaced, similar to **IORING\_OP\_FILES\_UPDATE.** Please note that only io\_uring has access to such files and no other syscall can use them. See **IOSQE\_FIXED\_FILE** and **IORING\_REGISTER\_FILES**.

  Available since 5.15.

- **IORING\_OP\_OPENAT2**

  Issue the equivalent of a [**openat2**(2)](/openat2/2.md) system call. *fd* is the *dirfd* argument, *addr* must contain a pointer to the *\*pathname* argument, *len* should contain the size of the open\_how structure, and *off* should be set to the address of the open\_how structure. See also [**openat2**(2)](/openat2/2.md) for the general description of the related system call. Available since 5.6.

  If the *file\_index* field is set to a positive number, the file won't be installed into the normal file table as usual but will be placed into the fixed file table at index *file\_index - 1.* In this case, instead of returning a file descriptor, the result will contain either 0 on success or an error. If the index points to a valid empty slot, the installation is guaranteed to not fail. If there is already a file in the slot, it will be replaced, similar to **IORING\_OP\_FILES\_UPDATE**. Please note that only io\_uring has access to such files and no other syscall can use them. See **IOSQE\_FIXED\_FILE** and **IORING\_REGISTER\_FILES**.

  Available since 5.15.

- **IORING\_OP\_CLOSE**

  Issue the equivalent of a [**close**(2)](/close/2.md) system call. *fd* is the file descriptor to be closed. See also [**close**(2)](/close/2.md) for the general description of the related system call. Available since 5.6. If the *file\_index* field is set to a positive number, this command can be used to close files that were direct opened through **IORING\_OP\_OPENAT**, **IORING\_OP\_OPENAT2**, or **IORING\_OP\_ACCEPT** using the io\_uring specific direct descriptors. Note that only one of the descriptor fields may be set. The direct close feature is available since the 5.15 kernel, where direct descriptors were introduced.

- **IORING\_OP\_STATX**

  Issue the equivalent of a [**statx**(2)](/statx/2.md) system call. *fd* is the *dirfd* argument, *addr* must contain a pointer to the *\*pathname* string, *statx\_flags* is the *flags* argument, *len* should be the *mask* argument, and *off* must contain a pointer to the *statxbuf* to be filled in. See also [**statx**(2)](/statx/2.md) for the general description of the related system call. Available since 5.6.

- **IORING\_OP\_READ**

  - **IORING\_OP\_WRITE**

  Issue the equivalent of a [**pread**(2)](/pread/2.md) or [**pwrite**(2)](/pwrite/2.md) system call. *fd* is the file descriptor to be operated on, *addr* contains the buffer in question, *len* contains the length of the IO operation, and *offs* contains the read or write offset. If *fd* does not refer to a seekable file, *off* must be set to zero or -1. If *offs* is set to **-1** , the offset will use (and advance) the file position, like the [**read**(2)](/read/2.md) and [**write**(2)](/write/2.md) system calls. These are non-vectored versions of the **IORING\_OP\_READV** and **IORING\_OP\_WRITEV** opcodes. See also [**read**(2)](/read/2.md) and [**write**(2)](/write/2.md) for the general description of the related system call. Available since 5.6.

- **IORING\_OP\_SPLICE**

  Issue the equivalent of a [**splice**(2)](/splice/2.md) system call. *splice\_fd\_in* is the file descriptor to read from, *splice\_off\_in* is an offset to read from, *fd* is the file descriptor to write to, *off* is an offset from which to start writing to. A sentinel value of **-1** is used to pass the equivalent of a NULL for the offsets to [**splice**(2)](/splice/2.md). *len* contains the number of bytes to copy. *splice\_flags* contains a bit mask for the flag field associated with the system call. Please note that one of the file descriptors must refer to a pipe. See also [**splice**(2)](/splice/2.md) for the general description of the related system call. Available since 5.7.

- **IORING\_OP\_TEE**

  Issue the equivalent of a [**tee**(2)](/tee/2.md) system call. *splice\_fd\_in* is the file descriptor to read from, *fd* is the file descriptor to write to, *len* contains the number of bytes to copy, and *splice\_flags* contains a bit mask for the flag field associated with the system call. Please note that both of the file descriptors must refer to a pipe. See also [**tee**(2)](/tee/2.md) for the general description of the related system call. Available since 5.8.

- **IORING\_OP\_FILES\_UPDATE**

  This command is an alternative to using **IORING\_REGISTER\_FILES\_UPDATE** which then works in an async fashion, like the rest of the io\_uring commands. The arguments passed in are the same. *addr* must contain a pointer to the array of file descriptors, *len* must contain the length of the array, and *off* must contain the offset at which to operate. Note that the array of file descriptors pointed to in *addr* must remain valid until this operation has completed. Available since 5.6.

- **IORING\_OP\_PROVIDE\_BUFFERS**

  This command allows an application to register a group of buffers to be used by commands that read/receive data. Using buffers in this manner can eliminate the need to separate the poll + read, which provides a convenient point in time to allocate a buffer for a given request. It's often infeasible to have as many buffers available as pending reads or receive. With this feature, the application can have its pool of buffers ready in the kernel, and when the file or socket is ready to read/receive data, a buffer can be selected for the operation. *fd* must contain the number of buffers to provide, *addr* must contain the starting address to add buffers from, *len* must contain the length of each buffer to add from the range, *buf\_group* must contain the group ID of this range of buffers, and *off* must contain the starting buffer ID of this range of buffers. With that set, the kernel adds buffers starting with the memory address in *addr,* each with a length of *len.* Hence the application should provide *len \* fd* worth of memory in *addr.* Buffers are grouped by the group ID, and each buffer within this group will be identical in size according to the above arguments. This allows the application to provide different groups of buffers, and this is often used to have differently sized buffers available depending on what the expectations are of the individual request. When submitting a request that should use a provided buffer, the **IOSQE\_BUFFER\_SELECT** flag must be set, and *buf\_group* must be set to the desired buffer group ID where the buffer should be selected from. Available since 5.7.

- **IORING\_OP\_REMOVE\_BUFFERS**

  Remove buffers previously registered with **IORING\_OP\_PROVIDE\_BUFFERS**. *fd* must contain the number of buffers to remove, and *buf\_group* must contain the buffer group ID from which to remove the buffers. Available since 5.7.

- **IORING\_OP\_SHUTDOWN**

  Issue the equivalent of a [**shutdown**(2)](/shutdown/2.md) system call. *fd* is the file descriptor to the socket being shutdown, and *len* must be set to the *how* argument. No no other fields should be set. Available since 5.11.

- **IORING\_OP\_RENAMEAT**

  Issue the equivalent of a [**renameat2**(2)](/renameat2/2.md) system call. *fd* should be set to the *olddirfd*, *addr* should be set to the *oldpath*, *len* should be set to the *newdirfd*, *addr* should be set to the *oldpath*, *addr2* should be set to the *newpath*, and finally *rename\_flags* should be set to the *flags* passed in to [**renameat2**(2)](/renameat2/2.md). Available since 5.11.

- **IORING\_OP\_UNLINKAT**

  Issue the equivalent of a [**unlinkat**(2)](/unlinkat/2.md) system call. *fd* should be set to the *dirfd*, *addr* should be set to the *pathname*, and *unlink\_flags* should be set to the *flags* being passed in to [**unlinkat**(2)](/unlinkat/2.md). Available since 5.11.

- **IORING\_OP\_MKDIRAT**

  Issue the equivalent of a [**mkdirat**(2)](/mkdirat/2.md) system call. *fd* should be set to the *dirfd*, *addr* should be set to the *pathname*, and *len* should be set to the *mode* being passed in to [**mkdirat**(2)](/mkdirat/2.md). Available since 5.15.

- **IORING\_OP\_SYMLINKAT**

  Issue the equivalent of a [**symlinkat**(2)](/symlinkat/2.md) system call. *fd* should be set to the *newdirfd*, *addr* should be set to the *target* and *addr2* should be set to the *linkpath* being passed in to [**symlinkat**(2)](/symlinkat/2.md). Available since 5.15.

- **IORING\_OP\_LINKAT**

  Issue the equivalent of a [**linkat**(2)](/linkat/2.md) system call. *fd* should be set to the *olddirfd*, *addr* should be set to the *oldpath*, *len* should be set to the *newdirfd*, *addr2* should be set to the *newpath*, and *hardlink\_flags* should be set to the *flags* being passed in to [**linkat**(2)](/linkat/2.md). Available since 5.15.

- **IORING\_OP\_MSG\_RING**

  Send a message to an io\_uring. *fd* must be set to a file descriptor of a ring that the application has access to, *len* can be set to any 32-bit value that the application wishes to pass on, and *off* should be set any 64-bit value that the application wishes to send. On the target ring, a CQE will be posted with the *res* field matching the *len* set, and a *user\_data* field matching the *off* value being passed in. This request type can be used to either just wake or interrupt anyone waiting for completions on the target ring, or it can be used to pass messages via the two fields. Available since 5.18.

- **IORING\_OP\_SOCKET**

  Issue the equivalent of a [**socket**(2)](/socket/2.md) system call. *fd* must contain the communication domain, *off* must contain the communication type, *len* must contain the protocol, and *rw\_flags* is currently unused and must be set to zero. See also [**socket**(2)](/socket/2.md) for the general description of the related system call. Available since 5.19.

  If the *file\_index* field is set to a positive number, the file won't be installed into the normal file table as usual but will be placed into the fixed file table at index *file\_index* - 1. In this case, instead of returning a file descriptor, the result will contain either 0 on success or an error. If the index points to a valid empty slot, the installation is guaranteed to not fail. If there is already a file in the slot, it will be replaced, similar to **IORING\_OP\_FILES\_UPDATE**. Please note that only io\_uring has access to such files and no other syscall can use them. See **IOSQE\_FIXED\_FILE** and **IORING\_REGISTER\_FILES**.

  Available since 5.19.

- **IORING\_OP\_URING\_CMD**

  Issues an asynchronous, per-file private operation, similar to [**ioctl**(2)](/ioctl/2.md). Further information may be found in the dedicated man page of **IORING\_OP\_URING\_CMD**.

  Available since 5.19.

- **IORING\_OP\_SEND\_ZC**

  Issue the zerocopy equivalent of a **[send(2)](/send/2.md)** system call. Similar to **IORING\_OP\_SEND**, but tries to avoid making intermediate copies of data. Zerocopy execution is not guaranteed and may fall back to copying. The request may also fail with **-EOPNOTSUPP**, when a protocol doesn't support zerocopy, in which case users are recommended to use copying sends instead.

  The *flags* field of the first *struct io\_uring\_cqe* may likely contain **IORING\_CQE\_F\_MORE**, which means that there will be a second completion event / notification for the request, with the *user\_data* field set to the same value. The user must not modify the data buffer until the notification is posted. The first cqe follows the usual rules and so its *res* field will contain the number of bytes sent or a negative error code. The notification's *res* field will be set to zero and the *flags* field will contain **IORING\_CQE\_F\_NOTIF**. The two step model is needed because the kernel may hold on to buffers for a long time, e.g. waiting for a TCP ACK, and having a separate cqe for request completions allows userspace to push more data without extra delays. Note, notifications are only responsible for controlling the lifetime of the buffers, and as such don't mean anything about whether the data has atually been sent out or received by the other end. Even errored requests may generate a notification, and the user must check for **IORING\_CQE\_F\_MORE** rather than relying on the result.

  *fd* must be set to the socket file descriptor, *addr* must contain a pointer to the buffer, *len* denotes the length of the buffer to send, and *msg\_flags* holds the flags associated with the system call. When *addr2* is non-zero it points to the address of the target with *addr\_len* specifying its size, turning the request into a [**sendto**(2)](/sendto/2.md) system call equivalent.

  Available since 6.0.

  This command also supports the following modifiers in *ioprio:*

**IORING\_RECVSEND\_POLL\_FIRST** If set, io\_uring will assume the socket is currently full and attempting to send data will be unsuccessful. For this case, io\_uring will arm internal poll and trigger a send of the data when there is enough space available. This initial send attempt can be wasteful for the case where the socket is expected to be full, setting this flag will bypass the initial send attempt and go straight to arming poll. If poll does indicate that data can be sent, the operation will proceed.

**IORING\_RECVSEND\_FIXED\_BUF** If set, instructs io\_uring to use a pre-mapped buffer. The *buf\_index* field should contain an index into an array of fixed buffers. See [**io\_uring\_register**(2)](/io_uring_register/2.md) for details on how to setup a context for fixed buffer I/O.

- **IORING\_OP\_SENDMSG\_ZC**

  Issue the zerocopy equivalent of a [**sendmsg**(2)](/sendmsg/2.md) system call. Works just like **IORING\_OP\_SENDMSG**, but like **IORING\_OP\_SEND\_ZC** supports **IORING\_RECVSEND\_FIXED\_BUF**. For additional notes regarding zero copy see **IORING\_OP\_SEND\_ZC**.

  Available since 6.1

- **IORING\_OP\_WAITID**

  Issue the equivalent of a [**waitid**(2)](/waitid/2.md) system call. *len* must contain the idtype being queried/waited for and *fd* must contain the 'pid' (or id) being waited for. *file\_index* is the 'options' being set (the child state changes to wait for). *addr2* is a pointer to siginfo\_t, if any, being filled in. See also [**waitid**(2)](/waitid/2.md) for the general description of the related system call. Available since 6.5.

- **IORING\_OP\_SETXATTR**

  - **IORING\_OP\_GETXATTR**

  - **IORING\_OP\_FSETXATTR**

  - **IORING\_OP\_FGETXATTR**

  Issue the equivalent of a [**setxattr**(2)](/setxattr/2.md) or [**getxattr**(2)](/getxattr/2.md) or [**fsetxattr**(2)](/fsetxattr/2.md) or [**fgetxattr**(2)](/fgetxattr/2.md) system call. *addr* must contain a pointer to a buffer containing the name of the extended attribute. *addr2* must contain a pointer to a buffer of maximum length *len*, in which the value of the extended attribute is to be placed or is read from. Additional flags maybe provided in *xattr\_flags*. For [**setxattr**(2)](/setxattr/2.md) or [**getxattr**(2)](/getxattr/2.md) *addr3* must contain a pointer to the path of the file. For [**fsetxattr**(2)](/fsetxattr/2.md) or [**fgetxattr**(2)](/fgetxattr/2.md) *fd* must contain the file descriptor of the file.

  Available since 5.19.

- **IORING\_OP\_BIND**

  Issues the equivalent of the [**bind**(2)](/bind/2.md) system call. *fd* must contain the file descriptor of the socket, *addr* must contain a pointer to the sockaddr struct containing the address to assign and *addr2* must contain the length of the address.

  Available since 6.11.

- **IORING\_OP\_LISTEN**

  Issues the equivalent of the [**listen**(2)](/listen/2.md) system call. *fd* must contain the file descriptor of the socket and *len* must contain the backlog parameter, i.e. the maximum amount of pending queued connections.

  Available since 6.11.

- **IORING\_OP\_FTRUNCATE**

  Issues the equivalent of the [**ftruncate**(2)](/ftruncate/2.md) system call. *fd* must contain the file descriptor of the file to truncate and *off* must contain the length to which the file will be truncated.

  Available since 6.9.

- **IORING\_OP\_READ\_MULTISHOT**

  Like **IORING\_OP\_READ**, but similar to requests prepared with [*io\_uring\_prep\_multishot\_accept*(3)](/io_uring_prep_multishot_accept/3.md) additional reads and thus CQEs will be performed based on this single SQE once there is more data available. Is restricted to pollable files and will fall back to single shot if the file does not support **NOWAIT**. Like other multishot type requests, the application should look at the CQE flags and see if **IORING\_CQE\_F\_MORE** is set on completion as an indication of whether or not the read request will generate further CQEs. Available since 6.7.

- **IORING\_OP\_FUTEX\_WAIT**

  Issues the equivalent of the **futex\_wait**(2) system call. *addr* must hold a pointer to the futex, *addr2* must hold the value to which the futex has to be changed so this caller to **futex\_wait**(2) can be woken by a call to **futex\_wake**(2), *addr3* must hold the bitmask of this **futex\_wait**(2) caller. For a caller of **futex\_wake**(2) to wake a waiter additionally the bitmask of the waiter and waker must have at least one set bit in common. *fd* must contain additional flags passed in.

  Available since 6.7.

- **IORING\_OP\_FUTEX\_WAKE**

  Issues the equivalent of the **futex\_wake**(2) system call. *addr* must hold a pointer to the futex, *addr2* must hold the maximum number of waiters waiting on this futex to wake, *addr3* must hold the bitmask of this **futex\_wake**(2) call. To wake a waiter additionally the bitmask of the waiter and waker must have at least one set bit in common. *fd* must contain additional flags passed in.

  Available since 6.7.

- **IORING\_OP\_FUTEX\_WAITV**

  Issues the equivalent of the [**futex\_waitv**(2)](/futex_waitv/2.md) system call. *addr* must hold a pointer to the futexv struct, *len* must hold the length of the futexv struct, which may not be 0 and must be smaller than **FUTEX\_WAITV\_MAX** (as of 6.11 == 128).

  Available since 6.7.

- **IORING\_OP\_FIXED\_FD\_INSTALL**

  This operation is used to insert a registered file into the regular process file table. Consequently *fd* must contain the file index and **IOSQE\_FIXED\_FILE** must be set. The resulting regular fd is returned via cqe-\>res. Additional flags may be passed in via *install\_fd\_flags*. Currently supported flags are: **IORING\_FIXED\_FD\_NO\_CLOEXEC**, which overrides a potentially set **O\_CLOEXEC** flag set on the initial file.

  Available since 6.8.

- **IORING\_OP\_PIPE**

  This operation is used to create a pipe, a set of file descriptors that can be used for communication. The pipe may either be created as a set of normal file descriptors, or it can be created as fixed/direct descriptors. *addr* must contain a pointer to an array of two integers, where upon successful completion of the request, index 0 will contain the read side and index 1 the write side of the pipe. *pipe\_flags* may contain flags associated with pipe creation. Currently **O\_CLOEXEC \| O\_NONBLOCK \| O\_DIRECT \| O\_NOTIFICATION\_PIPE** are supported. *file\_index* may contain the the desired starting point for a fixed descriptor pipe creation. If this is set to **0,** then regular file descriptors are used. If set to **IORING\_FILE\_INDEX\_ALLOC,** then the kernel will allocate descriptors from the previously registered direct descriptor table. If set to any non-zero value, then it sets the exact direct descriptor value for index 0 of the pipe, and index 1 will be the following integer value.

  If used with direct descriptors rather than normal file descriptors, a direct descriptor table must have been previously registered with the kernel.

  Available since 6.16.

- **IORING\_OP\_RECV\_ZC**

  Receive data from a socket using zero-copy techniques. Unlike **IORING\_OP\_RECV**, this operation does not use a user-provided buffer. Instead, data is delivered through a pre-registered zero-copy RX interface queue. *fd* must be set to the socket file descriptor. *zcrx\_ifq\_idx* specifies the index of the registered zero-copy RX interface queue. *len* specifies the maximum amount of data to receive. *ioprio* can contain flags such as **IORING\_RECVSEND\_POLL\_FIRST** and **IORING\_RECV\_MULTISHOT**. This operation requires multishot mode.

  Before using this command, a zero-copy RX interface queue must be registered via [**io\_uring\_register**(2)](/io_uring_register/2.md) using **IORING\_REGISTER\_ZCRX\_IFQ**. Data completions are posted as auxiliary CQEs.

  Available since 6.15.

- **IORING\_OP\_EPOLL\_WAIT**

  Wait for events on an epoll instance. This is an async version of [**epoll\_wait**(2)](/epoll_wait/2.md). *fd* must be set to the epoll file descriptor, *addr* must point to an array of *struct epoll\_event* to receive the events, and *len* must contain the maximum number of events to return.

  The primary use case is for legacy event loops that still use epoll for some file descriptors. By using io\_uring to wait on epoll events, the application can unify its event handling through io\_uring while maintaining backwards compatibility with epoll-based components.

  Available since 6.15.

- **IORING\_OP\_READV\_FIXED**

  - **IORING\_OP\_WRITEV\_FIXED**

  Vectored read and write operations using pre-registered buffers, combining the functionality of **IORING\_OP\_READV**/**IORING\_OP\_WRITEV** with **IORING\_OP\_READ\_FIXED**/**IORING\_OP\_WRITE\_FIXED**. The *buf\_index* field specifies the index into the registered buffer table. Unlike the non-fixed vectored operations, the iovec entries point into the registered buffer region. This allows vectored I/O while still benefiting from the reduced overhead of pre-registered buffers.

  Available since 6.15.

- **IORING\_OP\_NOP128**

  No operation, similar to **IORING\_OP\_NOP**, but explicitly uses a 128-byte SQE. This can be useful for testing or alignment purposes when using mixed 64/128-byte SQE rings (**IORING\_SETUP\_SQE\_MIXED**).

  Available since 6.19.

- **IORING\_OP\_URING\_CMD128**

  Passthrough command to the underlying file, identical to **IORING\_OP\_URING\_CMD**, but explicitly uses a 128-byte SQE. The extra 64 bytes provide additional space for command-specific data. This is useful with **IORING\_SETUP\_SQE\_MIXED** rings where some commands need the larger SQE size while others do not.

  See **IORING\_OP\_URING\_CMD** for general usage details.

  Available since 6.19.

The *flags* field is a bit mask. The supported flags are:

- **IOSQE\_FIXED\_FILE**

  When this flag is specified, *fd* is an index into the files array registered with the io\_uring instance (see the **IORING\_REGISTER\_FILES** section of the [**io\_uring\_register**(2)](/io_uring_register/2.md) man page). Note that this isn't always available for all commands. If used on a command that doesn't support fixed files, the SQE will error with **-EBADF**. Available since 5.1.

- **IOSQE\_IO\_DRAIN**

  When this flag is specified, the SQE will not be started before previously submitted SQEs have completed, and new SQEs will not be started before this one completes. Available since 5.2.

- **IOSQE\_IO\_LINK**

  When this flag is specified, the SQE forms a link with the next SQE in the submission ring. That next SQE will not be started before the previous request completes. This, in effect, forms a chain of SQEs, which can be arbitrarily long. The tail of the chain is denoted by the first SQE that does not have this flag set. Chains are not supported across submission boundaries. Even if the last SQE in a submission has this flag set, it will still terminate the current chain. This flag has no effect on previous SQE submissions, nor does it impact SQEs that are outside of the chain tail. This means that multiple chains can be executing in parallel, or chains and individual SQEs. Only members inside the chain are serialized. A chain of SQEs will be broken if any request in that chain ends in error. io\_uring considers any unexpected result an error. This means that, eg, a short read will also terminate the remainder of the chain. If a chain of SQE links is broken, the remaining unstarted part of the chain will be terminated and completed with **-ECANCELED** as the error code. Available since 5.3.

- **IOSQE\_IO\_HARDLINK**

  Like IOSQE\_IO\_LINK, but it doesn't sever regardless of the completion result. Note that the link will still sever if we fail submitting the parent request, hard links are only resilient in the presence of completion results for requests that did submit correctly. **IOSQE\_IO\_HARDLINK** implies **IOSQE\_IO\_LINK**. Available since 5.5.

- **IOSQE\_ASYNC**

  Normal operation for io\_uring is to try and issue an sqe as non-blocking first, and if that fails, execute it in an async manner. To support more efficient overlapped operation of requests that the application knows/assumes will always (or most of the time) block, the application can ask for an sqe to be issued async from the start. Available since 5.6.

- **IOSQE\_BUFFER\_SELECT**

  Used in conjunction with the **IORING\_OP\_PROVIDE\_BUFFERS** command, which registers a pool of buffers to be used by commands that read or receive data. When buffers are registered for this use case, and this flag is set in the command, io\_uring will grab a buffer from this pool when the request is ready to receive or read data. If successful, the resulting CQE will have **IORING\_CQE\_F\_BUFFER** set in the flags part of the struct, and the upper **IORING\_CQE\_BUFFER\_SHIFT** bits will contain the ID of the selected buffers. This allows the application to know exactly which buffer was selected for the operation. If no buffers are available and this flag is set, then the request will fail with **-ENOBUFS** as the error code. Once a buffer has been used, it is no longer available in the kernel pool. The application must re-register the given buffer again when it is ready to recycle it (eg has completed using it). Available since 5.7.

- **IOSQE\_CQE\_SKIP\_SUCCESS**

  Don't generate a CQE if the request completes successfully. If the request fails, an appropriate CQE will be posted as usual and if there is no **IOSQE\_IO\_HARDLINK,** CQEs for all linked requests will be omitted. The notion of failure/success is opcode specific and is the same as with breaking chains of **IOSQE\_IO\_LINK**. One special case is when the request has a linked timeout, then the CQE generation for the linked timeout is decided solely by whether it has **IOSQE\_CQE\_SKIP\_SUCCESS** set, regardless whether it timed out or was canceled. In other words, if a linked timeout has the flag set, it's guaranteed to not post a CQE.

  The semantics are chosen to accommodate several use cases. First, when all but the last request of a normal link without linked timeouts are marked with the flag, only one CQE per link is posted. Additionally, it enables suppression of CQEs in cases where the side effects of a successfully executed operation is enough for userspace to know the state of the system. One such example would be writing to a synchronisation file.

  This flag is incompatible with **IOSQE\_IO\_DRAIN**. Using both of them in a single ring is undefined behavior, even when they are not used together in a single request. Currently, after the first request with **IOSQE\_CQE\_SKIP\_SUCCESS**, all subsequent requests marked with drain will be failed at submission time. Note that the error reporting is best effort only, and restrictions may change in the future.

  Available since 5.17.

*ioprio* specifies the I/O priority.  See [**ioprio\_get**(2)](/ioprio_get/2.md) for a description of Linux I/O priorities.

*fd* specifies the file descriptor against which the operation will be performed, with the exception noted above.

If the operation is one of **IORING\_OP\_READ\_FIXED** or **IORING\_OP\_WRITE\_FIXED**, *addr* and *len* must fall within the buffer located at *buf\_index* in the fixed buffer array.  If the operation is either **IORING\_OP\_READV** or **IORING\_OP\_WRITEV**, then *addr* points to an iovec array of *len* entries.

*rw\_flags*, specified for read and write operations, contains a bitwise OR of per-I/O flags, as described in the [**preadv2**(2)](/preadv2/2.md) man page.

The *fsync\_flags* bit mask may contain either 0, for a normal file integrity sync, or **IORING\_FSYNC\_DATASYNC** to provide data sync only semantics.  See the descriptions of **O\_SYNC** and **O\_DSYNC** in the [**open**(2)](/open/2.md) manual page for more information.

The bits that may be set in *poll\_events* are defined in *\<poll.h\>*, and documented in [**poll**(2)](/poll/2.md).

*user\_data* is an application-supplied value that will be copied into the completion queue entry (see below). *buf\_index* is an index into an array of fixed buffers, and is only valid if fixed buffers were registered. *personality* is the credentials id to use for this operation. See [**io\_uring\_register**(2)](/io_uring_register/2.md) for how to register personalities with io\_uring. If set to 0, the current personality of the submitting task is used.

Once the submission queue entry is initialized, I/O is submitted by placing the index of the submission queue entry into the tail of the submission queue.  After one or more indexes are added to the queue, and the queue tail is advanced, the [**io\_uring\_enter**(2)](/io_uring_enter/2.md) system call can be invoked to initiate the I/O.

Completions use the following data structure:

```
/*
 * IO completion data structure (Completion Queue Entry)
 */
struct io_uring_cqe {
    __u64    user_data; /* sqe->data submission passed back */
    __s32    res;       /* result code for this event */
    __u32    flags;
};
```

*user\_data* is copied from the field of the same name in the submission queue entry.  The primary use case is to store data that the application will need to access upon completion of this particular I/O.  The *flags* is used for certain commands, like **IORING\_OP\_POLL\_ADD** or in conjunction with **IOSQE\_BUFFER\_SELECT** or **IORING\_OP\_MSG\_RING**, see those entries for details. *res* is the operation-specific result, but io\_uring-specific errors (e.g. flags or opcode invalid) are returned through this field. They are described in section **CQE** **ERRORS**.

For read and write opcodes, the return values match *errno* values documented in the [**preadv2**(2)](/preadv2/2.md) and [**pwritev2**(2)](/pwritev2/2.md) man pages, with *res* holding the equivalent of *-errno* for error cases, or the transferred number of bytes in case the operation is successful. Hence both error and success return can be found in that field in the CQE. For other request types, the return values are documented in the matching man page for that type, or in the opcodes section above for io\_uring-specific opcodes.

## RETURN VALUE

[**io\_uring\_enter**(2)](/io_uring_enter/2.md) returns the number of I/Os successfully consumed.  This can be zero if *to\_submit* was zero or if the submission queue was empty. Note that if the ring was created with **IORING\_SETUP\_SQPOLL** specified, then the return value will generally be the same as *to\_submit* as submission happens outside the context of the system call.

The errors related to a submission queue entry will be returned through a completion queue entry (see section **CQE** **ERRORS**), rather than through the system call itself.

Errors that occur not on behalf of a submission queue entry are returned via the system call directly. On such an error, a negative error code is returned. The caller should not rely on *errno* variable.

## ERRORS

These are the errors returned by [**io\_uring\_enter**(2)](/io_uring_enter/2.md) system call.

- **EAGAIN**

  The kernel was unable to allocate memory for the request, or otherwise ran out of resources to handle it. The application should wait for some completions and try again.

- **EBADF**

  *fd* is not a valid file descriptor.

- **EBADFD**

  *fd* is a valid file descriptor, but the io\_uring ring is not in the right state (enabled). See [**io\_uring\_register**(2)](/io_uring_register/2.md) for details on how to enable the ring.

- **EBADR**

  At least one CQE was dropped even with the **IORING\_FEAT\_NODROP** feature, and there are no otherwise available CQEs. This clears the error state and so with no other changes the next call to [**io\_uring\_enter**(2)](/io_uring_enter/2.md) will not have this error. This error should be extremely rare and indicates the machine is running critically low on memory. It may be reasonable for the application to terminate running unless it is able to safely handle any CQE being lost.

- **EBUSY**

  If the **IORING\_FEAT\_NODROP** feature flag is set, then **EBUSY** will be returned if there were overflow entries, **IORING\_ENTER\_GETEVENTS** flag is set and not all of the overflow entries were able to be flushed to the CQ ring.

  Without **IORING\_FEAT\_NODROP** the application is attempting to overcommit the number of requests it can have pending. The application should wait for some completions and try again. May occur if the application tries to queue more requests than we have room for in the CQ ring, or if the application attempts to wait for more events without having reaped the ones already present in the CQ ring.

- **EEXIST**

  The thread submitting the work is invalid. This may occur if **IORING\_ENTER\_GETEVENTS** and **IORING\_SETUP\_DEFER\_TASKRUN** is set, but the submitting thread is not the thread that initially created or enabled the io\_uring associated with *fd.*

- **EINVAL**

  Some bits in the *flags* argument are invalid.

- **EFAULT**

  An invalid user space address was specified for the *sig* argument.

- **ENXIO**

  The io\_uring instance is in the process of being torn down.

- **EOPNOTSUPP**

  *fd* does not refer to an io\_uring instance.

- **EINTR**

  The operation was interrupted by a delivery of a signal before it could complete; see [**signal**(7)](/signal/7.md). Can happen while waiting for events with **IORING\_ENTER\_GETEVENTS.**

- **EOWNERDEAD**

  The ring has been setup with **IORING\_SETUP\_SQPOLL** and the sq poll kernel thread has been killed.

## CQE ERRORS

These io\_uring-specific errors are returned as a negative value in the *res* field of the completion queue entry.

- **EACCES**

  The *flags* field or *opcode* in a submission queue entry is not allowed due to registered restrictions. See [**io\_uring\_register**(2)](/io_uring_register/2.md) for details on how restrictions work.

- **EBADF**

  The *fd* field in the submission queue entry is invalid, or the **IOSQE\_FIXED\_FILE** flag was set in the submission queue entry, but no files were registered with the io\_uring instance.

- **EFAULT**

  buffer is outside of the process' accessible address space

- **EFAULT**

  **IORING\_OP\_READ\_FIXED** or **IORING\_OP\_WRITE\_FIXED** was specified in the *opcode* field of the submission queue entry, but either buffers were not registered for this io\_uring instance, or the address range described by *addr* and *len* does not fit within the buffer registered at *buf\_index*.

- **EINVAL**

  The *flags* field or *opcode* in a submission queue entry is invalid.

- **EINVAL**

  The *buf\_index* member of the submission queue entry is invalid.

- **EINVAL**

  The *personality* field in a submission queue entry is invalid.

- **EINVAL**

  **IORING\_OP\_READV** or **IORING\_OP\_WRITEV** was specified in the submission queue entry, but the io\_uring instance has fixed buffers registered.

- **EINVAL**

  **IORING\_OP\_READ\_FIXED** or **IORING\_OP\_WRITE\_FIXED** was specified in the submission queue entry, and the *buf\_index* is invalid.

- **EINVAL**

  **IORING\_OP\_READV**, **IORING\_OP\_WRITEV**, **IORING\_OP\_READ\_FIXED**, **IORING\_OP\_WRITE\_FIXED** or **IORING\_OP\_FSYNC** was specified in the submission queue entry, but the io\_uring instance was configured for IOPOLLing, or any of *addr*, *ioprio*, *off*, *len*, or *buf\_index* was set in the submission queue entry.

- **EINVAL**

  **IORING\_OP\_POLL\_ADD** or **IORING\_OP\_POLL\_REMOVE** was specified in the *opcode* field of the submission queue entry, but the io\_uring instance was configured for busy-wait polling (**IORING\_SETUP\_IOPOLL**), or any of *ioprio*, *off*, *len*, or *buf\_index* was non-zero in the submission queue entry.

- **EINVAL**

  **IORING\_OP\_POLL\_ADD** was specified in the *opcode* field of the submission queue entry, and the *addr* field was non-zero.

- **EOPNOTSUPP**

  *opcode* is valid, but not supported by this kernel.

- **EOPNOTSUPP**

  **IOSQE\_BUFFER\_SELECT** was set in the *flags* field of the submission queue entry, but the *opcode* doesn't support buffer selection.

- **EINVAL**

  **IORING\_OP\_TIMEOUT** was specified, but *timeout\_flags* specified more than one clock source or **IORING\_TIMEOUT\_MULTISHOT** was set alongside **IORING\_TIMEOUT\_ABS**.
