io_uring linked requests
io_uring linked requests are a chain of submission entries whose dependencies delay each successor until its predecessor completes.
IO_LINK is local to its chain and does not order unrelated requests. A chain must stay within a submission boundary, and the last entry of a submission ends the chain even when its link flag is set. IO_HARDLINK retains a link across a completion error; it does not convert the failed operation into a successful one. [1] [3]
In the Linux v6.16 ABI, IOSQE_IO_LINK is flag bit 2 with value 4 and IOSQE_IO_HARDLINK is bit 3 with value 8. The link flag is available since Linux 5.3 and the hard link since 5.5. [4] [3]
Any unexpected result, including a short read, breaks an ordinary chain. Without completion suppression, the unstarted remainder reports -ECANCELED. A hard link still severs if the parent request fails at submission rather than at completion. [3]
In a chain without linked timeouts or IO_HARDLINK, a skip-enabled failure reports its own result while subsequent linked CQEs are omitted. [5] In the upstream normal-chain tests, successful predecessors suppress their reports and the tail reports success; a failing request instead supplies the sole report. Waiting only for the tail can therefore miss the failure path. The unsuppressed tail can also fail: its identity alone never establishes success. This is source review, not an executed kernel test. [6]
Relations
- related
- io_uring, io_uring completion queue entry, io_uring drain, Persistence ordering, io_uring cancellation, io_uring linked timeout
Advantages
- Expresses dependencies without waiting in user space between every operation. [1]
- Several chains and single requests can run in parallel, because only members of one chain are serialized. [3]
Limitations
- Ordering a chain does not make its side effects an atomic transaction.
- The chain breaks only on results that io_uring treats as errors, so an application-level check on an earlier result cannot stop later members. [3]
Citations
- liburing 2.9: io_uring_sqe_set_flags(3), chain and drain scope.
- Linux man-pages, io_uring_enter(2): IOSQE_IO_LINK and IOSQE_IO_HARDLINK
- Linux v6.16 include/uapi/linux/io_uring.h: SQE flag bits
- liburing 2.11: io_uring_enter(2), IOSQE_CQE_SKIP_SUCCESS and link/timeout exceptions
- liburing 2.11: skip-cqe.c, test_link_success and test_link_fail (source inspection only)
Further reading
Sources & caveats
- flags is the liburing 2.9 io_uring_sqe_set_flags(3) page, kept from the earlier version.
- enter is the Linux man-pages io_uring_enter(2) page, read on the access date in IOSQE_IO_LINK and IOSQE_IO_HARDLINK.
- uapi-header is include/uapi/linux/io_uring.h at tag v6.16, read in the IOSQE_*_BIT enumeration and flag definitions.
- Bits 2 and 3 and values 4 and 8 come from uapi-header. 5.3, 5.5 and -ECANCELED come from enter.