O_DIRECT, and silently blocked everywhere else.Why did reading a file and reading a socket
ever need two completely different access paradigms?
io_submit) - only worked for O_DIRECT, silently blocked otherwise.O_DIRECT I/O would randomly block.io-wq is just the last-resort fallback - not the highlight.ioringapi)"…#include <liburing.h> fdfile = open("file.txt", O_RDONLY); /* a file - but could be a socket, pipe, any fd */ /* describe one read - no syscall yet */ sqe = io_uring_get_sqe(ring); io_uring_prep_read(sqe, fdfile, buf, sizeof(buf), 0); /* hand it to the kernel, then wait */ io_uring_submit(ring); io_uring_wait_cqe(ring, &cqe); printf("read %d bytes\n", cqe->res); /* res = bytes, or -errno */ io_uring_cqe_seen(ring, cqe); /* tell kernel the app has seen this CQE */
#include <liburing.h> pipe(fds); /* a pipe now - the read code below doesn't change */ /* describe one read - no syscall yet */ sqe = io_uring_get_sqe(ring); io_uring_prep_read(sqe, fds[0], buf, sizeof(buf), 0); /* hand it to the kernel, then wait */ io_uring_submit(ring); io_uring_wait_cqe(ring, &cqe); printf("read %d bytes\n", cqe->res); /* res = bytes, or -errno */ io_uring_cqe_seen(ring, cqe); /* tell kernel the app has seen this CQE */
#include <liburing.h> pipe(fds); /* a pipe now - the read code below doesn't change */ /* describe one read - no syscall yet */ sqe = io_uring_get_sqe(ring); io_uring_prep_read(sqe, fds[0], buf, sizeof(buf), 0); /* submit + wait in one syscall, then grab the ready CQE */ io_uring_submit_and_wait(ring, 1); io_uring_peek_cqe(ring, &cqe); printf("read %d bytes\n", cqe->res); /* res = bytes, or -errno */ io_uring_cqe_seen(ring, cqe); /* tell kernel the app has seen this CQE */
io_uring_prep_accept(), io_uring_prep_openat(), io_uring_prep_sync_file_range(), …task_work completes or retries in-context.llist, then ran llist_reverse() before running.io-wq was always used to drive -EAGAIN retries.msghdr; recv #2 sizes an iovec to it and takes the rest in one go.cmsg / error queue dance sync zero-copy needs for completion notifications - io_uring posts a normal CQE.URING_CMD)./dev/ublkbN; a userspace daemon serves every I/O - like FUSE for block.ublk).io-wq used kernel threads, by default carrying kernel credentials.