{
  "slug": "io-uring-drain",
  "term": "io_uring drain",
  "aliases": [
    "IOSQE_IO_DRAIN"
  ],
  "definition": "io_uring drain is a submission flag that delays a request until earlier requests in the same ring finish and delays later requests until the drain request finishes.",
  "note": "Drain orders completion within one ring; it is not a device-cache flush. [flags] The documented API forbids mixing IO_DRAIN with IOSQE_CQE_SKIP_SUCCESS in one ring, including on separate requests. [enter]\n\nIOSQE_IO_DRAIN is bit 1 of the submission flags, value 2, and has been available since Linux 5.2. A drained request does not start before all previously submitted requests have completed, and later requests do not start before it completes. [enter] [uapi-header]\n\nA link chain orders only the requests joined to it, while a drain waits for every earlier request in the ring. One slow earlier request therefore also delays all requests submitted after the drain. [enter]",
  "status": "shipping",
  "advantages": [
    {
      "text": "Can establish a ring-scoped dependency before a synchronization request.",
      "citationIds": [
        "flags"
      ]
    }
  ],
  "limitations": [
    "It does not order another ring or validate earlier write results."
  ],
  "related": [
    "io-uring",
    "io-uring-linked-requests",
    "fsync",
    "persistence-ordering"
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-10-22",
  "citations": [
    {
      "id": "flags",
      "title": "liburing 2.9: io_uring_sqe_set_flags(3), chain and drain scope.",
      "url": "https://github.com/axboe/liburing/blob/liburing-2.9/man/io_uring_sqe_set_flags.3",
      "accessed": "2026-10-14"
    },
    {
      "id": "enter",
      "title": "liburing: io_uring_enter(2), IORING_OP_FSYNC, linking and CQE_SKIP_SUCCESS constraints.",
      "url": "https://man7.org/linux/man-pages/man2/io_uring_enter.2.html",
      "accessed": "2026-10-22"
    },
    {
      "id": "hesela-uring",
      "title": "io_uring: completion is not a durable commit",
      "url": "https://hesela.com/analyses/io-uring-completion-ordering-durability/",
      "accessed": "2026-10-14"
    },
    {
      "id": "uapi-header",
      "title": "Linux v6.16 include/uapi/linux/io_uring.h: submission flag bits",
      "url": "https://github.com/torvalds/linux/blob/v6.16/include/uapi/linux/io_uring.h",
      "accessed": "2026-10-22"
    }
  ],
  "provenance": [
    "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, reread on the access date in IOSQE_IO_DRAIN, IOSQE_IO_LINK and IOSQE_CQE_SKIP_SUCCESS.",
    "uapi-header is include/uapi/linux/io_uring.h at tag v6.16, read in enum io_uring_sqe_flags_bit.",
    "Bit 1 and value 2 come from uapi-header. 5.2 comes from enter."
  ]
}
