├── .github ├── actions │ └── codespell │ │ └── stopwords ├── pull_request_template.md └── workflows │ └── ci.yml ├── .gitignore ├── CHANGELOG ├── CITATION.cff ├── CONTRIBUTING.md ├── COPYING ├── COPYING.GPL ├── LICENSE ├── Makefile ├── Makefile.common ├── Makefile.quiet ├── README ├── SECURITY.md ├── configure ├── debian ├── README.Debian ├── changelog ├── control ├── copyright ├── liburing-dev.install ├── liburing-dev.manpages ├── liburing2.install ├── liburing2.symbols ├── patches │ └── series ├── rules ├── source │ ├── format │ ├── local-options │ └── options └── watch ├── examples ├── Makefile ├── helpers.c ├── helpers.h ├── io_uring-close-test.c ├── io_uring-cp.c ├── io_uring-test.c ├── io_uring-udp.c ├── kdigest.c ├── link-cp.c ├── napi-busy-poll-client.c ├── napi-busy-poll-server.c ├── poll-bench.c ├── proxy.c ├── proxy.h ├── reg-wait.c ├── rsrc-update-bench.c ├── send-zerocopy.c ├── ucontext-cp.c └── zcrx.c ├── liburing-ffi.pc.in ├── liburing.pc.in ├── liburing.spec ├── make-debs.sh ├── man ├── IO_URING_CHECK_VERSION.3 ├── IO_URING_VERSION_MAJOR.3 ├── IO_URING_VERSION_MINOR.3 ├── __io_uring_buf_ring_cq_advance.3 ├── io_uring.7 ├── io_uring_buf_ring_add.3 ├── io_uring_buf_ring_advance.3 ├── io_uring_buf_ring_available.3 ├── io_uring_buf_ring_cq_advance.3 ├── io_uring_buf_ring_init.3 ├── io_uring_buf_ring_mask.3 ├── io_uring_check_version.3 ├── io_uring_clone_buffers.3 ├── io_uring_clone_buffers_offset.3 ├── io_uring_close_ring_fd.3 ├── io_uring_cq_advance.3 ├── io_uring_cq_has_overflow.3 ├── io_uring_cq_ready.3 ├── io_uring_cqe_get_data.3 ├── io_uring_cqe_get_data64.3 ├── io_uring_cqe_seen.3 ├── io_uring_enable_rings.3 ├── io_uring_enter.2 ├── io_uring_enter2.2 ├── io_uring_for_each_cqe.3 ├── io_uring_free_buf_ring.3 ├── io_uring_free_probe.3 ├── io_uring_free_reg_wait.3 ├── io_uring_get_events.3 ├── io_uring_get_probe.3 ├── io_uring_get_sqe.3 ├── io_uring_major_version.3 ├── io_uring_minor_version.3 ├── io_uring_opcode_supported.3 ├── io_uring_peek_batch_cqe.3 ├── io_uring_peek_cqe.3 ├── io_uring_prep_accept.3 ├── io_uring_prep_accept_direct.3 ├── io_uring_prep_bind.3 ├── io_uring_prep_cancel.3 ├── io_uring_prep_cancel64.3 ├── io_uring_prep_cancel_fd.3 ├── io_uring_prep_close.3 ├── io_uring_prep_close_direct.3 ├── io_uring_prep_cmd.3 ├── io_uring_prep_cmd_discard.3 ├── io_uring_prep_connect.3 ├── io_uring_prep_epoll_wait.3 ├── io_uring_prep_fadvise.3 ├── io_uring_prep_fadvise64.3 ├── io_uring_prep_fallocate.3 ├── io_uring_prep_fgetxattr.3 ├── io_uring_prep_files_update.3 ├── io_uring_prep_fixed_fd_install.3 ├── io_uring_prep_fsetxattr.3 ├── io_uring_prep_fsync.3 ├── io_uring_prep_ftruncate.3 ├── io_uring_prep_futex_wait.3 ├── io_uring_prep_futex_waitv.3 ├── io_uring_prep_futex_wake.3 ├── io_uring_prep_getxattr.3 ├── io_uring_prep_link.3 ├── io_uring_prep_link_timeout.3 ├── io_uring_prep_linkat.3 ├── io_uring_prep_listen.3 ├── io_uring_prep_madvise.3 ├── io_uring_prep_madvise64.3 ├── io_uring_prep_mkdir.3 ├── io_uring_prep_mkdirat.3 ├── io_uring_prep_msg_ring.3 ├── io_uring_prep_msg_ring_cqe_flags.3 ├── io_uring_prep_msg_ring_fd.3 ├── io_uring_prep_msg_ring_fd_alloc.3 ├── io_uring_prep_multishot_accept.3 ├── io_uring_prep_multishot_accept_direct.3 ├── io_uring_prep_nop.3 ├── io_uring_prep_open.3 ├── io_uring_prep_open_direct.3 ├── io_uring_prep_openat.3 ├── io_uring_prep_openat2.3 ├── io_uring_prep_openat2_direct.3 ├── io_uring_prep_openat_direct.3 ├── io_uring_prep_poll_add.3 ├── io_uring_prep_poll_multishot.3 ├── io_uring_prep_poll_remove.3 ├── io_uring_prep_poll_update.3 ├── io_uring_prep_provide_buffers.3 ├── io_uring_prep_read.3 ├── io_uring_prep_read_fixed.3 ├── io_uring_prep_read_multishot.3 ├── io_uring_prep_readv.3 ├── io_uring_prep_readv2.3 ├── io_uring_prep_recv.3 ├── io_uring_prep_recv_multishot.3 ├── io_uring_prep_recvmsg.3 ├── io_uring_prep_recvmsg_multishot.3 ├── io_uring_prep_remove_buffers.3 ├── io_uring_prep_rename.3 ├── io_uring_prep_renameat.3 ├── io_uring_prep_send.3 ├── io_uring_prep_send_bundle.3 ├── io_uring_prep_send_set_addr.3 ├── io_uring_prep_send_zc.3 ├── io_uring_prep_send_zc_fixed.3 ├── io_uring_prep_sendmsg.3 ├── io_uring_prep_sendmsg_zc.3 ├── io_uring_prep_sendto.3 ├── io_uring_prep_setxattr.3 ├── io_uring_prep_shutdown.3 ├── io_uring_prep_socket.3 ├── io_uring_prep_socket_direct.3 ├── io_uring_prep_socket_direct_alloc.3 ├── io_uring_prep_splice.3 ├── io_uring_prep_statx.3 ├── io_uring_prep_symlink.3 ├── io_uring_prep_symlinkat.3 ├── io_uring_prep_sync_file_range.3 ├── io_uring_prep_tee.3 ├── io_uring_prep_timeout.3 ├── io_uring_prep_timeout_remove.3 ├── io_uring_prep_timeout_update.3 ├── io_uring_prep_unlink.3 ├── io_uring_prep_unlinkat.3 ├── io_uring_prep_waitid.3 ├── io_uring_prep_write.3 ├── io_uring_prep_write_fixed.3 ├── io_uring_prep_writev.3 ├── io_uring_prep_writev2.3 ├── io_uring_queue_exit.3 ├── io_uring_queue_init.3 ├── io_uring_queue_init_mem.3 ├── io_uring_queue_init_params.3 ├── io_uring_recvmsg_cmsg_firsthdr.3 ├── io_uring_recvmsg_cmsg_nexthdr.3 ├── io_uring_recvmsg_name.3 ├── io_uring_recvmsg_out.3 ├── io_uring_recvmsg_payload.3 ├── io_uring_recvmsg_payload_length.3 ├── io_uring_recvmsg_validate.3 ├── io_uring_register.2 ├── io_uring_register_buf_ring.3 ├── io_uring_register_buffers.3 ├── io_uring_register_buffers_sparse.3 ├── io_uring_register_buffers_tags.3 ├── io_uring_register_buffers_update_tag.3 ├── io_uring_register_clock.3 ├── io_uring_register_eventfd.3 ├── io_uring_register_eventfd_async.3 ├── io_uring_register_file_alloc_range.3 ├── io_uring_register_files.3 ├── io_uring_register_files_sparse.3 ├── io_uring_register_files_tags.3 ├── io_uring_register_files_update.3 ├── io_uring_register_files_update_tag.3 ├── io_uring_register_iowq_aff.3 ├── io_uring_register_iowq_max_workers.3 ├── io_uring_register_napi.3 ├── io_uring_register_reg_wait.3 ├── io_uring_register_ring_fd.3 ├── io_uring_register_sync_cancel.3 ├── io_uring_resize_rings.3 ├── io_uring_setup.2 ├── io_uring_setup_buf_ring.3 ├── io_uring_setup_reg_wait.3 ├── io_uring_sq_ready.3 ├── io_uring_sq_space_left.3 ├── io_uring_sqe_set_buf_group.3 ├── io_uring_sqe_set_data.3 ├── io_uring_sqe_set_data64.3 ├── io_uring_sqe_set_flags.3 ├── io_uring_sqring_wait.3 ├── io_uring_submit.3 ├── io_uring_submit_and_get_events.3 ├── io_uring_submit_and_wait.3 ├── io_uring_submit_and_wait_min_timeout.3 ├── io_uring_submit_and_wait_reg.3 ├── io_uring_submit_and_wait_timeout.3 ├── io_uring_unregister_buf_ring.3 ├── io_uring_unregister_buffers.3 ├── io_uring_unregister_eventfd.3 ├── io_uring_unregister_files.3 ├── io_uring_unregister_iowq_aff.3 ├── io_uring_unregister_napi.3 ├── io_uring_unregister_ring_fd.3 ├── io_uring_wait_cqe.3 ├── io_uring_wait_cqe_nr.3 ├── io_uring_wait_cqe_timeout.3 ├── io_uring_wait_cqes.3 └── io_uring_wait_cqes_min_timeout.3 ├── src ├── Makefile ├── arch │ ├── aarch64 │ │ ├── lib.h │ │ └── syscall.h │ ├── generic │ │ ├── lib.h │ │ └── syscall.h │ ├── riscv64 │ │ ├── lib.h │ │ └── syscall.h │ ├── syscall-defs.h │ └── x86 │ │ ├── lib.h │ │ └── syscall.h ├── ffi.c ├── include │ ├── liburing.h │ └── liburing │ │ ├── barrier.h │ │ ├── io_uring.h │ │ └── sanitize.h ├── int_flags.h ├── lib.h ├── liburing-ffi.map ├── liburing.map ├── nolibc.c ├── queue.c ├── register.c ├── sanitize.c ├── setup.c ├── setup.h ├── syscall.c ├── syscall.h └── version.c └── test ├── 232c93d07b74.c ├── 35fa71a030ca.c ├── 500f9fbadef8.c ├── 7ad0e4b2f83c.c ├── 8a9973408177.c ├── 917257daa0fe.c ├── Makefile ├── a0908ae19763.c ├── a4c0b3decb33.c ├── accept-link.c ├── accept-non-empty.c ├── accept-reuse.c ├── accept-test.c ├── accept.c ├── across-fork.c ├── b19062a56726.c ├── b5837bd5311d.c ├── bind-listen.c ├── buf-ring-nommap.c ├── buf-ring-put.c ├── buf-ring.c ├── ce593a6c480a.c ├── close-opath.c ├── cmd-discard.c ├── config ├── connect-rep.c ├── connect.c ├── coredump.c ├── cq-full.c ├── cq-overflow.c ├── cq-peek-batch.c ├── cq-ready.c ├── cq-size.c ├── d4ae271dfaae.c ├── d77a67ed5f27.c ├── defer-taskrun.c ├── defer-tw-timeout.c ├── defer.c ├── double-poll-crash.c ├── drop-submit.c ├── eeed8b54e0df.c ├── empty-eownerdead.c ├── eploop.c ├── epwait.c ├── eventfd-disable.c ├── eventfd-reg.c ├── eventfd-ring.c ├── eventfd.c ├── evloop.c ├── exec-target.c ├── exit-no-cleanup.c ├── fadvise.c ├── fallocate.c ├── fc2a85cb02ef.c ├── fd-install.c ├── fd-pass.c ├── fdinfo.c ├── fifo-nonblock-read.c ├── file-exit-unreg.c ├── file-register.c ├── file-update.c ├── file-verify.c ├── files-exit-hang-poll.c ├── files-exit-hang-timeout.c ├── fixed-buf-iter.c ├── fixed-buf-merge.c ├── fixed-hugepage.c ├── fixed-link.c ├── fixed-reuse.c ├── fixed-seg.c ├── fpos.c ├── fsnotify.c ├── fsync.c ├── futex.c ├── hardlink.c ├── helpers.c ├── helpers.h ├── ignore-single-mmap.c ├── init-mem.c ├── io-cancel.c ├── io_uring_enter.c ├── io_uring_passthrough.c ├── io_uring_register.c ├── io_uring_setup.c ├── iopoll-leak.c ├── iopoll-overflow.c ├── iopoll.c ├── iowait.c ├── kallsyms.c ├── lfs-openat-write.c ├── lfs-openat.c ├── link-timeout.c ├── link.c ├── link_drain.c ├── linked-defer-close.c ├── madvise.c ├── min-timeout-wait.c ├── min-timeout.c ├── mkdir.c ├── msg-ring-fd.c ├── msg-ring-flags.c ├── msg-ring-overflow.c ├── msg-ring.c ├── multicqes_drain.c ├── napi-test.c ├── napi-test.sh ├── no-mmap-inval.c ├── nolibc.c ├── nop-all-sizes.c ├── nop.c ├── nvme.h ├── ooo-file-unreg.c ├── open-close.c ├── open-direct-link.c ├── open-direct-pick.c ├── openat2.c ├── personality.c ├── pipe-bug.c ├── pipe-eof.c ├── pipe-reuse.c ├── poll-cancel-all.c ├── poll-cancel-ton.c ├── poll-cancel.c ├── poll-link.c ├── poll-many.c ├── poll-mshot-overflow.c ├── poll-mshot-update.c ├── poll-race-mshot.c ├── poll-race.c ├── poll-ring.c ├── poll-v-poll.c ├── poll.c ├── pollfree.c ├── probe.c ├── read-before-exit.c ├── read-inc-file.c ├── read-mshot-empty.c ├── read-mshot-stdin.c ├── read-mshot.c ├── read-write.c ├── recv-bundle-short-ooo.c ├── recv-msgall-stream.c ├── recv-msgall.c ├── recv-multishot.c ├── recvsend_bundle-inc.c ├── recvsend_bundle.c ├── reg-fd-only.c ├── reg-hint.c ├── reg-reg-ring.c ├── reg-wait.c ├── regbuf-clone.c ├── regbuf-merge.c ├── register-restrictions.c ├── rename.c ├── resize-rings.c ├── ring-leak.c ├── ring-leak2.c ├── ringbuf-read.c ├── ringbuf-status.c ├── rsrc_tags.c ├── runtests-loop.sh ├── runtests-quiet.sh ├── runtests.sh ├── rw_merge_test.c ├── self.c ├── send-zerocopy.c ├── send_recv.c ├── send_recvmsg.c ├── sendmsg_iov_clean.c ├── shared-wq.c ├── short-read.c ├── shutdown.c ├── sigfd-deadlock.c ├── single-issuer.c ├── skip-cqe.c ├── socket-getsetsock-cmd.c ├── socket-io-cmd.c ├── socket-nb.c ├── socket-rw-eagain.c ├── socket-rw-offset.c ├── socket-rw.c ├── socket.c ├── splice.c ├── sq-full-cpp.cc ├── sq-full.c ├── sq-poll-dup.c ├── sq-poll-kthread.c ├── sq-poll-share.c ├── sq-space_left.c ├── sqpoll-disable-exit.c ├── sqpoll-exec.c ├── sqpoll-exit-hang.c ├── sqpoll-sleep.c ├── sqwait.c ├── statx.c ├── stdout.c ├── submit-and-wait.c ├── submit-link-fail.c ├── submit-reuse.c ├── symlink.c ├── sync-cancel.c ├── teardowns.c ├── test.h ├── thread-exit.c ├── timeout-new.c ├── timeout.c ├── truncate.c ├── tty-write-dpoll.c ├── unlink.c ├── uring_cmd_ublk.c ├── vec-regbuf.c ├── version.c ├── wait-timeout.c ├── waitid.c ├── wakeup-hang.c ├── wq-aff.c ├── xattr.c ├── xfail_prep_link_timeout_out_of_scope.c ├── xfail_register_buffers_out_of_scope.c └── zcrx.c /.github/actions/codespell/stopwords: -------------------------------------------------------------------------------- 1 | bu 2 | cancelation 3 | cancelations 4 | cant 5 | pring 6 | sring 7 | wont 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.rej 2 | *.orig 3 | *~ 4 | /*.patch 5 | 6 | *.d 7 | *.o 8 | *.o[ls] 9 | 10 | /src/liburing.a 11 | /src/liburing.so* 12 | /src/liburing-ffi.a 13 | /src/liburing-ffi.so* 14 | /src/include/liburing/compat.h 15 | /src/include/liburing/io_uring_version.h 16 | 17 | /examples/io_uring-close-test 18 | /examples/io_uring-cp 19 | /examples/io_uring-test 20 | /examples/io_uring-udp 21 | /examples/link-cp 22 | /examples/napi-busy-poll-client 23 | /examples/napi-busy-poll-server 24 | /examples/ucontext-cp 25 | /examples/poll-bench 26 | /examples/proxy 27 | /examples/send-zerocopy 28 | /examples/rsrc-update-bench 29 | /examples/kdigest 30 | /examples/reg-wait 31 | /examples/zcrx 32 | 33 | /test/*.t 34 | /test/*.dmesg 35 | /test/output/ 36 | 37 | # Clang's compilation database file and directory. 38 | /.cache 39 | /compile_commands.json 40 | 41 | config-host.h 42 | config-host.mak 43 | config.log 44 | 45 | liburing.pc 46 | liburing-ffi.pc 47 | 48 | cscope.out 49 | -------------------------------------------------------------------------------- /CITATION.cff: -------------------------------------------------------------------------------- 1 | cff-version: 1.2.0 2 | preferred-citation: 3 | type: software 4 | authors: 5 | - family-names: "Axboe" 6 | given-names: "Jens" 7 | email: axboe@kernel.dk 8 | title: "liburing library for io_uring" 9 | year: 2022 10 | url: "https://github.com/axboe/liburing" 11 | licence: MIT 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 Jens Axboe 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a 4 | copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included 12 | in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /Makefile.common: -------------------------------------------------------------------------------- 1 | TOP := $(dir $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))) 2 | NAME=liburing 3 | SPECFILE=$(TOP)/$(NAME).spec 4 | VERSION=$(shell awk '/Version:/ { print $$2 }' $(SPECFILE)) 5 | VERSION_MAJOR=$(shell echo $(VERSION) | cut -d. -f1) 6 | VERSION_MINOR=$(shell echo $(VERSION) | cut -d. -f2) 7 | TAG = $(NAME)-$(VERSION) 8 | -------------------------------------------------------------------------------- /Makefile.quiet: -------------------------------------------------------------------------------- 1 | ifneq ($(findstring $(MAKEFLAGS),s),s) 2 | ifndef V 3 | QUIET_CC = @echo ' ' CC $@; 4 | QUIET_CXX = @echo ' ' CXX $@; 5 | QUIET_LINK = @echo ' ' LINK $@; 6 | QUIET_AR = @echo ' ' AR $@; 7 | QUIET_RANLIB = @echo '' RANLIB $@; 8 | endif 9 | endif 10 | 11 | 12 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Reporting a Vulnerability 4 | 5 | Please report any security issue to axboe@kernel.dk where the issue will be triaged appropriately. 6 | Thank you in advance for helping to keep liburing secure. 7 | -------------------------------------------------------------------------------- /debian/README.Debian: -------------------------------------------------------------------------------- 1 | liburing for Debian 2 | 3 | The newest Linux IO interface i.e. io_uring, need 4 | userspace library to support it. This package 5 | liburing is the library for io_uring. 6 | 7 | -- Liu Changcheng Thu, 14 Nov 2019 21:35:39 +0800 8 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | liburing (2.2-1) stable; urgency=low 2 | 3 | * Update to 2.2 4 | * Bump up so version to 2 5 | * Drop liburing1-udeb 6 | * Package using dh instead of using dh_* helpers manually 7 | * Add linux header dependency to liburing-dev 8 | * Bump up debhelper-compact level to 13 9 | 10 | -- Kefu Chai Sun, 16 Oct 2022 16:30:48 +0800 11 | 12 | liburing (0.7-1) stable; urgency=low 13 | 14 | * Update to 0.7 15 | * Fix library symlinks 16 | 17 | -- Stefan Metzmacher Thu, 23 Jul 2020 00:23:00 +0200 18 | 19 | liburing (0.4-2) stable; urgency=low 20 | 21 | * Fix /usr/lib/*/liburing.so symlink to /lib/*/liburing.so.1.0.4 22 | 23 | -- Stefan Metzmacher Fri, 07 Feb 2020 15:30:00 +0100 24 | 25 | liburing (0.4-1) stable; urgency=low 26 | 27 | * Package liburing-0.4 using a packaging layout similar to libaio1 28 | 29 | -- Stefan Metzmacher Thu, 06 Feb 2020 11:30:00 +0100 30 | 31 | liburing (0.2-1ubuntu1) stable; urgency=low 32 | 33 | * Initial release. 34 | * commit 4bce856d43ab1f9a64477aa5a8f9f02f53e64b74 35 | * Author: Jens Axboe 36 | * Date: Mon Nov 11 16:00:58 2019 -0700 37 | 38 | -- Liu Changcheng Fri, 15 Nov 2019 00:06:46 +0800 39 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: liburing 2 | Section: libs 3 | Priority: optional 4 | Maintainer: Liu Changcheng 5 | Build-Depends: 6 | debhelper-compat (= 13) 7 | Standards-Version: 4.1.4 8 | Homepage: https://git.kernel.dk/cgit/liburing/tree/README 9 | Vcs-Git: https://git.kernel.dk/liburing 10 | Vcs-Browser: https://git.kernel.dk/cgit/liburing/ 11 | 12 | Package: liburing2 13 | Architecture: linux-any 14 | Multi-Arch: same 15 | Pre-Depends: ${misc:Pre-Depends} 16 | Depends: ${misc:Depends}, ${shlibs:Depends} 17 | Description: userspace library for using io_uring 18 | io_uring is kernel feature to improve development 19 | The newese Linux IO interface, io_uring could improve 20 | system performance a lot. liburing is the userspace 21 | library to use io_uring feature. 22 | . 23 | This package contains the shared library. 24 | 25 | Package: liburing-dev 26 | Section: libdevel 27 | Architecture: linux-any 28 | Multi-Arch: same 29 | Depends: 30 | ${misc:Depends}, 31 | liburing2 (= ${binary:Version}), 32 | linux-libc-dev (>= 5.1) 33 | Description: userspace library for using io_uring 34 | io_uring is kernel feature to improve development 35 | The newese Linux IO interface, io_uring could improve 36 | system performance a lot. liburing is the userspace 37 | library to use io_uring feature. 38 | . 39 | This package contains the static library and the header files. 40 | -------------------------------------------------------------------------------- /debian/liburing-dev.install: -------------------------------------------------------------------------------- 1 | usr/include 2 | usr/lib/*/lib*.so 3 | usr/lib/*/lib*.a 4 | usr/lib/*/pkgconfig 5 | -------------------------------------------------------------------------------- /debian/liburing-dev.manpages: -------------------------------------------------------------------------------- 1 | usr/share/man/man2/io_uring_*.2 2 | usr/share/man/man3/io_uring_*.3 3 | usr/share/man/man7/io_uring.7 4 | usr/share/man/man3/IO_URING_*.3 5 | usr/share/man/man3/__io_uring_*.3 6 | -------------------------------------------------------------------------------- /debian/liburing2.install: -------------------------------------------------------------------------------- 1 | usr/lib/*/lib*.so.* 2 | -------------------------------------------------------------------------------- /debian/patches/series: -------------------------------------------------------------------------------- 1 | # You must remove unused comment lines for the released package. 2 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | # Uncomment this to turn on verbose mode. 4 | #export DH_VERBOSE=1 5 | 6 | DEB_BUILD_MAINT_OPTIONS = hardening=+bindnow 7 | DEB_CFLAGS_MAINT_PREPEND = -Wall 8 | DEB_BUILD_OPTIONS += nocheck 9 | 10 | include /usr/share/dpkg/default.mk 11 | include /usr/share/dpkg/buildtools.mk 12 | 13 | %: 14 | dh $@ --parallel 15 | 16 | override_dh_auto_configure: 17 | ./configure \ 18 | --prefix=/usr \ 19 | --includedir=/usr/include \ 20 | --datadir=/usr/share \ 21 | --mandir=/usr/share/man \ 22 | --libdir=/usr/lib/$(DEB_HOST_MULTIARCH) \ 23 | --libdevdir=/usr/lib/$(DEB_HOST_MULTIARCH) \ 24 | --cc=$(CC) 25 | 26 | override_dh_auto_test: 27 | ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) 28 | $(MAKE) runtests 29 | endif 30 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /debian/source/local-options: -------------------------------------------------------------------------------- 1 | #abort-on-upstream-changes 2 | #unapply-patches 3 | -------------------------------------------------------------------------------- /debian/source/options: -------------------------------------------------------------------------------- 1 | extend-diff-ignore = "(^|/)(config\.log|config-host\.h|config-host\.mak|liburing\.pc)$" 2 | -------------------------------------------------------------------------------- /debian/watch: -------------------------------------------------------------------------------- 1 | # Site Directory Pattern Version Script 2 | version=4 3 | https://git.kernel.dk/cgit/liburing/ snapshot\/liburing-([\d\.]+)\.tar\.(?:gz|xz) debian uupdate 4 | -------------------------------------------------------------------------------- /examples/Makefile: -------------------------------------------------------------------------------- 1 | CPPFLAGS ?= 2 | override CPPFLAGS += -D_GNU_SOURCE -I../src/include/ 3 | CFLAGS ?= -g -O2 -Wall 4 | LDFLAGS ?= 5 | override LDFLAGS += -L../src/ -luring 6 | 7 | include ../Makefile.quiet 8 | 9 | ifneq ($(MAKECMDGOALS),clean) 10 | include ../config-host.mak 11 | endif 12 | 13 | LDFLAGS ?= 14 | override LDFLAGS += -L../src/ -luring -lpthread 15 | 16 | ifeq ($(CONFIG_USE_SANITIZER),y) 17 | override CFLAGS += -fsanitize=address,undefined -fno-omit-frame-pointer -fno-optimize-sibling-calls 18 | override CPPFLAGS += -fsanitize=address,undefined -fno-omit-frame-pointer -fno-optimize-sibling-calls 19 | override LDFLAGS += -fsanitize=address,undefined 20 | endif 21 | 22 | example_srcs := \ 23 | io_uring-close-test.c \ 24 | io_uring-cp.c \ 25 | io_uring-test.c \ 26 | io_uring-udp.c \ 27 | link-cp.c \ 28 | napi-busy-poll-client.c \ 29 | napi-busy-poll-server.c \ 30 | poll-bench.c \ 31 | reg-wait.c \ 32 | send-zerocopy.c \ 33 | rsrc-update-bench.c \ 34 | proxy.c \ 35 | zcrx.c \ 36 | kdigest.c 37 | 38 | all_targets := 39 | 40 | 41 | ifdef CONFIG_HAVE_UCONTEXT 42 | example_srcs += ucontext-cp.c 43 | endif 44 | all_targets += ucontext-cp helpers.o 45 | 46 | example_targets := $(patsubst %.c,%,$(patsubst %.cc,%,$(example_srcs))) 47 | all_targets += $(example_targets) 48 | 49 | helpers = helpers.o 50 | 51 | all: $(example_targets) 52 | 53 | helpers.o: helpers.c 54 | $(QUIET_CC)$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $< 55 | 56 | %: %.c $(helpers) ../src/liburing.a 57 | $(QUIET_CC)$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< $(helpers) $(LDFLAGS) 58 | 59 | clean: 60 | @rm -f $(all_targets) 61 | 62 | .PHONY: all clean 63 | -------------------------------------------------------------------------------- /examples/helpers.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "helpers.h" 15 | 16 | int setup_listening_socket(int port, int ipv6) 17 | { 18 | struct sockaddr_in srv_addr = { }; 19 | struct sockaddr_in6 srv_addr6 = { }; 20 | int fd, enable, ret, domain; 21 | 22 | if (ipv6) 23 | domain = AF_INET6; 24 | else 25 | domain = AF_INET; 26 | 27 | fd = socket(domain, SOCK_STREAM, 0); 28 | if (fd == -1) { 29 | perror("socket()"); 30 | return -1; 31 | } 32 | 33 | enable = 1; 34 | ret = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int)); 35 | if (ret < 0) { 36 | perror("setsockopt(SO_REUSEADDR)"); 37 | return -1; 38 | } 39 | 40 | if (ipv6) { 41 | srv_addr6.sin6_family = AF_INET6; 42 | srv_addr6.sin6_port = htons(port); 43 | srv_addr6.sin6_addr = in6addr_any; 44 | ret = bind(fd, (const struct sockaddr *)&srv_addr6, sizeof(srv_addr6)); 45 | } else { 46 | srv_addr.sin_family = AF_INET; 47 | srv_addr.sin_port = htons(port); 48 | srv_addr.sin_addr.s_addr = htonl(INADDR_ANY); 49 | ret = bind(fd, (const struct sockaddr *)&srv_addr, sizeof(srv_addr)); 50 | } 51 | 52 | if (ret < 0) { 53 | perror("bind()"); 54 | return -1; 55 | } 56 | 57 | if (listen(fd, 1024) < 0) { 58 | perror("listen()"); 59 | return -1; 60 | } 61 | 62 | return fd; 63 | } 64 | 65 | void *aligned_alloc(size_t alignment, size_t size) 66 | { 67 | void *ret; 68 | 69 | if (posix_memalign(&ret, alignment, size)) 70 | return NULL; 71 | 72 | return ret; 73 | } 74 | 75 | void t_error(int status, int errnum, const char *format, ...) 76 | { 77 | va_list args; 78 | va_start(args, format); 79 | 80 | vfprintf(stderr, format, args); 81 | if (errnum) 82 | fprintf(stderr, ": %s", strerror(errnum)); 83 | 84 | fprintf(stderr, "\n"); 85 | va_end(args); 86 | exit(status); 87 | } 88 | -------------------------------------------------------------------------------- /examples/helpers.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | #ifndef LIBURING_EX_HELPERS_H 3 | #define LIBURING_EX_HELPERS_H 4 | 5 | #include 6 | 7 | #define T_ALIGN_UP(v, align) (((v) + (align) - 1) & ~((align) - 1)) 8 | 9 | int setup_listening_socket(int port, int ipv6); 10 | 11 | /* 12 | * Some Android versions lack aligned_alloc in stdlib.h. 13 | * To avoid making large changes in tests, define a helper 14 | * function that wraps posix_memalign as our own aligned_alloc. 15 | */ 16 | void *aligned_alloc(size_t alignment, size_t size); 17 | 18 | void t_error(int status, int errnum, const char *format, ...); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /liburing-ffi.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=${prefix} 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: @NAME@ 7 | Version: @VERSION@ 8 | Description: io_uring FFI library 9 | URL: https://git.kernel.dk/cgit/liburing/ 10 | 11 | Libs: -L${libdir} -luring-ffi 12 | Cflags: -I${includedir} 13 | -------------------------------------------------------------------------------- /liburing.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=${prefix} 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: @NAME@ 7 | Version: @VERSION@ 8 | Description: io_uring library 9 | URL: https://git.kernel.dk/cgit/liburing/ 10 | 11 | Libs: -L${libdir} -luring 12 | Cflags: -I${includedir} 13 | -------------------------------------------------------------------------------- /liburing.spec: -------------------------------------------------------------------------------- 1 | Name: liburing 2 | Version: 2.10 3 | Release: 1%{?dist} 4 | Summary: Linux-native io_uring I/O access library 5 | License: (GPLv2 with exceptions and LGPLv2+) or MIT 6 | Source0: https://brick.kernel.dk/snaps/%{name}-%{version}.tar.gz 7 | Source1: https://brick.kernel.dk/snaps/%{name}-%{version}.tar.gz.asc 8 | URL: https://git.kernel.dk/cgit/liburing/ 9 | BuildRequires: gcc 10 | BuildRequires: make 11 | 12 | %description 13 | Provides native async IO for the Linux kernel, in a fast and efficient 14 | manner, for both buffered and O_DIRECT. 15 | 16 | %package devel 17 | Summary: Development files for Linux-native io_uring I/O access library 18 | Requires: %{name}%{_isa} = %{version}-%{release} 19 | Requires: pkgconfig 20 | 21 | %description devel 22 | This package provides header files to include and libraries to link with 23 | for the Linux-native io_uring. 24 | 25 | %prep 26 | %autosetup 27 | 28 | %build 29 | %set_build_flags 30 | ./configure --prefix=%{_prefix} --libdir=%{_libdir} --libdevdir=%{_libdir} --mandir=%{_mandir} --includedir=%{_includedir} 31 | 32 | %make_build 33 | 34 | %install 35 | %make_install 36 | 37 | %files 38 | %attr(0755,root,root) %{_libdir}/liburing.so.* 39 | %license COPYING 40 | 41 | %files devel 42 | %{_includedir}/liburing/ 43 | %{_includedir}/liburing.h 44 | %{_libdir}/liburing.so 45 | %exclude %{_libdir}/liburing.a 46 | %{_libdir}/pkgconfig/* 47 | %{_mandir}/man2/* 48 | %{_mandir}/man3/* 49 | %{_mandir}/man7/* 50 | 51 | %changelog 52 | * Thu Oct 31 2019 Jeff Moyer - 0.2-1 53 | - Add io_uring_cq_ready() 54 | - Add io_uring_peek_batch_cqe() 55 | - Add io_uring_prep_accept() 56 | - Add io_uring_prep_{recv,send}msg() 57 | - Add io_uring_prep_timeout_remove() 58 | - Add io_uring_queue_init_params() 59 | - Add io_uring_register_files_update() 60 | - Add io_uring_sq_space_left() 61 | - Add io_uring_wait_cqe_timeout() 62 | - Add io_uring_wait_cqes() 63 | - Add io_uring_wait_cqes_timeout() 64 | 65 | * Tue Jan 8 2019 Jens Axboe - 0.1 66 | - Initial version 67 | -------------------------------------------------------------------------------- /make-debs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright (C) 2019 Liu Changcheng 3 | # Author: Liu Changcheng 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # as published by the Free Software Foundation; either version 2 8 | # of the License, or (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | # 18 | set -xe 19 | 20 | # Create dir for build 21 | base=${1:-/tmp/release} 22 | distro=unstable 23 | releasedir=$base/$(lsb_release -si)/liburing 24 | rm -rf $releasedir 25 | mkdir -p $releasedir 26 | HEAD=$(which head) 27 | DCH=$(which dch) 28 | 29 | src_dir=$(readlink -e `basename $0`) 30 | liburing_dir=$(dirname $src_dir) 31 | basename=$(basename $liburing_dir) 32 | dirname=$(dirname $liburing_dir) 33 | version=$(git describe --match "lib*" | cut -d '-' -f 2) 34 | outfile="liburing-$version" 35 | orgfile=$(echo $outfile | tr '-' '_') 36 | 37 | # Prepare source code 38 | cp -arf ${dirname}/${basename} ${releasedir}/${outfile} 39 | cd ${releasedir}/${outfile} 40 | git clean -dxf 41 | 42 | # Change changelog if it's needed 43 | cur_ver=`$HEAD < debian/changelog | sed -n -e 's/.* (\(.*\)) .*/\1/p'` 44 | if [ "$cur_ver" != "$version-1" ]; then 45 | $DCH -D $distro --force-distribution -b -v "$version-1" "new version" 46 | fi 47 | 48 | # Create tar archive 49 | cd ../ 50 | tar cvzf ${outfile}.tar.gz ${outfile} 51 | ln -s ${outfile}.tar.gz ${orgfile}.orig.tar.gz 52 | 53 | # Build debian package 54 | cd - 55 | debuild 56 | -------------------------------------------------------------------------------- /man/IO_URING_CHECK_VERSION.3: -------------------------------------------------------------------------------- 1 | io_uring_check_version.3 -------------------------------------------------------------------------------- /man/IO_URING_VERSION_MAJOR.3: -------------------------------------------------------------------------------- 1 | io_uring_check_version.3 -------------------------------------------------------------------------------- /man/IO_URING_VERSION_MINOR.3: -------------------------------------------------------------------------------- 1 | io_uring_check_version.3 -------------------------------------------------------------------------------- /man/__io_uring_buf_ring_cq_advance.3: -------------------------------------------------------------------------------- 1 | io_uring_buf_ring_cq_advance.3 -------------------------------------------------------------------------------- /man/io_uring_buf_ring_advance.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Jens Axboe 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_buf_ring_advance 3 "May 18, 2022" "liburing-2.2" "liburing Manual" 6 | .SH NAME 7 | io_uring_buf_ring_advance \- advance index of provided buffer in buffer ring 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "void io_uring_buf_ring_advance(struct io_uring_buf_ring *" br ", 13 | .BI " int " count ");" 14 | .fi 15 | .SH DESCRIPTION 16 | .PP 17 | The 18 | .BR io_uring_buf_ring_advance (3) 19 | commits 20 | .I count 21 | previously added buffers to the shared buffer ring 22 | .IR br , 23 | making them visible to the kernel and hence consumable. This passes ownership 24 | of the buffer to the ring. 25 | 26 | .SH RETURN VALUE 27 | None 28 | .SH SEE ALSO 29 | .BR io_uring_register_buf_ring (3), 30 | .BR io_uring_buf_ring_add (3), 31 | .BR io_uring_buf_ring_cq_advance (3) 32 | -------------------------------------------------------------------------------- /man/io_uring_buf_ring_available.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Jens Axboe 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_buf_ring_available 3 "Jan 11, 2024" "liburing-2.6" "liburing Manual" 6 | .SH NAME 7 | io_uring_buf_ring_available \- return number of unconsumed provided ring buffer entries 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "int io_uring_buf_ring_available(struct io_uring *" ring ", 13 | .BI " struct io_uring_buf_ring *" br ", 14 | .BI " unsigned short " bgid ");" 15 | .fi 16 | .SH DESCRIPTION 17 | .PP 18 | The 19 | .BR io_uring_buf_ring_available (3) 20 | helper returns the number of unconsumed (by the kernel) entries in the 21 | .IR br 22 | provided buffer group belonging to the io_uring 23 | .IR ring 24 | and identified by the buffer group ID 25 | .IR bgid. 26 | 27 | Since the head of the provided buffer ring is only visible to the kernel, it's 28 | impossible to otherwise know how many unconsumed entries exist in the given 29 | provided buffer ring. This function query the kernel to return that number. 30 | Available since kernel 6.8. 31 | 32 | .SH NOTES 33 | The returned number of entries reflect the amount of unconsumed entries at the 34 | time that it was queried. If inflight IO exists that may consume provided 35 | buffers from this buffer group, then the returned value is inherently racy. 36 | .SH RETURN VALUE 37 | Returns the number of unconsumed entries on success, which may be 0. In case 38 | of error, may return 39 | .BR -ENOENT 40 | if the specified buffer group doesn't exist, or 41 | .BR -EINVAL 42 | if the buffer group isn't of the correct type, or if the kernel doesn't 43 | support this feature. 44 | .SH SEE ALSO 45 | .BR io_uring_register_buf_ring (3), 46 | .BR io_uring_buf_ring_add (3), 47 | .BR io_uring_buf_ring_cq_advance (3) 48 | -------------------------------------------------------------------------------- /man/io_uring_buf_ring_cq_advance.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Jens Axboe 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_buf_ring_cq_advance 3 "May 18, 2022" "liburing-2.2" "liburing Manual" 6 | .SH NAME 7 | io_uring_buf_ring_cq_advance \- advance index of provided buffer and CQ ring 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "void io_uring_buf_ring_cq_advance(struct io_uring *" ring ", 13 | .BI " struct io_uring_buf_ring *" br ", 14 | .BI " int " count ");" 15 | .PP 16 | .BI "void __io_uring_buf_ring_cq_advance(struct io_uring *" ring ", 17 | .BI " struct io_uring_buf_ring *" br ", 18 | .BI " int " cq_count ", 19 | .BI " int " buf_count ");" 20 | .fi 21 | .SH DESCRIPTION 22 | .PP 23 | The 24 | .BR io_uring_buf_ring_cq_advance (3) 25 | commits 26 | .I count 27 | previously added buffers to the shared buffer ring 28 | .IR br , 29 | making them visible to the kernel and hence consumable. This passes ownership 30 | of the buffer to the ring. At the same time, it advances the CQ ring of 31 | .I ring 32 | by 33 | .I count 34 | amount. This effectively bundles both a 35 | .BR io_uring_buf_ring_advance (3) 36 | call and a 37 | .BR io_uring_cq_advance (3) 38 | into one operation. Since updating either ring index entails a store memory 39 | barrier, doing both at once is more efficient. 40 | 41 | The 42 | .BR __io_uring_buf_ring_cq_advance (3) 43 | function performs the same operation, except it splits the counts into two 44 | separate values. It advances the CQ ring by 45 | .I cq_count 46 | entries, and the buffer ring by 47 | .I buf_count 48 | entries rather than increment both by the same value. 49 | 50 | .SH RETURN VALUE 51 | None 52 | .SH SEE ALSO 53 | .BR io_uring_register_buf_ring (3), 54 | .BR io_uring_buf_ring_add (3), 55 | .BR io_uring_buf_ring_advance (3) 56 | -------------------------------------------------------------------------------- /man/io_uring_buf_ring_init.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Dylan Yudaken 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_buf_ring_init 3 "June 13, 2022" "liburing-2.2" "liburing Manual" 6 | .SH NAME 7 | io_uring_buf_ring_init \- Initialise a buffer ring 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "void io_uring_buf_ring_init(struct io_uring_buf_ring *" br ");" 13 | .fi 14 | .SH DESCRIPTION 15 | .PP 16 | .BR io_uring_buf_ring_init (3) 17 | initialises 18 | .IR br 19 | so that it is ready to be used. It may be called after 20 | .BR io_uring_register_buf_ring (3) 21 | but must be called before the buffer ring is used in any other way. 22 | 23 | .SH RETURN VALUE 24 | None 25 | 26 | .SH NOTES 27 | Unless manual setup is needed, it's recommended to use 28 | .BR io_uring_setup_buf_ring (3) 29 | as it provides a simpler way to setup a provided buffer ring. 30 | . 31 | .SH SEE ALSO 32 | .BR io_uring_register_buf_ring (3), 33 | .BR io_uring_setup_buf_ring (3), 34 | .BR io_uring_buf_ring_add (3) 35 | .BR io_uring_buf_ring_advance (3), 36 | .BR io_uring_buf_ring_cq_advance (3) 37 | -------------------------------------------------------------------------------- /man/io_uring_buf_ring_mask.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Dylan Yudaken 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_buf_ring_mask 3 "June 13, 2022" "liburing-2.2" "liburing Manual" 6 | .SH NAME 7 | io_uring_buf_ring_mask \- Calculate buffer ring mask size 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "int io_uring_buf_ring_mask(__u32 " ring_entries ");" 13 | .fi 14 | .SH DESCRIPTION 15 | .PP 16 | .BR io_uring_buf_ring_mask (3) 17 | calculates the appropriate size mask for a buffer ring. 18 | .IR ring_entries 19 | is the ring entries as specified in 20 | .BR io_uring_register_buf_ring (3) . 21 | 22 | .SH RETURN VALUE 23 | Size mask for the buffer ring. 24 | 25 | .SH SEE ALSO 26 | .BR io_uring_register_buf_ring (3), 27 | .BR io_uring_buf_ring_add (3) 28 | -------------------------------------------------------------------------------- /man/io_uring_check_version.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Christian Hergert 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_check_version 3 "December 1, 2022" "liburing-2.4" "liburing Manual" 6 | .SH NAME 7 | io_uring_check_version \- functions and macros to check the liburing version 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "bool io_uring_check_version(int " major ", int " minor ");" 13 | .BI "IO_URING_CHECK_VERSION(" major ", " minor ");" 14 | .PP 15 | .BI "int io_uring_major_version(void);" 16 | .BI "IO_URING_VERSION_MAJOR;" 17 | .PP 18 | .BI "int io_uring_minor_version(void);" 19 | .BI "IO_URING_VERSION_MINOR;" 20 | .fi 21 | .SH DESCRIPTION 22 | .PP 23 | The 24 | .BR io_uring_check_version (3) 25 | function returns 26 | .I false 27 | if the liburing library loaded by the dynamic linker is greater-than 28 | or equal-to the 29 | .I major 30 | and 31 | .I minor 32 | numbers provided. 33 | 34 | .PP 35 | The 36 | .BR IO_URING_CHECK_VERSION (3) 37 | macro returns 38 | .I 0 39 | if the liburing library being compiled against is greater-than or equal-to the 40 | .I major 41 | and 42 | .I minor 43 | numbers provided. 44 | 45 | .PP 46 | The 47 | .BR io_uring_major_version (3) 48 | function returns the 49 | .I major 50 | version number of the liburing library loaded by the dynamic linker. 51 | 52 | .PP 53 | The 54 | .BR IO_URING_VERSION_MAJOR (3) 55 | macro returns the 56 | .I major 57 | version number of the liburing library being compiled against. 58 | 59 | .PP 60 | The 61 | .BR io_uring_minor_version (3) 62 | function returns the 63 | .I minor 64 | version number of the liburing library loaded by the dynamic linker. 65 | 66 | .PP 67 | The 68 | .BR IO_URING_VERSION_MINOR (3) 69 | macro returns the 70 | .I minor 71 | version number of the liburing library being compiled against. 72 | 73 | -------------------------------------------------------------------------------- /man/io_uring_clone_buffers_offset.3: -------------------------------------------------------------------------------- 1 | io_uring_clone_buffers.3 -------------------------------------------------------------------------------- /man/io_uring_close_ring_fd.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Jens Axboe 2 | .\" Copyright (C) 2022 Josh Triplett 3 | .\" 4 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 5 | .\" 6 | .TH io_uring_close_ring_fd 3 "September 25, 2022" "liburing-2.4" "liburing Manual" 7 | .SH NAME 8 | io_uring_close_ring_fd \- close a ring file descriptor and use it only via registered index 9 | .SH SYNOPSIS 10 | .nf 11 | .B #include 12 | .PP 13 | .BI "int io_uring_close_ring_fd(struct io_uring *" ring ");" 14 | .fi 15 | .SH DESCRIPTION 16 | .PP 17 | .BR io_uring_close_ring_fd (3) 18 | closes the ring file descriptor, which must have been previously registered. 19 | The file will remain open, but accessible only via the registered index, not 20 | via any file descriptor. Subsequent liburing calls will continue to work, using 21 | the registered ring fd. 22 | 23 | The kernel must support 24 | .BR IORING_FEAT_REG_REG_RING . 25 | 26 | Libraries that must avoid disrupting their users' uses of file descriptors, and 27 | must continue working even in the face of 28 | .BR close_range (2) 29 | and similar, can use 30 | .BR io_uring_close_ring_fd (3) 31 | to work with liburing without having any open file descriptor. 32 | 33 | .SH NOTES 34 | Each thread that wants to make use of io_uring must register the fd. A library 35 | that may get called from arbitrary theads may need to detect when it gets 36 | called on a previously unseen thread and create and register a ring for that 37 | thread. 38 | .SH RETURN VALUE 39 | Returns 1 on success, or 40 | .BR -errno 41 | on error. 42 | .SH SEE ALSO 43 | .BR io_uring_register_ring_fd (3) 44 | -------------------------------------------------------------------------------- /man/io_uring_cq_advance.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Stefan Roesch 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_cq_advance 3 "January 25, 2022" "liburing-2.1" "liburing Manual" 6 | .SH NAME 7 | io_uring_cq_advance \- mark one or more io_uring completion events as consumed 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "void io_uring_cq_advance(struct io_uring *" ring "," 13 | .BI " unsigned " nr ");" 14 | .fi 15 | .SH DESCRIPTION 16 | .PP 17 | The 18 | .BR io_uring_cq_advance (3) 19 | function marks 20 | .I nr 21 | IO completions belonging to the 22 | .I ring 23 | param as consumed. 24 | 25 | After the caller has submitted a request with 26 | .BR io_uring_submit (3), 27 | the application can retrieve the completion with 28 | .BR io_uring_wait_cqe (3), 29 | .BR io_uring_peek_cqe (3), 30 | or any of the other CQE retrieval helpers, and mark it as consumed with 31 | .BR io_uring_cqe_seen (3). 32 | 33 | The function 34 | .BR io_uring_cqe_seen (3) 35 | calls the function 36 | .BR io_uring_cq_advance (3). 37 | 38 | Completions must be marked as seen, so their slot can get reused. Failure to do 39 | so will result in the same completion being returned on the next invocation. 40 | 41 | .SH RETURN VALUE 42 | None 43 | .SH SEE ALSO 44 | .BR io_uring_submit (3), 45 | .BR io_uring_wait_cqe (3), 46 | .BR io_uring_peek_cqe (3), 47 | .BR io_uring_wait_cqes (3), 48 | .BR io_uring_wait_cqe_timeout (3), 49 | .BR io_uring_cqe_seen (3) 50 | -------------------------------------------------------------------------------- /man/io_uring_cq_has_overflow.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Dylan Yudaken 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_cq_has_overflow 3 "September 5, 2022" "liburing-2.3" "liburing Manual" 6 | .SH NAME 7 | io_uring_cq_has_overflow \- returns if there are overflow entries waiting to move to the CQ ring 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "bool io_uring_cq_has_overflow(const struct io_uring *" ring ");" 13 | .fi 14 | .SH DESCRIPTION 15 | .PP 16 | The 17 | .BR io_uring_cq_has_overflow (3) 18 | function informs the application if CQ entries have overflowed and are waiting to be flushed to 19 | the CQ ring. For example using 20 | .BR io_uring_get_events (3) 21 | .SH NOTES 22 | Using this function is only valid if the ring has 23 | .B IORING_FEAT_NODROP 24 | set, as it's checking for a flag set by kernels supporting that feature. For 25 | really old kernels that don't support this feature, if CQE overflow is 26 | experienced the CQEs are lost. If that happens, the CQ ring overflow offset 27 | will get incremented. 28 | .SH RETURN VALUE 29 | True if there are CQ entries waiting to be flushed to the CQ ring. 30 | .SH SEE ALSO 31 | .BR io_uring_get_events (3) 32 | -------------------------------------------------------------------------------- /man/io_uring_cq_ready.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Stefan Roesch 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_cq_ready 3 "January 25, 2022" "liburing-2.1" "liburing Manual" 6 | .SH NAME 7 | io_uring_cq_ready \- returns number of unconsumed ready entries in the CQ ring 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "unsigned io_uring_cq_ready(const struct io_uring *" ring ");" 13 | .fi 14 | .SH DESCRIPTION 15 | .PP 16 | The 17 | .BR io_uring_cq_ready (3) 18 | function returns the number of unconsumed entries that are ready belonging to the 19 | .I ring 20 | param. 21 | 22 | .SH RETURN VALUE 23 | Returns the number of unconsumed ready entries in the CQ ring. 24 | .SH SEE ALSO 25 | .BR io_uring_submit (3), 26 | .BR io_uring_wait_cqe (3) 27 | -------------------------------------------------------------------------------- /man/io_uring_cqe_get_data.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2021 Stefan Roesch 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_cqe_get_data 3 "November 15, 2021" "liburing-2.1" "liburing Manual" 6 | .SH NAME 7 | io_uring_cqe_get_data \- get user data for completion event 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "void *io_uring_cqe_get_data(struct io_uring_cqe *" cqe ");" 13 | .BI " 14 | .BI "__u64 io_uring_cqe_get_data64(struct io_uring_cqe *" cqe ");" 15 | .fi 16 | .SH DESCRIPTION 17 | .PP 18 | The 19 | .BR io_uring_cqe_get_data (3) 20 | function returns the user_data with the completion queue entry 21 | .IR cqe 22 | as a data pointer. 23 | 24 | The 25 | .BR io_uring_cqe_get_data64 (3) 26 | function returns the user_data with the completion queue entry 27 | .IR cqe 28 | as a 64-bit data value. 29 | 30 | After the caller has received a completion queue entry (CQE) with 31 | .BR io_uring_wait_cqe (3), 32 | the application can call 33 | .BR io_uring_cqe_get_data (3) 34 | or 35 | .BR io_uring_cqe_get_data64 (3) 36 | function to retrieve the 37 | .I user_data 38 | value. This requires that 39 | .I user_data 40 | has been set earlier with the function 41 | .BR io_uring_sqe_set_data (3) 42 | or 43 | .BR io_uring_sqe_set_data64 (3). 44 | 45 | .SH RETURN VALUE 46 | If the 47 | .I user_data 48 | value has been set before submitting the request, it will be returned. 49 | Otherwise, the return value is undefined. 50 | .SH SEE ALSO 51 | .BR io_uring_get_sqe (3), 52 | .BR io_uring_sqe_set_data (3), 53 | .BR io_uring_sqe_submit (3) 54 | -------------------------------------------------------------------------------- /man/io_uring_cqe_get_data64.3: -------------------------------------------------------------------------------- 1 | io_uring_cqe_get_data.3 -------------------------------------------------------------------------------- /man/io_uring_cqe_seen.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2021 Stefan Roesch 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_cqe_seen 3 "November 15, 2021" "liburing-2.1" "liburing Manual" 6 | .SH NAME 7 | io_uring_cqe_seen \- mark io_uring completion event as consumed 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "void io_uring_cqe_seen(struct io_uring *" ring "," 13 | .BI " struct io_uring_cqe *" cqe ");" 14 | .fi 15 | .SH DESCRIPTION 16 | .PP 17 | The 18 | .BR io_uring_cqe_seen (3) 19 | function marks the IO completion 20 | .I cqe 21 | belonging to the 22 | .I ring 23 | param as consumed. 24 | 25 | After the caller has submitted a request with 26 | .BR io_uring_submit (3), 27 | the application can retrieve the completion with 28 | .BR io_uring_wait_cqe (3), 29 | .BR io_uring_peek_cqe (3), 30 | or any of the other CQE retrieval helpers, and mark it as consumed with 31 | .BR io_uring_cqe_seen (3). 32 | 33 | Completions must be marked as completed so their slot can get reused. 34 | .SH RETURN VALUE 35 | None 36 | .SH SEE ALSO 37 | .BR io_uring_submit (3), 38 | .BR io_uring_peek_cqe (3), 39 | .BR io_uring_wait_cqe (3), 40 | .BR io_uring_wait_cqes (3), 41 | .BR io_uring_wait_cqe_timeout (3) 42 | -------------------------------------------------------------------------------- /man/io_uring_enable_rings.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2023 nick black 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_enable_rings 3 "July 26, 2024" "liburing-2.7" "liburing Manual" 6 | .SH NAME 7 | io_uring_enable_rings \- enable a disabled ring 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "int io_uring_enable_rings(struct io_uring *" ring ");" 13 | .fi 14 | .SH DESCRIPTION 15 | .PP 16 | The 17 | .BR io_uring_enable_rings (3) 18 | function enables a ring after having created it with the 19 | .B IORING_SETUP_R_DISABLED 20 | flag to 21 | .BR io_uring_queue_init (3) 22 | 23 | It is not possible to submit work to such a ring until this 24 | function has been successfully called. 25 | 26 | .SH RETURN VALUE 27 | .BR io_uring_enable_rings (3) 28 | returns 0 on success. It otherwise returns a negative error code. 29 | It does not write to 30 | .BR errno . 31 | 32 | .SH ERRORS 33 | .TP 34 | .B EBADFD 35 | The ring was not disabled. 36 | 37 | .SH SEE ALSO 38 | .BR io_uring_queue_init (3), 39 | .BR io_uring_register (2), 40 | .BR io_uring_setup (2) 41 | -------------------------------------------------------------------------------- /man/io_uring_enter2.2: -------------------------------------------------------------------------------- 1 | io_uring_enter.2 -------------------------------------------------------------------------------- /man/io_uring_for_each_cqe.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2023 Jens Axboe 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_for_each_cqe 3 "June 04, 2023" "liburing-2.4" "liburing Manual" 6 | .SH NAME 7 | io_uring_for_each_cqe \- iterate pending completion events 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "io_uring_for_each_cqe(struct io_uring *" ring "," 13 | .BI " unsigned " head "," 14 | .BI " struct io_uring_cqe *" cqe ") { } 15 | .fi 16 | .SH DESCRIPTION 17 | .PP 18 | The 19 | .BR io_uring_for_each_cqe (3) 20 | is a macro helper that iterates completion events belonging to the 21 | .I ring 22 | using 23 | .I head 24 | as a temporary iterator, and points 25 | .I cqe 26 | to each pending event when iterating. 27 | 28 | This helper provides an efficient way to iterate all pending events in 29 | the ring, and then advancing the CQ ring by calling 30 | .BR io_uring_cq_advance (3) 31 | with the number of CQEs consumed when done. As updating the kernel visible 32 | CQ ring state involves an ordered write, doing it once for a number of 33 | events is more efficient than handling each completion separately and 34 | calling 35 | .BR io_uring_cqe_seen (3) 36 | for each of them. 37 | 38 | .SH EXAMPLE 39 | .EX 40 | void handle_cqes(struct io_uring *ring) 41 | { 42 | struct io_uring_cqe *cqe; 43 | unsigned head; 44 | unsigned i = 0; 45 | 46 | io_uring_for_each_cqe(ring, head, cqe) { 47 | /* handle completion */ 48 | printf("cqe: %d\\n", cqe->res); 49 | i++; 50 | } 51 | 52 | io_uring_cq_advance(ring, i); 53 | } 54 | .EE 55 | 56 | .SH RETURN VALUE 57 | None 58 | .SH SEE ALSO 59 | .BR io_uring_wait_cqe_timeout (3), 60 | .BR io_uring_wait_cqe (3), 61 | .BR io_uring_wait_cqes (3), 62 | .BR io_uring_cqe_seen (3), 63 | .BR io_uring_buf_ring_cq_advance (3) 64 | -------------------------------------------------------------------------------- /man/io_uring_free_buf_ring.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Jens Axboe 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_free_buf_ring 3 "Mar 07, 2023" "liburing-2.4" "liburing Manual" 6 | .SH NAME 7 | io_uring_free_buf_ring \- register and free a buffer ring for provided buffers 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "int io_uring_free_buf_ring(struct io_uring *" ring ", 13 | .BI " struct io_uring_buf_ring *" br ", 14 | .BI " unsigned int " nentries ", 15 | .BI " int " bgid ");" 16 | .BI " 17 | .fi 18 | .SH DESCRIPTION 19 | .PP 20 | The 21 | .BR io_uring_free_buf_ring (3) 22 | function unregisters a previously registered shared buffer ring. The ring must 23 | have heen previously returned from 24 | .BR io_uring_setup_buf_ring (3) . 25 | 26 | The 27 | .I ring 28 | argument must pointer to the ring for which the provided buffer ring is being 29 | registered, 30 | .I br 31 | must point to a buffer ring previously returned by 32 | .BR io_uring_setup_buf_ring (3) , 33 | .I nentries 34 | is the number of entries requested in the buffer ring, and 35 | .I bgid 36 | is the buffer group ID that 37 | .I br 38 | was setup with. 39 | 40 | Under the covers, this function uses 41 | .BR io_uring_unregister_buf_ring (3) 42 | to unregister the ring, and handles the freeing of the ring rather than 43 | letting the application open code it. 44 | 45 | Available since 5.19. 46 | 47 | .SH RETURN VALUE 48 | On success 49 | .BR io_uring_free_buf_ring (3) 50 | returns zero. On failure it returns 51 | .BR -errno . 52 | .SH SEE ALSO 53 | .BR io_uring_setup_buf_ring (3) 54 | -------------------------------------------------------------------------------- /man/io_uring_free_probe.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Stefan Roesch 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_free_probe 3 "January 25, 2022" "liburing-2.1" "liburing Manual" 6 | .SH NAME 7 | io_uring_free_probe \- free probe instance 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "void io_uring_free_probe(struct io_uring_probe *" probe ");" 13 | .fi 14 | .SH DESCRIPTION 15 | .PP 16 | The function 17 | .BR io_uring_free_probe (3) 18 | frees the 19 | .I probe 20 | instance allocated with the 21 | .BR io_uring_get_probe (3) 22 | function. 23 | 24 | .SH RETURN VALUE 25 | None 26 | .SH SEE ALSO 27 | .BR io_uring_get_probe (3) 28 | -------------------------------------------------------------------------------- /man/io_uring_free_reg_wait.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2024 Jens Axboe 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_free_reg_wait 3 "November 2, 2024" "liburing-2.9" "liburing Manual" 6 | .SH NAME 7 | io_uring_free_reg_wait \- Frees a previously registered wait region 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "void io_uring_free_reg_wait(struct io_uring *" ring "," 13 | .BI " unsigned " nentries ");" 14 | .PP 15 | .fi 16 | .SH DESCRIPTION 17 | .PP 18 | The 19 | .BR io_uring_free_reg_wait (3) 20 | function frees a wait region for the ring 21 | .IR ring 22 | of 23 | .IR nentries 24 | previously setup with 25 | .BR io_uring_setup_reg_wait (3) . 26 | As registered wait regions persist for the life time of the ring, on the 27 | kernel side the wait regions still remain active, and may in fact still 28 | be used by the application for wait operations. They may just no longer 29 | be modified by the application. 30 | 31 | Available since kernel 6.13. 32 | 33 | .SH SEE ALSO 34 | .BR io_uring_submit_and_wait_reg (3), 35 | .BR io_uring_free_reg_wait (3) 36 | -------------------------------------------------------------------------------- /man/io_uring_get_events.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Dylan Yudaken 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_get_events 3 "September 5, 2022" "liburing-2.3" "liburing Manual" 6 | .SH NAME 7 | io_uring_get_events \- Flush outstanding requests to CQE ring 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "int io_uring_get_events(struct io_uring *" ring ");" 13 | .fi 14 | .SH DESCRIPTION 15 | .PP 16 | The 17 | .BR io_uring_get_events (3) 18 | function runs outstanding work and flushes completion events to the CQE ring. 19 | 20 | There can be events needing to be flushed if the ring was full and had overflowed. 21 | Alternatively if the ring was setup with the 22 | .BR IORING_SETUP_DEFER_TASKRUN 23 | flag then this will process outstanding tasks, possibly resulting in more CQEs. 24 | 25 | .SH RETURN VALUE 26 | On success 27 | .BR io_uring_get_events (3) 28 | returns 0. On failure it returns 29 | .BR -errno . 30 | .SH SEE ALSO 31 | .BR io_uring_get_sqe (3), 32 | .BR io_uring_submit_and_get_events (3), 33 | .BR io_uring_cq_has_overflow (3) 34 | -------------------------------------------------------------------------------- /man/io_uring_get_probe.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Stefan Roesch 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_get_probe 3 "January 25, 2022" "liburing-2.1" "liburing Manual" 6 | .SH NAME 7 | io_uring_get_probe \- get probe instance 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "io_uring_probe *io_uring_get_probe(void);" 13 | .fi 14 | .SH DESCRIPTION 15 | .PP 16 | The function 17 | .BR io_uring_get_probe (3) 18 | returns an allocated io_uring_probe structure to the caller. The caller is 19 | responsible for freeing the structure with the function 20 | .BR io_uring_free_probe (3). 21 | 22 | .SH NOTES 23 | Earlier versions of the Linux kernel do not support probe. If the kernel 24 | doesn't support probe, this function will return NULL. 25 | 26 | .SH RETURN VALUE 27 | On success it returns an allocated io_uring_probe structure, otherwise 28 | it returns NULL. 29 | .SH SEE ALSO 30 | .BR io_uring_free_probe (3) 31 | -------------------------------------------------------------------------------- /man/io_uring_get_sqe.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2020 Jens Axboe 2 | .\" Copyright (C) 2020 Red Hat, Inc. 3 | .\" 4 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 5 | .\" 6 | .TH io_uring_get_sqe 3 "July 10, 2020" "liburing-0.7" "liburing Manual" 7 | .SH NAME 8 | io_uring_get_sqe \- get the next available submission queue entry from the 9 | submission queue 10 | .SH SYNOPSIS 11 | .nf 12 | .B #include 13 | .PP 14 | .BI "struct io_uring_sqe *io_uring_get_sqe(struct io_uring *" ring ");" 15 | .fi 16 | .SH DESCRIPTION 17 | .PP 18 | The 19 | .BR io_uring_get_sqe (3) 20 | function gets the next available submission queue entry from the submission 21 | queue belonging to the 22 | .I ring 23 | param. 24 | 25 | On success 26 | .BR io_uring_get_sqe (3) 27 | returns a pointer to the submission queue entry. On failure NULL is returned. 28 | 29 | If a submission queue entry is returned, it should be filled out via one of the 30 | prep functions such as 31 | .BR io_uring_prep_read (3) 32 | and submitted via 33 | .BR io_uring_submit (3). 34 | 35 | Note that neither 36 | .BR io_uring_get_sqe 37 | nor the prep functions set (or clear) the 38 | .B user_data 39 | field of the SQE. If the caller expects 40 | .BR io_uring_cqe_get_data (3) 41 | or 42 | .BR io_uring_cqe_get_data64 (3) 43 | to return valid data when reaping IO completions, either 44 | .BR io_uring_sqe_set_data (3) 45 | or 46 | .BR io_uring_sqe_set_data64 (3) 47 | .B MUST 48 | have been called before submitting the request. 49 | 50 | .SH RETURN VALUE 51 | .BR io_uring_get_sqe (3) 52 | returns a pointer to the next submission queue event on success and NULL on 53 | failure. If NULL is returned, the SQ ring is currently full and entries must 54 | be submitted for processing before new ones can get allocated. 55 | .SH SEE ALSO 56 | .BR io_uring_submit (3), 57 | .BR io_uring_sqe_set_data (3) 58 | -------------------------------------------------------------------------------- /man/io_uring_major_version.3: -------------------------------------------------------------------------------- 1 | io_uring_check_version.3 -------------------------------------------------------------------------------- /man/io_uring_minor_version.3: -------------------------------------------------------------------------------- 1 | io_uring_check_version.3 -------------------------------------------------------------------------------- /man/io_uring_opcode_supported.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Stefan Roesch 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_opcode_supported 3 "January 25, 2022" "liburing-2.1" "liburing Manual" 6 | .SH NAME 7 | io_uring_opcode_supported \- is op code supported? 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "int io_uring_opcode_supported(struct io_uring_probe *" probe "," 13 | .BI " int " opcode ");" 14 | .fi 15 | .SH DESCRIPTION 16 | .PP 17 | The function 18 | .BR io_uring_opcode_supported (3) 19 | allows the caller to determine if the passed in 20 | .I opcode 21 | belonging to the 22 | .I probe 23 | param is supported. An instance of the io_uring_probe instance can be 24 | obtained by calling the function 25 | .BR io_uring_get_probe (3). 26 | 27 | .SH RETURN VALUE 28 | On success it returns 1, otherwise it returns 0. 29 | .SH SEE ALSO 30 | .BR io_uring_get_probe (3) 31 | -------------------------------------------------------------------------------- /man/io_uring_peek_batch_cqe.3: -------------------------------------------------------------------------------- 1 | io_uring_peek_cqe.3 -------------------------------------------------------------------------------- /man/io_uring_peek_cqe.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Jens Axboe 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_peek_cqe 3 "March 12, 2022" "liburing-2.2" "liburing Manual" 6 | .SH NAME 7 | io_uring_peek_cqe \- check if an io_uring completion event is available 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "int io_uring_peek_cqe(struct io_uring *" ring "," 13 | .BI " struct io_uring_cqe **" cqe_ptr ");" 14 | .PP 15 | .BI "unsigned io_uring_peek_batch_cqe(struct io_uring *" ring "," 16 | .BI " struct io_uring_cqe **" cqe_ptrs "," 17 | .BI " unsigned " count ");" 18 | .fi 19 | .SH DESCRIPTION 20 | .PP 21 | The 22 | .BR io_uring_peek_cqe (3) 23 | function returns an IO completion from the queue belonging to the 24 | .I ring 25 | param, if one is readily available. On successful return, 26 | .I cqe_ptr 27 | param is filled with a valid CQE entry. 28 | 29 | This function does not enter the kernel to wait for an event, an event 30 | is only returned if it's already available in the CQ ring. 31 | 32 | The 33 | .BR io_uring_peek_batch_cqe (3) 34 | function returns up to 35 | .I count 36 | request completions in 37 | .I cqe_ptrs 38 | belonging to the 39 | .I ring 40 | param, if they are readily available. It will not enter the kernel, unless the 41 | CQ ring is in an overflow condition. Upon successful return, 42 | .I cqe_ptrs 43 | are filled with the number of events indicated by the return value. 44 | 45 | .SH RETURN VALUE 46 | On success 47 | .BR io_uring_peek_cqe (3) 48 | returns 49 | .B 0 50 | and the cqe_ptr parameter is filled in. On success 51 | .BR io_uring_peek_batch_cqe (3) 52 | returns the number of completions filled in. On failure, 53 | .BR io_uring_peek_cqe (3) 54 | may return 55 | .BR -EAGAIN . 56 | .SH SEE ALSO 57 | .BR io_uring_submit (3), 58 | .BR io_uring_wait_cqes (3), 59 | .BR io_uring_wait_cqe (3) 60 | -------------------------------------------------------------------------------- /man/io_uring_prep_accept_direct.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_accept.3 -------------------------------------------------------------------------------- /man/io_uring_prep_bind.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2024 SUSE LLC 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_prep_bind 3 "Jun 3, 2024" "liburing-2.7" "liburing Manual" 6 | .SH NAME 7 | io_uring_prep_bind \- prepare a bind request 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .B #include 12 | .PP 13 | .BI "void io_uring_prep_bind(struct io_uring_sqe *" sqe "," 14 | .BI " int " sockfd "," 15 | .BI " struct sockaddr *" addr "," 16 | .BI " socklen_t " addrlen ");" 17 | .fi 18 | .SH DESCRIPTION 19 | The 20 | .BR io_uring_prep_bind (3) 21 | function prepares a bind request. The submission queue entry 22 | .I sqe 23 | is setup to assign the network address at 24 | .IR addr , 25 | of length 26 | .IR addrlen , 27 | to the socket descriptor 28 | .IR sockfd. 29 | 30 | This function prepares an async 31 | .BR bind (2) 32 | request. See that man page for details. 33 | 34 | .SH RETURN VALUE 35 | None 36 | .SH ERRORS 37 | The CQE 38 | .I res 39 | field will contain the result of the operation. See the related man page for 40 | details on possible values. Note that where synchronous system calls will return 41 | .B -1 42 | on failure and set 43 | .I errno 44 | to the actual error value, io_uring never uses 45 | .IR errno . 46 | Instead it returns the negated 47 | .I errno 48 | directly in the CQE 49 | .I res 50 | field. 51 | .SH SEE ALSO 52 | .BR io_uring_get_sqe (3), 53 | .BR io_uring_submit (3), 54 | .BR bind (2) 55 | -------------------------------------------------------------------------------- /man/io_uring_prep_cancel64.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_cancel.3 -------------------------------------------------------------------------------- /man/io_uring_prep_cancel_fd.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_cancel.3 -------------------------------------------------------------------------------- /man/io_uring_prep_close.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Jens Axboe 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_prep_close 3 "March 13, 2022" "liburing-2.2" "liburing Manual" 6 | .SH NAME 7 | io_uring_prep_close \- prepare a file descriptor close request 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "void io_uring_prep_close(struct io_uring_sqe *" sqe "," 13 | .BI " int " fd ");" 14 | .PP 15 | .BI "void io_uring_prep_close_direct(struct io_uring_sqe *" sqe "," 16 | .BI " unsigned " file_index ");" 17 | .PP 18 | .fi 19 | .SH DESCRIPTION 20 | .PP 21 | The 22 | .BR io_uring_prep_close (3) 23 | function prepares a close request. The submission queue entry 24 | .I sqe 25 | is setup to close the file descriptor indicated by 26 | .IR fd . 27 | 28 | For a direct descriptor close request, the offset is specified by the 29 | .I file_index 30 | argument instead of the 31 | .IR fd . 32 | This is identical to unregistering the direct descriptor, and is provided as 33 | a convenience. Note that even though it's closing a direct descriptor, the 34 | application must not set 35 | .B IOSQE_FIXED_FILE 36 | on the SQE. Otherwise the request will complete with 37 | .B -EBADF 38 | as the result. 39 | 40 | These functions prepare an async 41 | .BR close (2) 42 | request. See that man page for details. 43 | 44 | .SH RETURN VALUE 45 | None 46 | .SH ERRORS 47 | The CQE 48 | .I res 49 | field will contain the result of the operation. See the related man page for 50 | details on possible values. For closing of a direct descriptor, the only 51 | failure cases are the kernel running completely out of memory, or if the 52 | application has specified an invalid direct descriptor. Note that where 53 | synchronous system calls will return 54 | .B -1 55 | on failure and set 56 | .I errno 57 | to the actual error value, io_uring never uses 58 | .IR errno . 59 | Instead it returns the negated 60 | .I errno 61 | directly in the CQE 62 | .I res 63 | field. 64 | .SH SEE ALSO 65 | .BR io_uring_get_sqe (3), 66 | .BR io_uring_submit (3), 67 | .BR close (2) 68 | -------------------------------------------------------------------------------- /man/io_uring_prep_close_direct.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_close.3 -------------------------------------------------------------------------------- /man/io_uring_prep_cmd_discard.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2024 Pavel Begunkov 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_prep_cmd_discard 3 "Oct 13, 2024" "liburing-2.8" "liburing Manual" 6 | .SH NAME 7 | io_uring_prep_cmd_discard \- prepare a discard command 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "void io_uring_prep_cmd_discard(struct io_uring_sqe *" sqe "," 13 | .BI " int " fd "," 14 | .BI " uint64_t " offset "," 15 | .BI " uint64_t " nbytes ");" 16 | .fi 17 | .SH DESCRIPTION 18 | The 19 | .BR io_uring_prep_cmd_discard (3) 20 | function prepares a discard command request. The submission queue entry 21 | .I sqe 22 | is setup to use the file descriptor 23 | .IR fd 24 | to start discarding 25 | .I nbytes 26 | at the specified 27 | .IR offset . 28 | 29 | The command is an asynchronous equivalent of 30 | .B BLOCK_URING_CMD_DISCARD 31 | ioctl with a few differences. It allows multiple parallel discards, and it does 32 | not exclude concurrent writes and reads. As a result, it may lead to races for 33 | the data on the disk, if the application has IO inflight for the same ranges 34 | that the discard operates on. It's the user's responsibility to account for that. 35 | Furthermore, only best efforts are done to invalidate page caches. The user has 36 | to make sure that no other inflight requests are modifying or reading the 37 | range(s). If that is the case, it might result in stale page cache and data 38 | inconsistencies. 39 | 40 | Available since 6.12. 41 | 42 | .SH RETURN VALUE 43 | None 44 | .SH ERRORS 45 | The CQE 46 | .I res 47 | field will contain the result of the operation. On success, this field will be 48 | set to 49 | .B 0 . 50 | On error, a negative error value is returned. Note that where synchronous 51 | system calls will return 52 | .B -1 53 | on failure and set 54 | .I errno 55 | to the actual error value, io_uring never uses 56 | .IR errno . 57 | Instead it returns the negated 58 | .I errno 59 | directly in the CQE 60 | .I res 61 | field. 62 | .SH SEE ALSO 63 | .BR io_uring_get_sqe (3), 64 | .BR io_uring_submit (3), 65 | -------------------------------------------------------------------------------- /man/io_uring_prep_connect.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Jens Axboe 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_prep_connect 3 "March 13, 2022" "liburing-2.2" "liburing Manual" 6 | .SH NAME 7 | io_uring_prep_connect \- prepare a connect request 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .B #include 12 | .B #include 13 | .PP 14 | .BI "void io_uring_prep_connect(struct io_uring_sqe *" sqe "," 15 | .BI " int " sockfd "," 16 | .BI " const struct sockaddr *" addr "," 17 | .BI " socklen_t " addrlen ");" 18 | .fi 19 | .SH DESCRIPTION 20 | .PP 21 | The 22 | .BR io_uring_prep_connect (3) 23 | function prepares a connect request. The submission queue entry 24 | .I sqe 25 | is setup to use the file descriptor 26 | .I sockfd 27 | to start connecting to the destination described by the socket address at 28 | .I addr 29 | and of structure length 30 | .IR addrlen . 31 | 32 | This function prepares an async 33 | .BR connect (2) 34 | request. See that man page for details. 35 | 36 | .SH RETURN VALUE 37 | None 38 | .SH ERRORS 39 | The CQE 40 | .I res 41 | field will contain the result of the operation. See the related man page for 42 | details on possible values. Note that where synchronous system calls will return 43 | .B -1 44 | on failure and set 45 | .I errno 46 | to the actual error value, io_uring never uses 47 | .IR errno . 48 | Instead it returns the negated 49 | .I errno 50 | directly in the CQE 51 | .I res 52 | field. 53 | .SH NOTES 54 | As with any request that passes in data in a struct, that data must remain 55 | valid until the request has been successfully submitted. It need not remain 56 | valid until completion. Once a request has been submitted, the in-kernel 57 | state is stable. Very early kernels (5.4 and earlier) required state to be 58 | stable until the completion occurred. Applications can test for this 59 | behavior by inspecting the 60 | .B IORING_FEAT_SUBMIT_STABLE 61 | flag passed back from 62 | .BR io_uring_queue_init_params (3). 63 | .SH SEE ALSO 64 | .BR io_uring_get_sqe (3), 65 | .BR io_uring_submit (3), 66 | .BR connect (2) 67 | -------------------------------------------------------------------------------- /man/io_uring_prep_fadvise64.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_fadvise.3 -------------------------------------------------------------------------------- /man/io_uring_prep_fallocate.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Jens Axboe 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_prep_fallocate 3 "March 13, 2022" "liburing-2.2" "liburing Manual" 6 | .SH NAME 7 | io_uring_prep_fallocate \- prepare a fallocate request 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .B #include 12 | .PP 13 | .BI "void io_uring_prep_fallocate(struct io_uring_sqe *" sqe "," 14 | .BI " int " fd "," 15 | .BI " int " mode "," 16 | .BI " __u64 " offset "," 17 | .BI " __u64 " len ");" 18 | .fi 19 | .SH DESCRIPTION 20 | .PP 21 | The 22 | .BR io_uring_prep_fallocate (3) 23 | function prepares a fallocate request. The submission queue entry 24 | .I sqe 25 | is setup to use the file descriptor pointed to by 26 | .I fd 27 | to start a fallocate operation described by 28 | .I mode 29 | at offset 30 | .I offset 31 | and 32 | .I len 33 | length in bytes. 34 | 35 | This function prepares an async 36 | .BR fallocate (2) 37 | request. See that man page for details. 38 | 39 | .SH RETURN VALUE 40 | None 41 | .SH ERRORS 42 | The CQE 43 | .I res 44 | field will contain the result of the operation. See the related man page for 45 | details on possible values. Note that where synchronous system calls will return 46 | .B -1 47 | on failure and set 48 | .I errno 49 | to the actual error value, io_uring never uses 50 | .IR errno . 51 | Instead it returns the negated 52 | .I errno 53 | directly in the CQE 54 | .I res 55 | field. 56 | .SH SEE ALSO 57 | .BR io_uring_get_sqe (3), 58 | .BR io_uring_submit (3), 59 | .BR fallocate (2) 60 | -------------------------------------------------------------------------------- /man/io_uring_prep_fgetxattr.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_getxattr.3 -------------------------------------------------------------------------------- /man/io_uring_prep_fsetxattr.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_setxattr.3 -------------------------------------------------------------------------------- /man/io_uring_prep_fsync.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Jens Axboe 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_prep_fsync 3 "March 12, 2022" "liburing-2.2" "liburing Manual" 6 | .SH NAME 7 | io_uring_prep_fsync \- prepare an fsync request 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "void io_uring_prep_fsync(struct io_uring_sqe *" sqe "," 13 | .BI " int " fd "," 14 | .BI " unsigned " flags ");" 15 | .fi 16 | .SH DESCRIPTION 17 | .PP 18 | The 19 | .BR io_uring_prep_fsync (3) 20 | function prepares an fsync request. The submission queue entry 21 | .I sqe 22 | is setup to use the file descriptor 23 | .I fd 24 | that should get synced, with the modifier flags indicated by the 25 | .I flags 26 | argument. 27 | 28 | This function prepares an fsync request. It can act either like an 29 | .BR fsync (2) 30 | operation, which is the default behavior. If 31 | .B IORING_FSYNC_DATASYNC 32 | is set in the 33 | .I flags 34 | argument, then it behaves like 35 | .BR fdatasync (2). 36 | If no range is specified, the 37 | .I fd 38 | will be synced from 0 to end-of-file. 39 | 40 | It's possible to specify a range to sync, if one is desired. If the 41 | .I off 42 | field of the SQE is set to non-zero, then that indicates the offset to 43 | start syncing at. If 44 | .I len 45 | is set in the SQE, then that indicates the size in bytes to sync from the 46 | offset. Note that these fields are not accepted by this helper, so they have 47 | to be set manually in the SQE after calling this prep helper. 48 | 49 | .SH RETURN VALUE 50 | None 51 | .SH ERRORS 52 | The CQE 53 | .I res 54 | field will contain the result of the operation. See the related man page for 55 | details on possible values. Note that where synchronous system calls will return 56 | .B -1 57 | on failure and set 58 | .I errno 59 | to the actual error value, io_uring never uses 60 | .IR errno . 61 | Instead it returns the negated 62 | .I errno 63 | directly in the CQE 64 | .I res 65 | field. 66 | .SH SEE ALSO 67 | .BR io_uring_get_sqe (3), 68 | .BR io_uring_submit (3), 69 | .BR fsync (2), 70 | .BR fdatasync (2) 71 | -------------------------------------------------------------------------------- /man/io_uring_prep_ftruncate.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2024 Tony Solomonik 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_prep_ftruncate 3 "January 23, 2024" "liburing-2.6" "liburing Manual" 6 | .SH NAME 7 | io_uring_prep_ftruncate \- prepare an ftruncate request 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "void io_uring_prep_ftruncate(struct io_uring_sqe *" sqe "," 13 | .BI " int " fd "," 14 | .BI " loff_t " len ");" 15 | .fi 16 | .SH DESCRIPTION 17 | .PP 18 | The 19 | .BR io_uring_prep_ftruncate (3) 20 | function prepares an ftruncate request. The submission queue entry 21 | .I sqe 22 | is setup to use the file descriptor 23 | .I fd 24 | that should get truncated to the length indicated by the 25 | .I len 26 | argument. 27 | 28 | Applications must define 29 | .B _GNU_SOURCE 30 | to obtain the definition of this helper, as 31 | .I loff_t 32 | will not be defined without it. 33 | 34 | .SH RETURN VALUE 35 | None 36 | .SH ERRORS 37 | The CQE 38 | .I res 39 | field will contain the result of the operation. See the related man page for 40 | details on possible values. Note that where synchronous system calls will return 41 | .B -1 42 | on failure and set 43 | .I errno 44 | to the actual error value, io_uring never uses 45 | .IR errno . 46 | Instead it returns the negated 47 | .I errno 48 | directly in the CQE 49 | .I res 50 | field. 51 | .SH SEE ALSO 52 | .BR io_uring_get_sqe (3), 53 | .BR io_uring_submit (3), 54 | .BR ftruncate (2), 55 | -------------------------------------------------------------------------------- /man/io_uring_prep_getxattr.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2023 Rutvik Patel 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_prep_getxattr 3 "January 23, 2023" "liburing-2.4" "liburing Manual" 6 | .SH NAME 7 | io_uring_prep_getxattr, io_uring_prep_fgetxattr \- prepare a request to get an 8 | extended attribute value 9 | .SH SYNOPSIS 10 | .nf 11 | .B #include 12 | .PP 13 | .BI "void io_uring_prep_getxattr(struct io_uring_sqe *" sqe "," 14 | .BI " const char *" name "," 15 | .BI " char *" value "," 16 | .BI " const char *" path "," 17 | .BI " unsigned int " len ");" 18 | .PP 19 | .BI "void io_uring_prep_fgetxattr(struct io_uring_sqe *" sqe "," 20 | .BI " int " fd "," 21 | .BI " const char *" name "," 22 | .BI " char *" value "," 23 | .BI " unsigned int " len ");" 24 | .fi 25 | .SH DESCRIPTION 26 | .PP 27 | The 28 | .BR io_uring_prep_getxattr (3) 29 | function prepares a request to get an extended attribute value. The submission 30 | queue entry 31 | .I sqe 32 | is setup to get the 33 | .I value 34 | of the extended attribute identified by 35 | .I name 36 | and associated with the given 37 | .I path 38 | in the filesystem. 39 | The 40 | .I len 41 | argument specifies the size (in bytes) of 42 | .IR value . 43 | 44 | .BR io_uring_prep_fgetxattr (3) 45 | is identical to 46 | .BR io_uring_prep_getxattr (3), 47 | only the open file referred to by 48 | .I fd 49 | is interrogated in place of 50 | .IR path . 51 | 52 | This function prepares an async 53 | .BR getxattr (2) 54 | request. See that man page for details. 55 | 56 | .SH RETURN VALUE 57 | None 58 | 59 | .SH SEE ALSO 60 | .BR io_uring_get_sqe (3), 61 | .BR getxattr (2) 62 | -------------------------------------------------------------------------------- /man/io_uring_prep_link.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_linkat.3 -------------------------------------------------------------------------------- /man/io_uring_prep_listen.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2024 SUSE LLC. 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_prep_listen 3 "Jun 3, 2024" "liburing-2.7" "liburing Manual" 6 | .SH NAME 7 | io_uring_prep_listen \- prepare a listen request 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .B #include 12 | .PP 13 | .BI "void io_uring_prep_listen(struct io_uring_sqe *" sqe "," 14 | .BI " int " sockfd "," 15 | .BI " int" backlog ");" 16 | .fi 17 | .SH DESCRIPTION 18 | The 19 | .BR io_uring_prep_listen (3) 20 | function prepares a listen request. The submission queue entry 21 | .I sqe 22 | is setup to place the socket file descriptor pointed by 23 | .IR sockfd 24 | into a state to accept incoming connections. The parameter 25 | .IR backlog , 26 | defines the maximum length of the queue of pending connections. 27 | 28 | This function prepares an async 29 | .BR listen (2) 30 | request. See that man page for details. 31 | 32 | .SH RETURN VALUE 33 | None 34 | .SH ERRORS 35 | The CQE 36 | .I res 37 | field will contain the result of the operation. See the related man page for 38 | details on possible values. Note that where synchronous system calls will return 39 | .B -1 40 | on failure and set 41 | .I errno 42 | to the actual error value, io_uring never uses 43 | .IR errno . 44 | Instead it returns the negated 45 | .I errno 46 | directly in the CQE 47 | .I res 48 | field. 49 | .SH SEE ALSO 50 | .BR io_uring_get_sqe (3), 51 | .BR io_uring_submit (3), 52 | .BR listen (2) 53 | -------------------------------------------------------------------------------- /man/io_uring_prep_madvise64.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_madvise.3 -------------------------------------------------------------------------------- /man/io_uring_prep_mkdir.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_mkdirat.3 -------------------------------------------------------------------------------- /man/io_uring_prep_msg_ring_cqe_flags.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_msg_ring.3 -------------------------------------------------------------------------------- /man/io_uring_prep_msg_ring_fd_alloc.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_msg_ring_fd.3 -------------------------------------------------------------------------------- /man/io_uring_prep_multishot_accept.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_accept.3 -------------------------------------------------------------------------------- /man/io_uring_prep_multishot_accept_direct.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_accept.3 -------------------------------------------------------------------------------- /man/io_uring_prep_nop.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Samuel Williams 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_prep_nop 3 "October 20, 2022" "liburing-2.2" "liburing Manual" 6 | .SH NAME 7 | io_uring_prep_nop \- prepare a nop request 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "void io_uring_prep_nop(struct io_uring_sqe *" sqe ");" 13 | .fi 14 | .SH DESCRIPTION 15 | .PP 16 | The 17 | .BR io_uring_prep_nop (3) 18 | function prepares nop (no operation) request. The submission queue entry 19 | .I sqe 20 | does not require any additional setup. 21 | 22 | .SH RETURN VALUE 23 | None 24 | .SH ERRORS 25 | None 26 | .SH SEE ALSO 27 | .BR io_uring_get_sqe (3), 28 | .BR io_uring_submit (3), 29 | -------------------------------------------------------------------------------- /man/io_uring_prep_open.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_openat.3 -------------------------------------------------------------------------------- /man/io_uring_prep_open_direct.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_openat.3 -------------------------------------------------------------------------------- /man/io_uring_prep_openat2_direct.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_openat2.3 -------------------------------------------------------------------------------- /man/io_uring_prep_openat_direct.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_openat.3 -------------------------------------------------------------------------------- /man/io_uring_prep_poll_multishot.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_poll_add.3 -------------------------------------------------------------------------------- /man/io_uring_prep_poll_remove.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Jens Axboe 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_prep_poll_remove 3 "March 12, 2022" "liburing-2.2" "liburing Manual" 6 | .SH NAME 7 | io_uring_prep_poll_remove \- prepare a poll deletion request 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "void io_uring_prep_poll_remove(struct io_uring_sqe *" sqe "," 13 | .BI " __u64 " user_data ");" 14 | .BI " 15 | .fi 16 | .SH DESCRIPTION 17 | .PP 18 | The 19 | .BR io_uring_prep_poll_remove (3) 20 | function prepares a poll removal request. The submission queue entry 21 | .I sqe 22 | is setup to remove a poll request identified by 23 | .I user_data 24 | 25 | Works like 26 | .BR io_uring_prep_cancel (3) 27 | except only looks for poll requests. Apart from that, behavior is identical. 28 | See that man page for specific details. 29 | 30 | .SH RETURN VALUE 31 | None 32 | .SH ERRORS 33 | These are the errors that are reported in the CQE 34 | .I res 35 | field. On success, 36 | .B 0 37 | is returned. 38 | .TP 39 | .B -ENOENT 40 | The request identified by 41 | .I user_data 42 | could not be located. This could be because it completed before the cancelation 43 | request was issued, or if an invalid identifier is used. 44 | .TP 45 | .B -EINVAL 46 | One of the fields set in the SQE was invalid. 47 | .TP 48 | .B -EALREADY 49 | The execution state of the request has progressed far enough that cancelation 50 | is no longer possible. This should normally mean that it will complete shortly, 51 | either successfully, or interrupted due to the cancelation. 52 | .SH SEE ALSO 53 | .BR io_uring_get_sqe (3), 54 | .BR io_uring_submit (3), 55 | .BR io_uring_prep_cancel (3) 56 | -------------------------------------------------------------------------------- /man/io_uring_prep_read_fixed.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Jens Axboe 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_prep_read_fixed 3 "February 13, 2022" "liburing-2.1" "liburing Manual" 6 | .SH NAME 7 | io_uring_prep_read_fixed \- prepare I/O read request with registered buffer 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "void io_uring_prep_read_fixed(struct io_uring_sqe *" sqe "," 13 | .BI " int " fd "," 14 | .BI " void *" buf "," 15 | .BI " unsigned " nbytes "," 16 | .BI " __u64 " offset "," 17 | .BI " int " buf_index ");" 18 | .fi 19 | .SH DESCRIPTION 20 | .PP 21 | The 22 | .BR io_uring_prep_read_fixed (3) 23 | prepares an IO read request with a previously registered IO buffer. The 24 | submission queue entry 25 | .I sqe 26 | is setup to use the file descriptor 27 | .I fd 28 | to start reading 29 | .I nbytes 30 | into the buffer 31 | .I buf 32 | at the specified 33 | .IR offset , 34 | and with the buffer matching the registered index of 35 | .IR buf_index . 36 | 37 | This works just like 38 | .BR io_uring_prep_read (3) 39 | except it requires the use of buffers that have been registered with 40 | .BR io_uring_register_buffers (3). 41 | The 42 | .I buf 43 | and 44 | .I nbytes 45 | arguments must fall within a region specified by 46 | .I buf_index 47 | in the previously registered buffer. The buffer need not be aligned with 48 | the start of the registered buffer. 49 | 50 | After the read has been prepared it can be submitted with one of the submit 51 | functions. 52 | 53 | .SH RETURN VALUE 54 | None 55 | .SH ERRORS 56 | The CQE 57 | .I res 58 | field will contain the result of the operation. See the related man page for 59 | details on possible values. Note that where synchronous system calls will return 60 | .B -1 61 | on failure and set 62 | .I errno 63 | to the actual error value, io_uring never uses 64 | .IR errno . 65 | Instead it returns the negated 66 | .I errno 67 | directly in the CQE 68 | .I res 69 | field. 70 | .SH SEE ALSO 71 | .BR io_uring_prep_read (3), 72 | .BR io_uring_register_buffers (3) 73 | -------------------------------------------------------------------------------- /man/io_uring_prep_recv_multishot.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_recv.3 -------------------------------------------------------------------------------- /man/io_uring_prep_recvmsg_multishot.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_recvmsg.3 -------------------------------------------------------------------------------- /man/io_uring_prep_remove_buffers.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Jens Axboe 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_prep_remove_buffers 3 "March 13, 2022" "liburing-2.2" "liburing Manual" 6 | .SH NAME 7 | io_uring_prep_remove_buffers \- prepare a remove buffers request 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "void io_uring_prep_remove_buffers(struct io_uring_sqe *" sqe "," 13 | .BI " int " nr "," 14 | .BI " int " bgid ");" 15 | .fi 16 | .SH DESCRIPTION 17 | .PP 18 | The 19 | .BR io_uring_prep_remove_buffers (3) 20 | function prepares a request for removing previously supplied buffers. The 21 | submission queue entry 22 | .I sqe 23 | is setup to remove 24 | .I nr 25 | number of buffers from the buffer group ID indicated by 26 | .IR bgid . 27 | 28 | .SH RETURN VALUE 29 | None 30 | .SH ERRORS 31 | These are the errors that are reported in the CQE 32 | .I res 33 | field. On success, 34 | .I res 35 | will contain the number of successfully removed buffers. On error, 36 | the following errors can occur. 37 | .TP 38 | .B -ENOMEM 39 | The kernel was unable to allocate memory for the request. 40 | .TP 41 | .B -EINVAL 42 | One of the fields set in the SQE was invalid. 43 | .TP 44 | .B -ENOENT 45 | No buffers exist at the specified 46 | .I bgid 47 | buffer group ID. 48 | .SH SEE ALSO 49 | .BR io_uring_get_sqe (3), 50 | .BR io_uring_submit (3), 51 | .BR io_uring_register (2), 52 | .BR io_uring_prep_provide_buffers (3) 53 | -------------------------------------------------------------------------------- /man/io_uring_prep_rename.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_renameat.3 -------------------------------------------------------------------------------- /man/io_uring_prep_send_bundle.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_send.3 -------------------------------------------------------------------------------- /man/io_uring_prep_send_set_addr.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2023 Rutvik Patel 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_prep_send_set_addr 3 "January 23, 2023" "liburing-2.4" "liburing Manual" 6 | .SH NAME 7 | io_uring_prep_send_set_addr \- set address details for send requests 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "void io_uring_prep_send_set_addr(struct io_uring_sqe *" sqe "," 13 | .BI " const struct sockaddr *" dest_addr "," 14 | .BI " __u16 " addr_len ");" 15 | .fi 16 | .SH DESCRIPTION 17 | .PP 18 | The 19 | .BR io_uring_prep_send_set_addr (3) 20 | function sets a socket destination address specified by 21 | .I dest_addr 22 | and its length using 23 | .I addr_len 24 | parameters. It can be used once 25 | .I sqe 26 | is prepared using any of the 27 | .BR send (2) 28 | io_uring helpers. See man pages of 29 | .BR io_uring_prep_send (3) 30 | or 31 | .BR io_uring_prep_send_zc (3). 32 | .SH RETURN VALUE 33 | None 34 | .SH SEE ALSO 35 | .BR io_uring_get_sqe (3), 36 | .BR io_uring_prep_send (3), 37 | .BR io_uring_prep_send_zc (3), 38 | .BR send (2) 39 | -------------------------------------------------------------------------------- /man/io_uring_prep_send_zc_fixed.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_send_zc.3 -------------------------------------------------------------------------------- /man/io_uring_prep_sendmsg_zc.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_sendmsg.3 -------------------------------------------------------------------------------- /man/io_uring_prep_sendto.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_send.3 -------------------------------------------------------------------------------- /man/io_uring_prep_setxattr.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2023 Rutvik Patel 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_prep_setxattr 3 "January 23, 2023" "liburing-2.4" "liburing Manual" 6 | .SH NAME 7 | io_uring_prep_setxattr, io_uring_prep_fsetxattr \- prepare a request to set an 8 | extended attribute value 9 | .SH SYNOPSIS 10 | .nf 11 | .B #include 12 | .PP 13 | .BI "void io_uring_prep_setxattr(struct io_uring_sqe *" sqe "," 14 | .BI " const char *" name "," 15 | .BI " const char *" value "," 16 | .BI " const char *" path "," 17 | .BI " int " flags "," 18 | .BI " unsigned int " len ");" 19 | .PP 20 | .BI "void io_uring_prep_fsetxattr(struct io_uring_sqe *" sqe "," 21 | .BI " int " fd "," 22 | .BI " const char *" name "," 23 | .BI " const char *" value "," 24 | .BI " int " flags "," 25 | .BI " unsigned int " len ");" 26 | .fi 27 | .SH DESCRIPTION 28 | .PP 29 | The 30 | .BR io_uring_prep_setxattr (3) 31 | function prepares a request to set an extended attribute value. The submission 32 | queue entry 33 | .I sqe 34 | is setup to set the 35 | .I value 36 | of the extended attribute identified by 37 | .I name 38 | and associated with the given 39 | .I path 40 | in the filesystem with modifier flags 41 | .IR flags . 42 | The 43 | .I len 44 | argument specifies the size (in bytes) of 45 | .IR value . 46 | 47 | .BR io_uring_prep_fsetxattr (3) 48 | is identical to 49 | .BR io_uring_prep_setxattr (3), 50 | only the extended attribute is set on the open file referred to by 51 | .I fd 52 | in place of 53 | .IR path . 54 | 55 | This function prepares an async 56 | .BR setxattr (2) 57 | request. See that man page for details. 58 | 59 | .SH RETURN VALUE 60 | None 61 | 62 | .SH SEE ALSO 63 | .BR io_uring_get_sqe (3), 64 | .BR setxattr (2) 65 | -------------------------------------------------------------------------------- /man/io_uring_prep_shutdown.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Jens Axboe 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_prep_shutdown 3 "March 12, 2022" "liburing-2.2" "liburing Manual" 6 | .SH NAME 7 | io_uring_prep_shutdown \- prepare a shutdown request 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .B #include 12 | .PP 13 | .BI "void io_uring_prep_shutdown(struct io_uring_sqe *" sqe "," 14 | .BI " int " sockfd "," 15 | .BI " int " how ");" 16 | .fi 17 | .SH DESCRIPTION 18 | .PP 19 | The 20 | .BR io_uring_prep_shutdown (3) 21 | function prepares a shutdown request. The submission queue entry 22 | .I sqe 23 | is setup to use the file descriptor 24 | .I sockfd 25 | that should be shutdown with the 26 | .I how 27 | argument. 28 | 29 | This function prepares an async 30 | .BR shutdown (2) 31 | request. See that man page for details. 32 | 33 | .SH RETURN VALUE 34 | None 35 | .SH ERRORS 36 | The CQE 37 | .I res 38 | field will contain the result of the operation. See the related man page for 39 | details on possible values. Note that where synchronous system calls will return 40 | .B -1 41 | on failure and set 42 | .I errno 43 | to the actual error value, io_uring never uses 44 | .IR errno . 45 | Instead it returns the negated 46 | .I errno 47 | directly in the CQE 48 | .I res 49 | field. 50 | .SH SEE ALSO 51 | .BR io_uring_get_sqe (3), 52 | .BR io_uring_submit (3), 53 | .BR shutdown (2) 54 | -------------------------------------------------------------------------------- /man/io_uring_prep_socket_direct.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_socket.3 -------------------------------------------------------------------------------- /man/io_uring_prep_socket_direct_alloc.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_socket.3 -------------------------------------------------------------------------------- /man/io_uring_prep_symlink.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_symlinkat.3 -------------------------------------------------------------------------------- /man/io_uring_prep_sync_file_range.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Jens Axboe 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_prep_sync_file_range 3 "March 12, 2022" "liburing-2.2" "liburing Manual" 6 | .SH NAME 7 | io_uring_prep_sync_file_range \- prepare a sync_file_range request 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .B #include 12 | .PP 13 | .BI "void io_uring_prep_sync_file_range(struct io_uring_sqe *" sqe "," 14 | .BI " int " fd "," 15 | .BI " unsigned " len "," 16 | .BI " __u64 " offset "," 17 | .BI " int " flags ");" 18 | .fi 19 | .SH DESCRIPTION 20 | .PP 21 | The 22 | .BR io_uring_prep_sync_file_range (3) 23 | function prepares a sync_file_range request. The submission queue entry 24 | .I sqe 25 | is setup to use the file descriptor 26 | .I fd 27 | that should get 28 | .I len 29 | bytes synced started at offset 30 | .I offset 31 | and with modifier flags in the 32 | .I flags 33 | argument. 34 | 35 | This function prepares an async 36 | .BR sync_file_range (2) 37 | request. See that man page for details on the arguments. 38 | 39 | .SH RETURN VALUE 40 | None 41 | .SH ERRORS 42 | The CQE 43 | .I res 44 | field will contain the result of the operation. See the related man page for 45 | details on possible values. Note that where synchronous system calls will return 46 | .B -1 47 | on failure and set 48 | .I errno 49 | to the actual error value, io_uring never uses 50 | .IR errno . 51 | Instead it returns the negated 52 | .I errno 53 | directly in the CQE 54 | .I res 55 | field. 56 | .SH SEE ALSO 57 | .BR io_uring_get_sqe (3), 58 | .BR io_uring_submit (3), 59 | .BR sync_file_range (2) 60 | -------------------------------------------------------------------------------- /man/io_uring_prep_tee.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Jens Axboe 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_prep_tee 3 "March 13, 2022" "liburing-2.2" "liburing Manual" 6 | .SH NAME 7 | io_uring_prep_tee \- prepare a tee request 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .B #include 12 | .PP 13 | .BI "void io_uring_prep_tee(struct io_uring_sqe *" sqe "," 14 | .BI " int " fd_in "," 15 | .BI " int " fd_out "," 16 | .BI " unsigned int " nbytes "," 17 | .BI " unsigned int " splice_flags ");" 18 | .fi 19 | .SH DESCRIPTION 20 | .PP 21 | The 22 | .BR io_uring_prep_tee (3) 23 | function prepares a tee request. The submission queue entry 24 | .I sqe 25 | is setup to use as input the file descriptor 26 | .I fd_in 27 | and as output the file descriptor 28 | .I fd_out 29 | duplicating 30 | .I nbytes 31 | bytes worth of data. 32 | .I splice_flags 33 | are modifier flags for the operation. See 34 | .BR tee (2) 35 | for the generic splice flags. 36 | 37 | If the 38 | .I fd_out 39 | descriptor, 40 | .B IOSQE_FIXED_FILE 41 | can be set in the SQE to indicate that. For the input file, the io_uring 42 | specific 43 | .B SPLICE_F_FD_IN_FIXED 44 | can be set and 45 | .I fd_in 46 | given as a registered file descriptor offset. 47 | 48 | This function prepares an async 49 | .BR tee (2) 50 | request. See that man page for details. 51 | 52 | .SH RETURN VALUE 53 | None 54 | .SH ERRORS 55 | The CQE 56 | .I res 57 | field will contain the result of the operation. See the related man page for 58 | details on possible values. Note that where synchronous system calls will return 59 | .B -1 60 | on failure and set 61 | .I errno 62 | to the actual error value, io_uring never uses 63 | .IR errno . 64 | Instead it returns the negated 65 | .I errno 66 | directly in the CQE 67 | .I res 68 | field. 69 | .SH SEE ALSO 70 | .BR io_uring_get_sqe (3), 71 | .BR io_uring_submit (3), 72 | .BR io_uring_register (2), 73 | .BR splice (2), 74 | .BR tee (2) 75 | -------------------------------------------------------------------------------- /man/io_uring_prep_timeout_remove.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_timeout_update.3 -------------------------------------------------------------------------------- /man/io_uring_prep_unlink.3: -------------------------------------------------------------------------------- 1 | io_uring_prep_unlinkat.3 -------------------------------------------------------------------------------- /man/io_uring_prep_waitid.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Jens Axboe 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_prep_waitid 3 "July 14, 2023" "liburing-2.5" "liburing Manual" 6 | .SH NAME 7 | io_uring_prep_waitid \- prepare a waitid request 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .B #include 12 | .PP 13 | .BI "void io_uring_prep_waitid(struct io_uring_sqe *" sqe "," 14 | .BI " idtype_t " idtype "," 15 | .BI " id_t " id "," 16 | .BI " siginfo_t *" infop "," 17 | .BI " int " options "," 18 | .BI " unsigned int " flags ");" 19 | .fi 20 | .SH DESCRIPTION 21 | .PP 22 | The 23 | .BR io_uring_prep_waitid (3) 24 | function prepares a waitid request. The submission queue entry 25 | .I sqe 26 | is setup to use the 27 | .I idtype 28 | and 29 | .I id 30 | arguments select the child(ren), and 31 | .I options 32 | to specify the child state changes to wait for. Upon successful 33 | return, it fills 34 | .I infop 35 | with information of the child process, if any. 36 | .I flags 37 | is io_uring specific modifier flags. They are currently unused, and hence 38 | .B 0 39 | should be passed. 40 | 41 | This function prepares an async 42 | .BR waitid (2) 43 | request. See that man page for details. 44 | 45 | Available since kernel 6.7. 46 | 47 | .SH RETURN VALUE 48 | None 49 | .SH ERRORS 50 | The CQE 51 | .I res 52 | field will contain the result of the operation. See the related man page for 53 | details on possible values. Note that where synchronous system calls will return 54 | .B -1 55 | on failure and set 56 | .I errno 57 | to the actual error value, io_uring never uses 58 | .IR errno . 59 | Instead it returns the negated 60 | .I errno 61 | directly in the CQE 62 | .I res 63 | field. 64 | .SH SEE ALSO 65 | .BR io_uring_get_sqe (3), 66 | .BR io_uring_submit (3), 67 | .BR waitid (2) 68 | -------------------------------------------------------------------------------- /man/io_uring_prep_write.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2021 Stefan Roesch 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_prep_write 3 "November 15, 2021" "liburing-2.1" "liburing Manual" 6 | .SH NAME 7 | io_uring_prep_write \- prepare I/O write request 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "void io_uring_prep_write(struct io_uring_sqe *" sqe "," 13 | .BI " int " fd "," 14 | .BI " const void *" buf "," 15 | .BI " unsigned " nbytes "," 16 | .BI " __u64 " offset ");" 17 | .fi 18 | .SH DESCRIPTION 19 | .PP 20 | The 21 | .BR io_uring_prep_write (3) 22 | prepares an IO write request. The submission queue entry 23 | .I sqe 24 | is setup to use the file descriptor 25 | .I fd 26 | to start writing 27 | .I nbytes 28 | from the buffer 29 | .I buf 30 | at the specified 31 | .IR offset . 32 | 33 | On files that support seeking, if the offset is set to 34 | .BR -1 , 35 | the write operation commences at the file offset, and the file offset is 36 | incremented by the number of bytes written. See 37 | .BR write (2) 38 | for more details. Note that for an async API, reading and updating the 39 | current file offset may result in unpredictable behavior, unless access 40 | to the file is serialized. It is not encouraged to use this feature if it's 41 | possible to provide the desired IO offset from the application or library. 42 | 43 | On files that are not capable of seeking, the offset must be 0 or -1. 44 | 45 | After the write has been prepared, it can be submitted with one of the submit 46 | functions. 47 | 48 | .SH RETURN VALUE 49 | None 50 | .SH ERRORS 51 | The CQE 52 | .I res 53 | field will contain the result of the operation. See the related man page for 54 | details on possible values. Note that where synchronous system calls will return 55 | .B -1 56 | on failure and set 57 | .I errno 58 | to the actual error value, io_uring never uses 59 | .IR errno . 60 | Instead it returns the negated 61 | .I errno 62 | directly in the CQE 63 | .I res 64 | field. 65 | .SH SEE ALSO 66 | .BR io_uring_get_sqe (3), 67 | .BR io_uring_submit (3) 68 | -------------------------------------------------------------------------------- /man/io_uring_queue_exit.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2020 Jens Axboe 2 | .\" Copyright (C) 2020 Red Hat, Inc. 3 | .\" 4 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 5 | .\" 6 | .TH io_uring_queue_exit 3 "July 10, 2020" "liburing-0.7" "liburing Manual" 7 | .SH NAME 8 | io_uring_queue_exit \- tear down io_uring submission and completion queues 9 | .SH SYNOPSIS 10 | .nf 11 | .B #include 12 | .PP 13 | .BI "void io_uring_queue_exit(struct io_uring *" ring ");" 14 | .fi 15 | .SH DESCRIPTION 16 | .PP 17 | .BR io_uring_queue_exit (3) 18 | will release all resources acquired and initialized by 19 | .BR io_uring_queue_init (3). 20 | It first unmaps the memory shared between the application and the kernel and then closes the io_uring file descriptor. 21 | .SH RETURN VALUE 22 | None 23 | .SH SEE ALSO 24 | .BR io_uring_setup (2), 25 | .BR mmap (2), 26 | .BR io_uring_queue_init (3) 27 | -------------------------------------------------------------------------------- /man/io_uring_queue_init_mem.3: -------------------------------------------------------------------------------- 1 | io_uring_queue_init.3 -------------------------------------------------------------------------------- /man/io_uring_queue_init_params.3: -------------------------------------------------------------------------------- 1 | io_uring_queue_init.3 -------------------------------------------------------------------------------- /man/io_uring_recvmsg_cmsg_firsthdr.3: -------------------------------------------------------------------------------- 1 | io_uring_recvmsg_out.3 -------------------------------------------------------------------------------- /man/io_uring_recvmsg_cmsg_nexthdr.3: -------------------------------------------------------------------------------- 1 | io_uring_recvmsg_out.3 -------------------------------------------------------------------------------- /man/io_uring_recvmsg_name.3: -------------------------------------------------------------------------------- 1 | io_uring_recvmsg_out.3 -------------------------------------------------------------------------------- /man/io_uring_recvmsg_payload.3: -------------------------------------------------------------------------------- 1 | io_uring_recvmsg_out.3 -------------------------------------------------------------------------------- /man/io_uring_recvmsg_payload_length.3: -------------------------------------------------------------------------------- 1 | io_uring_recvmsg_out.3 -------------------------------------------------------------------------------- /man/io_uring_recvmsg_validate.3: -------------------------------------------------------------------------------- 1 | io_uring_recvmsg_out.3 -------------------------------------------------------------------------------- /man/io_uring_register_buffers_sparse.3: -------------------------------------------------------------------------------- 1 | io_uring_register_buffers.3 -------------------------------------------------------------------------------- /man/io_uring_register_buffers_tags.3: -------------------------------------------------------------------------------- 1 | io_uring_register_buffers.3 -------------------------------------------------------------------------------- /man/io_uring_register_buffers_update_tag.3: -------------------------------------------------------------------------------- 1 | io_uring_register_buffers.3 -------------------------------------------------------------------------------- /man/io_uring_register_clock.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2024 Jens Axboe 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_register_clock 3 "Aug 18, 2024" "liburing-2.8" "liburing Manual" 6 | .SH NAME 7 | io_uring_register_clock \- set clock source for event waiting 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "int io_uring_register_clock(struct io_uring *" ring ", 13 | .BI " struct io_uring_clock_register *" arg ");" 14 | .fi 15 | .SH DESCRIPTION 16 | .PP 17 | The 18 | .BR io_uring_register_clock (3) 19 | function registers which clock source should be used by io_uring, when an 20 | application waits for event completions. The 21 | .IR ring 22 | argument should point to the ring in question, and the 23 | .IR arg 24 | argument should be a pointer to a 25 | .B struct io_uring_clock_register . 26 | 27 | The 28 | .IR arg 29 | argument must be filled in with the appropriate information. It looks as 30 | follows: 31 | .PP 32 | .in +4n 33 | .EX 34 | struct io_uring_clock_register { 35 | __u32 clockid; 36 | __u32 __resv[3]; 37 | }; 38 | .EE 39 | .in 40 | .PP 41 | The 42 | .I clockid 43 | field must contain the clock source, with valid sources being: 44 | .TP 45 | .B CLOCK_MONOTONIC 46 | a nonsettable system-wide clock that represents monotonic time. 47 | .TP 48 | .B CLOCK_BOOTTIME 49 | A nonsettable system-wide clock that is identical to 50 | .B CLOCK_MONOTONIC , 51 | except that is also icnludes any time that the system is suspended. 52 | .PP 53 | See 54 | .BR clock_gettime (3) 55 | for more details. 56 | 57 | The 58 | .I __resv 59 | fields must be filled with zeroes. 60 | 61 | Available since 6.12. 62 | 63 | .SH RETURN VALUE 64 | On success 65 | .BR io_uring_register_clock (3) 66 | returns 0. On failure it returns 67 | .BR -errno . 68 | .SH SEE ALSO 69 | .BR clock_gettime (3), 70 | .BR io_uring_register (2), 71 | .BR io_uring_wait_cqe (3), 72 | .BR io_uring_wait_cqe_timeout (3), 73 | -------------------------------------------------------------------------------- /man/io_uring_register_eventfd.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Jens Axboe 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_register_eventfd 3 "April 16, 2022" "liburing-2.2" "liburing Manual" 6 | .SH NAME 7 | io_uring_register_eventfd \- register an eventfd with a ring 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "int io_uring_register_eventfd(struct io_uring *" ring "," 13 | .BI " int " fd ");" 14 | .PP 15 | .BI "int io_uring_register_eventfd_async(struct io_uring *" ring "," 16 | .BI " int " fd ");" 17 | .PP 18 | .BI "int io_uring_unregister_eventfd(struct io_uring *" ring ");" 19 | .fi 20 | .SH DESCRIPTION 21 | .PP 22 | .BR io_uring_register_eventfd (3) 23 | registers the eventfd file descriptor 24 | .I fd 25 | with the ring identified by 26 | .IR ring . 27 | 28 | Whenever completions are posted to the CQ ring, an eventfd notification 29 | is generated with the registered eventfd descriptor. If 30 | .BR io_uring_register_eventfd_async (3) 31 | is used, only events that completed out-of-line will trigger a notification. 32 | 33 | It notifications are no longer desired, 34 | .BR io_uring_unregister_eventfd (3) 35 | may be called to remove the eventfd registration. No eventfd argument is 36 | needed, as a ring can only have a single eventfd registered. 37 | 38 | .SH NOTES 39 | While io_uring generally takes care to avoid spurious events, they can occur. 40 | Similarly, batched completions of CQEs may only trigger a single eventfd 41 | notification even if multiple CQEs are posted. The application should make no 42 | assumptions on number of events being available having a direct correlation to 43 | eventfd notifications posted. An eventfd notification must thus only be treated 44 | as a hint to check the CQ ring for completions. 45 | .SH RETURN VALUE 46 | Returns 0 on success, or 47 | .BR -errno 48 | on error. 49 | .SH SEE ALSO 50 | .BR eventfd (2) 51 | -------------------------------------------------------------------------------- /man/io_uring_register_eventfd_async.3: -------------------------------------------------------------------------------- 1 | io_uring_register_eventfd.3 -------------------------------------------------------------------------------- /man/io_uring_register_file_alloc_range.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Jens Axboe 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_register_file_alloc_range 3 "Oct 21, 2022" "liburing-2.3" "liburing Manual" 6 | .SH NAME 7 | io_uring_register_file_alloc_range \- set range for fixed file allocations 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "int io_uring_register_file_alloc_range(struct io_uring *" ring ", 13 | .BI " unsigned " off "," 14 | .BI " unsigned " len ");" 15 | .BI " 16 | .fi 17 | .SH DESCRIPTION 18 | .PP 19 | The 20 | .BR io_uring_register_file_alloc_range (3) 21 | function sets the allowable range for fixed file index allocations within the 22 | kernel. When requests that can instantiate a new fixed file are used with 23 | .B IORING_FILE_INDEX_ALLOC , 24 | the application is asking the kernel to allocate a new fixed file descriptor 25 | rather than pass in a specific value for one. By default, the kernel will 26 | pick any available fixed file descriptor within the range available. Calling 27 | this function with 28 | .I off 29 | set to the starting offset and 30 | .I len 31 | set to the number of descriptors, the application can limit the allocated 32 | descriptors to that particular range. This effectively allows the application 33 | to set aside a range just for dynamic allocations, with the remainder being 34 | used for specific values. 35 | 36 | The application must have registered a fixed file table upfront, eg through 37 | .BR io_uring_register_files (3) 38 | or 39 | .BR io_uring_register_files_sparse (3) . 40 | 41 | Available since 6.0. 42 | 43 | .SH RETURN VALUE 44 | On success 45 | .BR io_uring_register_file_alloc_range (3) 46 | returns 0. On failure it returns 47 | .BR -errno . 48 | .SH SEE ALSO 49 | .BR io_uring_register_files (3) 50 | .BR io_uring_prep_accept_direct (3) 51 | .BR io_uring_prep_openat_direct (3) 52 | .BR io_uring_prep_socket_direct (3) 53 | -------------------------------------------------------------------------------- /man/io_uring_register_files_sparse.3: -------------------------------------------------------------------------------- 1 | io_uring_register_files.3 -------------------------------------------------------------------------------- /man/io_uring_register_files_tags.3: -------------------------------------------------------------------------------- 1 | io_uring_register_files.3 -------------------------------------------------------------------------------- /man/io_uring_register_files_update.3: -------------------------------------------------------------------------------- 1 | io_uring_register_files.3 -------------------------------------------------------------------------------- /man/io_uring_register_files_update_tag.3: -------------------------------------------------------------------------------- 1 | io_uring_register_files.3 -------------------------------------------------------------------------------- /man/io_uring_register_iowq_aff.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Jens Axboe 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_register_iowq_aff 3 "March 13, 2022" "liburing-2.2" "liburing Manual" 6 | .SH NAME 7 | io_uring_register_iowq_aff \- register async worker CPU affinities 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .B #include 12 | .PP 13 | .BI "int io_uring_register_iowq_aff(struct io_uring *" ring "," 14 | .BI " size_t " cpusz "," 15 | .BI " const cpu_set_t *" mask "); 16 | .PP 17 | .BI "void io_uring_unregister_iowq_aff(struct io_uring *" ring ");" 18 | .fi 19 | .SH DESCRIPTION 20 | .PP 21 | The 22 | .BR io_uring_prep_register_iowq_aff (3) 23 | function registers a set of CPU affinities to be used by the io_uring async 24 | workers. By default, io_uring async workers are allowed to run on any CPU in 25 | the system. If this function is called with 26 | .I ring 27 | set to the ring in question and 28 | .I mask 29 | set to a pointer to a 30 | .B cpu_set_t 31 | value and 32 | .I cpusz 33 | set to the size of the CPU set, then async workers will only be allowed to run 34 | on the CPUs specified in the mask. Existing workers may need to hit a schedule 35 | point before they are migrated. 36 | 37 | For unregistration, 38 | .BR io_uring_unregister_iowq_aff (3) 39 | may be called to restore CPU affinities to the default. 40 | 41 | Applications must define 42 | .B _GNU_SOURCE 43 | to obtain the definition of this helper, as 44 | .I cpu_set_t 45 | will not be defined without it. 46 | 47 | .SH RETURN VALUE 48 | Returns 49 | .B 0 50 | on success, or any of the following values in case of error. 51 | .TP 52 | .B -EFAULT 53 | The kernel was unable to copy the memory pointer to by 54 | .I mask 55 | as it was invalid. 56 | .TP 57 | .B -ENOMEM 58 | The kernel was unable to allocate memory for the new CPU mask. 59 | .TP 60 | .B -EINVAL 61 | .I cpusz 62 | or 63 | .I mask 64 | was NULL/0, or any other value specified was invalid. 65 | .SH SEE ALSO 66 | .BR io_uring_queue_init (3), 67 | .BR io_uring_register (2) 68 | -------------------------------------------------------------------------------- /man/io_uring_register_napi.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Stefan Roesch 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_register_napi 3 "November 16, 2022" "liburing-2.4" "liburing Manual" 6 | .SH NAME 7 | io_uring_register_napi \- register NAPI busy poll settings 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "int io_uring_register_napi(struct io_uring *" ring "," 13 | .BI " struct io_uring_napi *" napi) 14 | .PP 15 | .fi 16 | .SH DESCRIPTION 17 | .PP 18 | The 19 | .BR io_uring_register_napi (3) 20 | function registers the NAPI settings for subsequent operations. The NAPI 21 | settings are specified in the structure that is passed in the 22 | .I napi 23 | parameter. The structure consists of the napi timeout 24 | .I busy_poll_to 25 | (napi busy poll timeout in us) and 26 | .IR prefer_busy_poll . 27 | 28 | Registering a NAPI settings sets the mode when calling the function 29 | napi_busy_loop and corresponds to the SO_PREFER_BUSY_POLL socket 30 | option. 31 | 32 | NAPI busy poll can reduce the network roundtrip time. 33 | 34 | 35 | .SH RETURN VALUE 36 | On success 37 | .BR io_uring_register_napi (3) 38 | return 0. On failure they return 39 | .BR -errno . 40 | It also updates the napi structure with the current values. 41 | -------------------------------------------------------------------------------- /man/io_uring_register_reg_wait.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2024 Jens Axboe 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_register_reg_wait 3 "November 2, 2024" "liburing-2.9" "liburing Manual" 6 | .SH NAME 7 | io_uring_register_reg_wait \- Registers fixed wait regions 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "int io_uring_register_reg_wait(struct io_uring *" ring "," 13 | .BI " struct io_uring_reg_wait *"reg "," 14 | .BI " int "nr ");" 15 | .PP 16 | .fi 17 | .SH DESCRIPTION 18 | .PP 19 | The 20 | .BR io_uring_register_reg_wait (3) 21 | registers a fixed wait region starting at 22 | .IR reg 23 | and of 24 | .IR nentries 25 | entries with the ring indicated by 26 | .IR ring . 27 | 28 | This function works like 29 | .BR io_uring_setup_reg_wait (3) , 30 | except it doesn't allocate any memory on behalf of the application. The 31 | application must pass in previously allocated memory in 32 | .IR reg , 33 | which must be of the right size to hold 34 | .IR nr 35 | entries and suitably aligned on a page boundary. 36 | 37 | The memory registered should not be freed until the ring for which it is 38 | registered is closed. 39 | 40 | Once a wait region has been setup, it persists for the life time of the ring. 41 | It's currently not possible to unregister or resize a wait region. 42 | Additionally, a wait region may currently only use a single page of memory. 43 | On a 4k page size system, this means an application is limited to 44 | .B 64 45 | wait regions. That should be enough, as each wait index may be modified as 46 | needed. With at least 64 indices available, hopefully applications can just 47 | use the appropriately setup wait region for each specific type of wait, with 48 | different indices having different wait settings. 49 | 50 | Available since kernel 6.13. 51 | 52 | .SH RETURN VALUE 53 | On success 54 | .BR io_uring_register_reg_wait (3) 55 | returns 56 | .B 0 . 57 | On failure, it returns a 58 | .BR -errno 59 | value. 60 | .SH SEE ALSO 61 | .BR io_uring_submit_and_wait_reg (3), 62 | .BR io_uring_setup_reg_wait (3) 63 | -------------------------------------------------------------------------------- /man/io_uring_register_ring_fd.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Jens Axboe 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_register_ring_fd 3 "March 11, 2022" "liburing-2.2" "liburing Manual" 6 | .SH NAME 7 | io_uring_register_ring_fd \- register a ring file descriptor 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "int io_uring_register_ring_fd(struct io_uring *" ring ");" 13 | .fi 14 | .SH DESCRIPTION 15 | .PP 16 | .BR io_uring_register_ring_fd (3) 17 | registers the file descriptor of the ring. 18 | 19 | Whenever 20 | .BR io_uring_enter (2) 21 | is called to submit request or wait for completions, the kernel must grab a 22 | reference to the file descriptor. If the application using io_uring is threaded, 23 | the file table is marked as shared, and the reference grab and put of the file 24 | descriptor count is more expensive than it is for a non-threaded application. 25 | 26 | Similarly to how io_uring allows registration of files, this allow registration 27 | of the ring file descriptor itself. This reduces the overhead of the 28 | .BR io_uring_enter (2) 29 | system call. 30 | 31 | If an application using liburing is threaded, then an application should call 32 | this function to register the ring descriptor when a ring is set up. See NOTES 33 | for restrictions when a ring is shared. 34 | 35 | Available since kernel 5.18. 36 | 37 | .SH NOTES 38 | When the ring descriptor is registered, it is stored internally in the 39 | .I struct io_uring 40 | structure. For applications that share a ring between threads, for example 41 | having one thread do submits and another reap events, then this optimization 42 | cannot be used as each thread may have a different index for the registered 43 | ring fd. 44 | .SH RETURN VALUE 45 | Returns 1 on success, indicating that one file descriptor was registered, 46 | or 47 | .BR -errno 48 | on error. 49 | .SH SEE ALSO 50 | .BR io_uring_unregister_ring_fd (3), 51 | .BR io_uring_register_files (3) 52 | -------------------------------------------------------------------------------- /man/io_uring_register_sync_cancel.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Jens Axboe 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_register_sync_cancel 3 "September 21, 2022" "liburing-2.3" "liburing Manual" 6 | .SH NAME 7 | io_uring_register_sync_cancel \- issue a synchronous cancelation request 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "int io_uring_register_sync_cancel(struct io_uring *" ring ", 13 | .BI " struct io_uring_sync_cancel_reg *" reg "); 14 | .PP 15 | .SH DESCRIPTION 16 | .PP 17 | The 18 | .BR io_uring_register_sync_cancel (3) 19 | function performs a synchronous cancelation request based on the parameters 20 | specified in 21 | .I reg . 22 | 23 | The 24 | .I reg 25 | argument must be filled in with the appropriate information for the 26 | cancelation request. It looks as follows: 27 | .PP 28 | .in +4n 29 | .EX 30 | struct io_uring_sync_cancel_reg { 31 | __u64 addr; 32 | __s32 fd; 33 | __u32 flags; 34 | struct __kernel_timespec timeout; 35 | __u8 opcode; 36 | __u8 pad[7]; 37 | __u64 pad2[3]; 38 | }; 39 | .EE 40 | .in 41 | .PP 42 | 43 | The arguments largely mirror what the async prep functions support, see 44 | .BR io_uring_prep_cancel (3) 45 | for details. Similarly, the return value is the same. The exception is the 46 | .I timeout 47 | argument, which can be used to limit the time that the kernel will wait for 48 | cancelations to be successful. If the 49 | .I tv_sec 50 | and 51 | .I tv_nsec 52 | values are set to anything but 53 | .B -1UL , 54 | then they indicate a relative timeout upon which cancelations should be 55 | completed by. 56 | 57 | The 58 | .I pad 59 | values must be zero filled. 60 | 61 | .SH RETURN VALUE 62 | See 63 | .BR io_uring_prep_cancel (3) 64 | for details on the return value. If 65 | .I timeout 66 | is set to indicate a timeout, then 67 | .B -ETIME 68 | will be returned if exceeded. If an unknown value is set in the request, 69 | or if the pad values are not cleared to zero, then 70 | .I -EINVAL 71 | is returned. 72 | .SH SEE ALSO 73 | .BR io_uring_prep_cancel (3) 74 | -------------------------------------------------------------------------------- /man/io_uring_sq_ready.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Stefan Roesch 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_sq_ready 3 "January 25, 2022" "liburing-2.1" "liburing Manual" 6 | .SH NAME 7 | io_uring_sq_ready \- number of unconsumed or unsubmitted entries in the SQ ring 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "unsigned io_uring_sq_ready(const struct io_uring *" ring ");" 13 | .fi 14 | .SH DESCRIPTION 15 | .PP 16 | The 17 | .BR io_uring_sq_ready (3) 18 | function returns the number of unconsumed (if SQPOLL) or unsubmitted entries 19 | that exist in the SQ ring belonging to the 20 | .I ring 21 | param. 22 | 23 | Usage of this function only applies if the ring has been setup with 24 | .B IORING_SETUP_SQPOLL, 25 | where request submissions, and hence consumption from the SQ ring, happens 26 | through a polling thread. 27 | 28 | .SH RETURN VALUE 29 | Returns the number of unconsumed or unsubmitted entries in the SQ ring. 30 | .SH SEE ALSO 31 | .BR io_uring_cq_ready (3) 32 | -------------------------------------------------------------------------------- /man/io_uring_sq_space_left.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Stefan Roesch 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_sq_space_left 3 "January 25, 2022" "liburing-2.1" "liburing Manual" 6 | .SH NAME 7 | io_uring_sq_space_left \- free space in the SQ ring 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "unsigned io_uring_sq_space_left(const struct io_uring *" ring ");" 13 | .fi 14 | .SH DESCRIPTION 15 | .PP 16 | The 17 | .BR io_uring_sq_space_left (3) 18 | function returns how much space is left in the SQ ring belonging to the 19 | .I ring 20 | param. 21 | 22 | .SH RETURN VALUE 23 | Returns the number of availables entries in the SQ ring. 24 | .SH SEE ALSO 25 | .BR io_uring_sq_ready (3) 26 | -------------------------------------------------------------------------------- /man/io_uring_sqe_set_buf_group.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2024 Christian Mazakas 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_sqe_set_buf_group 3 "December 9, 2024" "liburing-2.9" "liburing Manual" 6 | .SH NAME 7 | io_uring_sqe_set_buf_group \- set buf group for submission queue event 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "void io_uring_sqe_set_buf_group(struct io_uring_sqe *" sqe "," 13 | .BI " int " bgid ");" 14 | .fi 15 | .SH DESCRIPTION 16 | .PP 17 | The 18 | .BR io_uring_sqe_set_buf_group (3) 19 | function sets the associated buf_group of the 20 | .I sqe 21 | to 22 | .IR bgid . 23 | 24 | After the caller has requested a submission queue entry (SQE) with 25 | .BR io_uring_get_sqe (3) , 26 | they can associate a buf_group with the SQE used for multishot operations. 27 | 28 | .SH RETURN VALUE 29 | None 30 | .SH SEE ALSO 31 | .BR io_uring_get_sqe (3), 32 | .BR io_uring_cqe_set_data (3) 33 | -------------------------------------------------------------------------------- /man/io_uring_sqe_set_data.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2021 Stefan Roesch 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_sqe_set_data 3 "November 15, 2021" "liburing-2.1" "liburing Manual" 6 | .SH NAME 7 | io_uring_sqe_set_data \- set user data for submission queue event 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "void io_uring_sqe_set_data(struct io_uring_sqe *" sqe "," 13 | .BI " void *" user_data ");" 14 | .BI " 15 | .BI "void io_uring_sqe_set_data64(struct io_uring_sqe *" sqe "," 16 | .BI " __u64 " data ");" 17 | .fi 18 | .SH DESCRIPTION 19 | .PP 20 | The 21 | .BR io_uring_sqe_set_data (3) 22 | function stores a 23 | .I user_data 24 | pointer with the submission queue entry 25 | .IR sqe . 26 | 27 | The 28 | .BR io_uring_sqe_set_data64 (3) 29 | function stores a 64-bit 30 | .I data 31 | value with the submission queue entry 32 | .IR sqe . 33 | 34 | After the caller has requested a submission queue entry (SQE) with 35 | .BR io_uring_get_sqe (3) , 36 | they can associate a data pointer or value with the SQE. Once the completion 37 | arrives, the function 38 | .BR io_uring_cqe_get_data (3) 39 | or 40 | .BR io_uring_cqe_get_data64 (3) 41 | can be called to retrieve the data pointer or value associated with the 42 | submitted request. 43 | 44 | Note that if neither of these functions are called, or the 45 | .I user_data 46 | field in the 47 | .IR sqe 48 | isn't set manually either, then the field may contain a value from a previous 49 | use of this sqe. If an application relies on always having a valid 50 | .I user_data 51 | value present, it must always assign one to each sqe. 52 | 53 | .SH RETURN VALUE 54 | None 55 | .SH SEE ALSO 56 | .BR io_uring_get_sqe (3), 57 | .BR io_uring_cqe_get_data (3) 58 | -------------------------------------------------------------------------------- /man/io_uring_sqe_set_data64.3: -------------------------------------------------------------------------------- 1 | io_uring_sqe_set_data.3 -------------------------------------------------------------------------------- /man/io_uring_sqring_wait.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Stefan Roesch 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_sqring_wait 3 "January 25, 2022" "liburing-2.1" "liburing Manual" 6 | .SH NAME 7 | io_uring_sqring_wait \- wait for free space in the SQ ring 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "int io_uring_sqring_wait(struct io_uring *" ring ");" 13 | .fi 14 | .SH DESCRIPTION 15 | .PP 16 | The function 17 | .BR io_uring_sqring_wait (3) 18 | allows the caller to wait for space to free up in the SQ ring belonging to the 19 | .I ring 20 | param, which happens when the kernel side thread 21 | has consumed one or more entries. If the SQ ring is currently non-full, 22 | no action is taken. 23 | 24 | This feature can only be used when the ring has been setup with 25 | .B IORING_SETUP_SQPOLL 26 | and hence is using an offloaded approach to request submissions. 27 | 28 | .SH RETURN VALUE 29 | On success it returns the free space. If the kernel does not support the 30 | feature, -EINVAL is returned. 31 | .SH SEE ALSO 32 | .BR io_uring_submit (3), 33 | .BR io_uring_wait_cqe (3), 34 | .BR io_uring_wait_cqes (3) 35 | -------------------------------------------------------------------------------- /man/io_uring_submit.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2021 Stefan Roesch 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_submit 3 "November 15, 2021" "liburing-2.1" "liburing Manual" 6 | .SH NAME 7 | io_uring_submit \- submit requests to the submission queue 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "int io_uring_submit(struct io_uring *" ring ");" 13 | .fi 14 | .SH DESCRIPTION 15 | .PP 16 | The 17 | .BR io_uring_submit (3) 18 | function submits the next events to the submission queue belonging to the 19 | .IR ring . 20 | 21 | After the caller retrieves a submission queue entry (SQE) with 22 | .BR io_uring_get_sqe (3) 23 | and prepares the SQE using one of the provided helpers, it can be submitted with 24 | .BR io_uring_submit (3) . 25 | 26 | .SH RETURN VALUE 27 | On success 28 | .BR io_uring_submit (3) 29 | returns the number of submitted submission queue entries, if SQPOLL is not used. 30 | If SQPOLL is used, the return value may report a higher number of submitted 31 | entries than actually submitted. If the user requires accurate information 32 | about how many submission queue entries have been successfully submitted, while 33 | using SQPOLL, the user must fall back to repeatedly submitting a single submission 34 | queue entry. On failure it returns 35 | .BR -errno . 36 | .SH NOTES 37 | For any request that passes in data in a struct, that data must remain 38 | valid until the request has been successfully submitted. It need not remain 39 | valid until completion. Once a request has been submitted, the in-kernel 40 | state is stable. Very early kernels (5.4 and earlier) required state to be 41 | stable until the completion occurred. Applications can test for this 42 | behavior by inspecting the 43 | .B IORING_FEAT_SUBMIT_STABLE 44 | flag passed back from 45 | .BR io_uring_queue_init_params (3). 46 | In general, the man pages for the individual prep helpers will have a note 47 | mentioning this fact as well, if required for the given command. 48 | .SH SEE ALSO 49 | .BR io_uring_get_sqe (3), 50 | .BR io_uring_submit_and_wait (3), 51 | .BR io_uring_submit_and_wait_timeout (3) 52 | -------------------------------------------------------------------------------- /man/io_uring_submit_and_get_events.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C), 2022 dylany 2 | .\" You may distribute this file under the terms of the GNU Free 3 | .\" Documentation License. 4 | .TH io_uring_submit_and_get_events 3 "September 5, 2022" "liburing-2.3" "liburing Manual" 5 | .SH NAME 6 | io_uring_submit_and_get_events \- submit requests to the submission queue and flush completions 7 | .SH SYNOPSIS 8 | .nf 9 | .B #include 10 | .PP 11 | .BI "int io_uring_submit_and_get_events(struct io_uring *" ring ");" 12 | .fi 13 | 14 | .SH DESCRIPTION 15 | The 16 | .BR io_uring_submit_and_get_events (3) 17 | function submits the next events to the submission queue as with 18 | .BR io_uring_submit (3) . 19 | After submission it will flush CQEs as with 20 | .BR io_uring_get_events (3) . 21 | 22 | The benefit of this function is that it does both with only one system call. 23 | 24 | .SH RETURN VALUE 25 | On success 26 | .BR io_uring_submit_and_get_events (3) 27 | returns the number of submitted submission queue entries. On failure it returns 28 | .BR -errno . 29 | .SH SEE ALSO 30 | .BR io_uring_submit (3), 31 | .BR io_uring_get_events (3) 32 | -------------------------------------------------------------------------------- /man/io_uring_submit_and_wait.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2021 Stefan Roesch 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_submit_and_wait 3 "November 15, 2021" "liburing-2.1" "liburing Manual" 6 | .SH NAME 7 | io_uring_submit_and_wait \- submit requests to the submission queue and wait for completion 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "int io_uring_submit_and_wait(struct io_uring *" ring "," 13 | .BI " unsigned " wait_nr ");" 14 | .fi 15 | .SH DESCRIPTION 16 | .PP 17 | The 18 | .BR io_uring_submit_and_wait (3) 19 | function submits the next requests from the submission queue belonging to the 20 | .I ring 21 | and waits for 22 | .I wait_nr 23 | completion events. 24 | 25 | After the caller retrieves a submission queue entry (SQE) with 26 | .BR io_uring_get_sqe (3) 27 | and prepares the SQE, it can be submitted with 28 | .BR io_uring_submit_and_wait (3) . 29 | 30 | Ideally used with a ring setup with 31 | .BR IORING_SETUP_SINGLE_ISSUER | IORING_SETUP_DEFER_TASKRUN 32 | as that will greatly reduce the number of context switches that an application 33 | will see waiting on multiple requests. 34 | 35 | .SH RETURN VALUE 36 | On success 37 | .BR io_uring_submit_and_wait (3) 38 | returns the number of submitted submission queue entries. On failure it returns 39 | .BR -errno . 40 | .SH SEE ALSO 41 | .BR io_uring_queue_init_params (3), 42 | .BR io_uring_get_sqe (3), 43 | .BR io_uring_submit (3), 44 | .BR io_uring_submit_and_wait_timeout (3) 45 | -------------------------------------------------------------------------------- /man/io_uring_unregister_buf_ring.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Jens Axboe 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_unregister_buf_ring 3 "May 18, 2022" "liburing-2.2" "liburing Manual" 6 | .SH NAME 7 | io_uring_unregister_buf_ring \- unregister a previously registered buffer ring 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "int io_uring_unregister_buf_ring(struct io_uring *" ring ", 13 | .BI " int " bgid ");" 14 | .BI " 15 | .fi 16 | .SH DESCRIPTION 17 | .PP 18 | The 19 | .BR io_uring_unregister_buf_ring (3) 20 | function unregisters a previously registered shared buffer ring indicated by 21 | .IR bgid . 22 | 23 | .SH RETURN VALUE 24 | On success 25 | .BR io_uring_unregister_buf_ring (3) 26 | returns 0. On failure it returns 27 | .BR -errno . 28 | .SH SEE ALSO 29 | .BR io_uring_register_buf_ring (3), 30 | .BR io_uring_buf_ring_free (3) 31 | -------------------------------------------------------------------------------- /man/io_uring_unregister_buffers.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2021 Stefan Roesch 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_unregister_buffers 3 "November 15, 2021" "liburing-2.1" "liburing Manual" 6 | .SH NAME 7 | io_uring_unregister_buffers \- unregister buffers for fixed buffer operations 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "int io_uring_unregister_buffers(struct io_uring *" ring ");" 13 | .fi 14 | .SH DESCRIPTION 15 | .PP 16 | The 17 | .BR io_uring_unregister_buffers (3) 18 | function unregisters the fixed buffers previously registered to the 19 | .IR ring . 20 | 21 | .SH RETURN VALUE 22 | On success 23 | .BR io_uring_unregister_buffers (3) 24 | returns 0. On failure it returns 25 | .BR -errno . 26 | .SH SEE ALSO 27 | .BR io_uring_register_buffers (3) 28 | -------------------------------------------------------------------------------- /man/io_uring_unregister_eventfd.3: -------------------------------------------------------------------------------- 1 | io_uring_register_eventfd.3 -------------------------------------------------------------------------------- /man/io_uring_unregister_files.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2021 Stefan Roesch 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_unregister_files 3 "November 15, 2021" "liburing-2.1" "liburing Manual" 6 | .SH NAME 7 | io_uring_unregister_files \- unregister file descriptors 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "int io_uring_unregister_files(struct io_uring *" ring ");" 13 | .fi 14 | .SH DESCRIPTION 15 | .PP 16 | The 17 | .BR io_uring_unregister_files (3) 18 | function unregisters the file descriptors previously registered to the 19 | .IR ring . 20 | 21 | .SH RETURN VALUE 22 | On success 23 | .BR io_uring_unregister_files (3) 24 | returns 0. On failure it returns 25 | .BR -errno . 26 | .SH SEE ALSO 27 | .BR io_uring_register_files (3) 28 | -------------------------------------------------------------------------------- /man/io_uring_unregister_iowq_aff.3: -------------------------------------------------------------------------------- 1 | io_uring_register_iowq_aff.3 -------------------------------------------------------------------------------- /man/io_uring_unregister_napi.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Stefan Roesch 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_unregister_napi 3 "November 16, 2022" "liburing-2.4" "liburing Manual" 6 | .SH NAME 7 | io_uring_unregister_napi \- unregister NAPI busy poll settings 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "int io_uring_unregister_napi(struct io_uring *" ring "," 13 | .BI " struct io_uring_napi *" napi) 14 | .PP 15 | .fi 16 | .SH DESCRIPTION 17 | .PP 18 | The 19 | .BR io_uring_unregister_napi (3) 20 | function unregisters the NAPI busy poll settings for subsequent operations. 21 | 22 | .SH RETURN VALUE 23 | On success 24 | .BR io_uring_unregister_napi (3) 25 | return 0. On failure they return 26 | .BR -errno . 27 | It also updates the napi structure with the current values. 28 | -------------------------------------------------------------------------------- /man/io_uring_unregister_ring_fd.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2022 Jens Axboe 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_unregister_ring_fd 3 "March 11, 2022" "liburing-2.2" "liburing Manual" 6 | .SH NAME 7 | io_uring_unregister_ring_fd \- unregister a ring file descriptor 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "int io_uring_unregister_ring_fd(struct io_uring *" ring ");" 13 | .fi 14 | .SH DESCRIPTION 15 | .PP 16 | .BR io_uring_unregister_ring_fd (3) 17 | unregisters the file descriptor of the ring. 18 | 19 | Unregisters a ring descriptor previously registered with the task. This is 20 | done automatically when 21 | .BR io_uring_queue_exit (3) 22 | is called, but can also be done to free up space for new ring registrations. 23 | For more information on ring descriptor registration, see 24 | .BR io_uring_register_ring_fd (3) 25 | 26 | .SH RETURN VALUE 27 | Returns 1 on success, indicating that one file descriptor was unregistered, or 28 | .BR -errno 29 | on error. 30 | .SH SEE ALSO 31 | .BR io_uring_register_ring_fd (3), 32 | .BR io_uring_register_files (3) 33 | -------------------------------------------------------------------------------- /man/io_uring_wait_cqe.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2021 Stefan Roesch 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_wait_cqe 3 "November 15, 2021" "liburing-2.1" "liburing Manual" 6 | .SH NAME 7 | io_uring_wait_cqe \- wait for one io_uring completion event 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "int io_uring_wait_cqe(struct io_uring *" ring "," 13 | .BI " struct io_uring_cqe **" cqe_ptr ");" 14 | .fi 15 | .SH DESCRIPTION 16 | .PP 17 | The 18 | .BR io_uring_wait_cqe (3) 19 | function waits for an IO completion from the queue belonging to the 20 | .I ring 21 | param, waiting for it if necessary. If an event is already available in 22 | the ring when invoked, no waiting will occur. The 23 | .I cqe_ptr 24 | param is filled in on success. 25 | 26 | After the caller has submitted a request with 27 | .BR io_uring_submit (3), 28 | the application can retrieve the completion with 29 | .BR io_uring_wait_cqe (3). 30 | 31 | .SH RETURN VALUE 32 | On success 33 | .BR io_uring_wait_cqe (3) 34 | returns 0 and the cqe_ptr param is filled in. On failure it returns 35 | .BR -errno . 36 | The return value indicates the result of waiting for a CQE, and it has no 37 | relation to the CQE result itself. 38 | .SH SEE ALSO 39 | .BR io_uring_submit (3), 40 | .BR io_uring_wait_cqe_timeout (3), 41 | .BR io_uring_wait_cqes (3) 42 | -------------------------------------------------------------------------------- /man/io_uring_wait_cqe_nr.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2021 Stefan Roesch 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_wait_cqe_nr 3 "November 15, 2021" "liburing-2.1" "liburing Manual" 6 | .SH NAME 7 | io_uring_wait_cqe_nr \- wait for one or more io_uring completion events 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "int io_uring_wait_cqe_nr(struct io_uring *" ring "," 13 | .BI " struct io_uring_cqe **" cqe_ptr "," 14 | .BI " unsigned " wait_nr ");" 15 | .fi 16 | .SH DESCRIPTION 17 | .PP 18 | The 19 | .BR io_uring_wait_cqe_nr (3) 20 | function returns 21 | .I wait_nr 22 | IO completion events from the queue belonging to the 23 | .I ring 24 | param, waiting for it if necessary. If the requested number of events are 25 | already available in the ring when invoked, no waiting will occur. The 26 | .I cqe_ptr 27 | param is filled in on success. 28 | 29 | After the caller has submitted a request with 30 | .BR io_uring_submit (3), 31 | the application can retrieve the completion with 32 | .BR io_uring_wait_cqe (3). 33 | 34 | Ideally used with a ring setup with 35 | .BR IORING_SETUP_SINGLE_ISSUER | IORING_SETUP_DEFER_TASKRUN 36 | as that will greatly reduce the number of context switches that an application 37 | will see waiting on multiple requests. 38 | 39 | .SH RETURN VALUE 40 | On success 41 | .BR io_uring_wait_cqe_nr (3) 42 | returns 0 and the cqe_ptr param is filled in. On failure it returns 43 | .BR -errno . 44 | The return value indicates the result of waiting for a CQE, and it has no 45 | relation to the CQE result itself. 46 | .SH SEE ALSO 47 | .BR io_uring_queue_init_params (3), 48 | .BR io_uring_submit (3), 49 | .BR io_uring_wait_cqes (3) 50 | -------------------------------------------------------------------------------- /man/io_uring_wait_cqe_timeout.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (C) 2021 Stefan Roesch 2 | .\" 3 | .\" SPDX-License-Identifier: LGPL-2.0-or-later 4 | .\" 5 | .TH io_uring_wait_cqe_timeout 3 "November 15, 2021" "liburing-2.1" "liburing Manual" 6 | .SH NAME 7 | io_uring_wait_cqe_timeout \- wait for one io_uring completion event with timeout 8 | .SH SYNOPSIS 9 | .nf 10 | .B #include 11 | .PP 12 | .BI "int io_uring_wait_cqe_timeout(struct io_uring *" ring "," 13 | .BI " struct io_uring_cqe **" cqe_ptr "," 14 | .BI " struct __kernel_timespec *" ts ");" 15 | .fi 16 | .SH DESCRIPTION 17 | .PP 18 | The 19 | .BR io_uring_wait_cqe_timeout (3) 20 | function waits for one IO completion to be available from the queue belonging 21 | to the 22 | .I ring 23 | param, waiting for it if necessary or until the timeout 24 | .I ts 25 | expires. If an event is already available in the ring when invoked, no waiting 26 | will occur. 27 | 28 | The 29 | .I cqe_ptr 30 | param is filled in on success. 31 | 32 | If 33 | .I ts 34 | is specified and an older kernel without 35 | .B IORING_FEAT_EXT_ARG 36 | is used, the application does not need to call 37 | .BR io_uring_submit (3) 38 | before calling 39 | .BR io_uring_wait_cqes (3). 40 | For newer kernels with that feature flag set, there is no implied submit 41 | when waiting for a request. 42 | 43 | If 44 | .I ts 45 | is 46 | .B NULL , 47 | then this behaves like 48 | .BR io_uring_wait_cqe (3) 49 | in that it will wait forever for an event. 50 | 51 | .SH RETURN VALUE 52 | On success 53 | .BR io_uring_wait_cqe_timeout (3) 54 | returns 0 and the cqe_ptr param is filled in. On failure it returns 55 | .BR -errno . 56 | The return value indicates the result of waiting for a CQE, and it has no 57 | relation to the CQE result itself. 58 | .SH SEE ALSO 59 | .BR io_uring_submit (3), 60 | .BR io_uring_wait_cqes (3), 61 | .BR io_uring_wait_cqe (3) 62 | -------------------------------------------------------------------------------- /src/arch/aarch64/lib.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | 3 | #ifndef LIBURING_ARCH_AARCH64_LIB_H 4 | #define LIBURING_ARCH_AARCH64_LIB_H 5 | 6 | #include 7 | #include "../../syscall.h" 8 | 9 | static inline long __get_page_size(void) 10 | { 11 | Elf64_Off buf[2]; 12 | long ret = 4096; 13 | int fd; 14 | 15 | fd = __sys_open("/proc/self/auxv", O_RDONLY, 0); 16 | if (fd < 0) 17 | return ret; 18 | 19 | while (1) { 20 | ssize_t x; 21 | 22 | x = __sys_read(fd, buf, sizeof(buf)); 23 | if (x < (long) sizeof(buf)) 24 | break; 25 | 26 | if (buf[0] == AT_PAGESZ) { 27 | ret = buf[1]; 28 | break; 29 | } 30 | } 31 | 32 | __sys_close(fd); 33 | return ret; 34 | } 35 | 36 | static inline long get_page_size(void) 37 | { 38 | static long cache_val; 39 | 40 | if (cache_val) 41 | return cache_val; 42 | 43 | cache_val = __get_page_size(); 44 | return cache_val; 45 | } 46 | 47 | #endif /* #ifndef LIBURING_ARCH_AARCH64_LIB_H */ 48 | -------------------------------------------------------------------------------- /src/arch/generic/lib.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | 3 | #ifndef LIBURING_ARCH_GENERIC_LIB_H 4 | #define LIBURING_ARCH_GENERIC_LIB_H 5 | 6 | static inline long get_page_size(void) 7 | { 8 | long page_size; 9 | 10 | page_size = sysconf(_SC_PAGESIZE); 11 | if (page_size < 0) 12 | page_size = 4096; 13 | 14 | return page_size; 15 | } 16 | 17 | #endif /* #ifndef LIBURING_ARCH_GENERIC_LIB_H */ 18 | -------------------------------------------------------------------------------- /src/arch/riscv64/lib.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | 3 | #ifndef LIBURING_ARCH_RISCV64_LIB_H 4 | #define LIBURING_ARCH_RISCV64_LIB_H 5 | 6 | #include 7 | #include 8 | #include "../../syscall.h" 9 | 10 | static inline long __get_page_size(void) 11 | { 12 | Elf64_Off buf[2]; 13 | long ret = 4096; 14 | int fd; 15 | 16 | fd = __sys_open("/proc/self/auxv", O_RDONLY, 0); 17 | if (fd < 0) 18 | return ret; 19 | 20 | while (1) { 21 | ssize_t x; 22 | 23 | x = __sys_read(fd, buf, sizeof(buf)); 24 | if (x < (long) sizeof(buf)) 25 | break; 26 | 27 | if (buf[0] == AT_PAGESZ) { 28 | ret = buf[1]; 29 | break; 30 | } 31 | } 32 | 33 | __sys_close(fd); 34 | return ret; 35 | } 36 | 37 | static inline long get_page_size(void) 38 | { 39 | static long cache_val; 40 | 41 | if (cache_val) 42 | return cache_val; 43 | 44 | cache_val = __get_page_size(); 45 | return cache_val; 46 | } 47 | 48 | #endif /* #ifndef LIBURING_ARCH_RISCV64_LIB_H */ 49 | -------------------------------------------------------------------------------- /src/arch/x86/lib.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | 3 | #ifndef LIBURING_ARCH_X86_LIB_H 4 | #define LIBURING_ARCH_X86_LIB_H 5 | 6 | static inline long get_page_size(void) 7 | { 8 | return 4096; 9 | } 10 | 11 | #endif /* #ifndef LIBURING_ARCH_X86_LIB_H */ 12 | -------------------------------------------------------------------------------- /src/ffi.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | #define IOURINGINLINE 3 | 4 | #ifdef __clang__ 5 | // clang doesn't seem to particularly like that we're including a header that 6 | // deliberately contains function definitions so we explicitly silence it 7 | #pragma clang diagnostic push 8 | #pragma clang diagnostic ignored "-Wmissing-prototypes" 9 | #endif 10 | 11 | #include "liburing.h" 12 | 13 | #ifdef __clang__ 14 | #pragma clang diagnostic pop 15 | #endif 16 | -------------------------------------------------------------------------------- /src/include/liburing/sanitize.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | #ifndef LIBURING_SANITIZE_H 3 | #define LIBURING_SANITIZE_H 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | struct io_uring; 10 | struct iovec; 11 | 12 | #if defined(CONFIG_USE_SANITIZER) 13 | void liburing_sanitize_ring(struct io_uring *ring); 14 | void liburing_sanitize_address(const void *addr); 15 | void liburing_sanitize_region(const void *addr, unsigned int len); 16 | void liburing_sanitize_iovecs(const struct iovec *iovecs, unsigned nr); 17 | #else 18 | #define __maybe_unused __attribute__((__unused__)) 19 | static inline void liburing_sanitize_ring(struct io_uring __maybe_unused *ring) 20 | { 21 | } 22 | static inline void liburing_sanitize_address(const void __maybe_unused *addr) 23 | { 24 | } 25 | static inline void liburing_sanitize_region(const void __maybe_unused *addr, 26 | unsigned int __maybe_unused len) 27 | { 28 | } 29 | static inline void liburing_sanitize_iovecs(const struct iovec __maybe_unused *iovecs, 30 | unsigned __maybe_unused nr) 31 | { 32 | } 33 | #endif 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/int_flags.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | #ifndef LIBURING_INT_FLAGS 3 | #define LIBURING_INT_FLAGS 4 | 5 | #define INT_FLAGS_MASK (IORING_ENTER_REGISTERED_RING | \ 6 | IORING_ENTER_NO_IOWAIT) 7 | 8 | enum { 9 | INT_FLAG_REG_RING = IORING_ENTER_REGISTERED_RING, 10 | INT_FLAG_NO_IOWAIT = IORING_ENTER_NO_IOWAIT, 11 | INT_FLAG_REG_REG_RING = 1, 12 | INT_FLAG_APP_MEM = 2, 13 | INT_FLAG_CQ_ENTER = 4, 14 | }; 15 | 16 | static inline int ring_enter_flags(struct io_uring *ring) 17 | { 18 | return ring->int_flags & INT_FLAGS_MASK; 19 | } 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /src/lib.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | #ifndef LIBURING_LIB_H 3 | #define LIBURING_LIB_H 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #if defined(__x86_64__) || defined(__i386__) 10 | #include "arch/x86/lib.h" 11 | #elif defined(__aarch64__) 12 | #include "arch/aarch64/lib.h" 13 | #elif defined(__riscv) && __riscv_xlen == 64 14 | #include "arch/riscv64/lib.h" 15 | #else 16 | /* 17 | * We don't have nolibc support for this arch. Must use libc! 18 | */ 19 | #ifdef CONFIG_NOLIBC 20 | #error "This arch doesn't support building liburing without libc" 21 | #endif 22 | /* libc wrappers. */ 23 | #include "arch/generic/lib.h" 24 | #endif 25 | 26 | 27 | #ifndef offsetof 28 | #define offsetof(TYPE, FIELD) ((size_t) &((TYPE *)0)->FIELD) 29 | #endif 30 | 31 | #ifndef container_of 32 | #define container_of(PTR, TYPE, FIELD) ({ \ 33 | __typeof__(((TYPE *)0)->FIELD) *__FIELD_PTR = (PTR); \ 34 | (TYPE *)((char *) __FIELD_PTR - offsetof(TYPE, FIELD)); \ 35 | }) 36 | #endif 37 | 38 | #define __maybe_unused __attribute__((__unused__)) 39 | #define __hot __attribute__((__hot__)) 40 | #define __cold __attribute__((__cold__)) 41 | 42 | #ifdef CONFIG_NOLIBC 43 | void *__uring_memset(void *s, int c, size_t n); 44 | void *__uring_malloc(size_t len); 45 | void __uring_free(void *p); 46 | 47 | #define malloc(LEN) __uring_malloc(LEN) 48 | #define free(PTR) __uring_free(PTR) 49 | #define memset(PTR, C, LEN) __uring_memset(PTR, C, LEN) 50 | #endif 51 | 52 | #endif /* #ifndef LIBURING_LIB_H */ 53 | -------------------------------------------------------------------------------- /src/nolibc.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | 3 | #ifndef CONFIG_NOLIBC 4 | #error "This file should only be compiled for no libc build" 5 | #endif 6 | 7 | #include "lib.h" 8 | #include "syscall.h" 9 | 10 | void *__uring_memset(void *s, int c, size_t n) 11 | { 12 | size_t i; 13 | unsigned char *p = s; 14 | 15 | for (i = 0; i < n; i++) { 16 | p[i] = (unsigned char) c; 17 | 18 | /* 19 | * An empty inline ASM to avoid auto-vectorization 20 | * because it's too bloated for liburing. 21 | */ 22 | __asm__ volatile (""); 23 | } 24 | 25 | return s; 26 | } 27 | 28 | struct uring_heap { 29 | size_t len; 30 | char user_p[] __attribute__((__aligned__)); 31 | }; 32 | 33 | void *__uring_malloc(size_t len) 34 | { 35 | struct uring_heap *heap; 36 | 37 | heap = __sys_mmap(NULL, sizeof(*heap) + len, PROT_READ | PROT_WRITE, 38 | MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); 39 | if (IS_ERR(heap)) 40 | return NULL; 41 | 42 | heap->len = sizeof(*heap) + len; 43 | return heap->user_p; 44 | } 45 | 46 | void __uring_free(void *p) 47 | { 48 | struct uring_heap *heap; 49 | 50 | if (uring_unlikely(!p)) 51 | return; 52 | 53 | heap = container_of(p, struct uring_heap, user_p); 54 | __sys_munmap(heap, heap->len); 55 | } 56 | -------------------------------------------------------------------------------- /src/setup.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | #ifndef LIBURING_SETUP_H 3 | #define LIBURING_SETUP_H 4 | 5 | int __io_uring_queue_init_params(unsigned entries, struct io_uring *ring, 6 | struct io_uring_params *p, void *buf, 7 | size_t buf_size); 8 | void io_uring_unmap_rings(struct io_uring_sq *sq, struct io_uring_cq *cq); 9 | int io_uring_mmap(int fd, struct io_uring_params *p, struct io_uring_sq *sq, 10 | struct io_uring_cq *cq); 11 | void io_uring_setup_ring_pointers(struct io_uring_params *p, 12 | struct io_uring_sq *sq, 13 | struct io_uring_cq *cq); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /src/syscall.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | 3 | #include "syscall.h" 4 | #include 5 | 6 | int io_uring_enter(unsigned int fd, unsigned int to_submit, 7 | unsigned int min_complete, unsigned int flags, sigset_t *sig) 8 | { 9 | return __sys_io_uring_enter(fd, to_submit, min_complete, flags, sig); 10 | } 11 | 12 | int io_uring_enter2(unsigned int fd, unsigned int to_submit, 13 | unsigned int min_complete, unsigned int flags, 14 | void *arg, size_t sz) 15 | { 16 | return __sys_io_uring_enter2(fd, to_submit, min_complete, flags, arg, 17 | sz); 18 | } 19 | 20 | int io_uring_setup(unsigned int entries, struct io_uring_params *p) 21 | { 22 | return __sys_io_uring_setup(entries, p); 23 | } 24 | 25 | int io_uring_register(unsigned int fd, unsigned int opcode, const void *arg, 26 | unsigned int nr_args) 27 | { 28 | return __sys_io_uring_register(fd, opcode, arg, nr_args); 29 | } 30 | -------------------------------------------------------------------------------- /src/syscall.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | #ifndef LIBURING_SYSCALL_H 3 | #define LIBURING_SYSCALL_H 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | /* 16 | * Don't put this below the #include "arch/$arch/syscall.h", that 17 | * file may need it. 18 | */ 19 | struct io_uring_params; 20 | 21 | static inline void *ERR_PTR(intptr_t n) 22 | { 23 | return (void *) n; 24 | } 25 | 26 | static inline int PTR_ERR(const void *ptr) 27 | { 28 | return (int) (intptr_t) ptr; 29 | } 30 | 31 | static inline bool IS_ERR(const void *ptr) 32 | { 33 | return uring_unlikely((uintptr_t) ptr >= (uintptr_t) -4095UL); 34 | } 35 | 36 | #if defined(__x86_64__) || defined(__i386__) 37 | #include "arch/x86/syscall.h" 38 | #elif defined(__aarch64__) 39 | #include "arch/aarch64/syscall.h" 40 | #elif defined(__riscv) && __riscv_xlen == 64 41 | #include "arch/riscv64/syscall.h" 42 | #else 43 | /* 44 | * We don't have native syscall wrappers 45 | * for this arch. Must use libc! 46 | */ 47 | #ifdef CONFIG_NOLIBC 48 | #error "This arch doesn't support building liburing without libc" 49 | #endif 50 | /* libc syscall wrappers. */ 51 | #include "arch/generic/syscall.h" 52 | #endif 53 | #endif 54 | -------------------------------------------------------------------------------- /src/version.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | 3 | #include "liburing.h" 4 | #include "liburing/io_uring_version.h" 5 | 6 | int io_uring_major_version(void) 7 | { 8 | return IO_URING_VERSION_MAJOR; 9 | } 10 | 11 | int io_uring_minor_version(void) 12 | { 13 | return IO_URING_VERSION_MINOR; 14 | } 15 | 16 | bool io_uring_check_version(int major, int minor) 17 | { 18 | return major > io_uring_major_version() || 19 | (major == io_uring_major_version() && 20 | minor > io_uring_minor_version()); 21 | } 22 | -------------------------------------------------------------------------------- /test/7ad0e4b2f83c.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | #include 3 | #include 4 | #include 5 | #include "liburing.h" 6 | #include "helpers.h" 7 | 8 | int main(int argc, char *argv[]) 9 | { 10 | struct __kernel_timespec ts1, ts2; 11 | struct io_uring_cqe *cqe; 12 | struct io_uring_sqe *sqe; 13 | struct io_uring ring; 14 | unsigned long msec; 15 | struct timeval tv; 16 | int ret; 17 | 18 | if (argc > 1) 19 | return T_EXIT_SKIP; 20 | 21 | ret = io_uring_queue_init(32, &ring, 0); 22 | if (ret) { 23 | fprintf(stderr, "io_uring_queue_init=%d\n", ret); 24 | return T_EXIT_FAIL; 25 | } 26 | 27 | sqe = io_uring_get_sqe(&ring); 28 | io_uring_prep_nop(sqe); 29 | ret = io_uring_submit(&ring); 30 | if (ret != 1) { 31 | fprintf(stderr, "io_uring_submit1=%d\n", ret); 32 | return T_EXIT_FAIL; 33 | } 34 | 35 | 36 | ts1.tv_sec = 5, 37 | ts1.tv_nsec = 0; 38 | ret = io_uring_wait_cqe_timeout(&ring, &cqe, &ts1); 39 | if (ret) { 40 | fprintf(stderr, "io_uring_wait_cqe_timeout=%d\n", ret); 41 | return T_EXIT_FAIL; 42 | } 43 | io_uring_cqe_seen(&ring, cqe); 44 | gettimeofday(&tv, NULL); 45 | 46 | ts2.tv_sec = 1; 47 | ts2.tv_nsec = 0; 48 | sqe = io_uring_get_sqe(&ring); 49 | io_uring_prep_timeout(sqe, &ts2, 0, 0); 50 | sqe->user_data = 89; 51 | ret = io_uring_submit(&ring); 52 | if (ret != 1) { 53 | fprintf(stderr, "io_uring_submit2=%d\n", ret); 54 | return T_EXIT_FAIL; 55 | } 56 | 57 | io_uring_wait_cqe(&ring, &cqe); 58 | io_uring_cqe_seen(&ring, cqe); 59 | msec = mtime_since_now(&tv); 60 | if (msec >= 900 && msec <= 1100) { 61 | io_uring_queue_exit(&ring); 62 | return T_EXIT_PASS; 63 | } 64 | 65 | fprintf(stderr, "%s: Timeout seems wonky (got %lu)\n", __FUNCTION__, 66 | msec); 67 | io_uring_queue_exit(&ring); 68 | return T_EXIT_FAIL; 69 | } 70 | -------------------------------------------------------------------------------- /test/917257daa0fe.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | // autogenerated by syzkaller (https://github.com/google/syzkaller) 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "liburing.h" 14 | #include "helpers.h" 15 | #include "../src/syscall.h" 16 | 17 | #ifndef CONFIG_USE_SANITIZER 18 | int main(int argc, char *argv[]) 19 | { 20 | if (argc > 1) 21 | return T_EXIT_SKIP; 22 | 23 | mmap((void *) 0x20000000, 0x1000000, 3, MAP_ANON|MAP_PRIVATE, -1, 0); 24 | 25 | *(uint32_t*)0x20000000 = 0; 26 | *(uint32_t*)0x20000004 = 0; 27 | *(uint32_t*)0x20000008 = 6; 28 | *(uint32_t*)0x2000000c = 0; 29 | *(uint32_t*)0x20000010 = 0x3af; 30 | *(uint32_t*)0x20000014 = 0; 31 | *(uint32_t*)0x20000018 = 0; 32 | *(uint32_t*)0x2000001c = 0; 33 | *(uint32_t*)0x20000020 = 0; 34 | *(uint32_t*)0x20000024 = 0; 35 | *(uint32_t*)0x20000028 = 0; 36 | *(uint32_t*)0x2000002c = 0; 37 | *(uint32_t*)0x20000030 = 0; 38 | *(uint32_t*)0x20000034 = 0; 39 | *(uint32_t*)0x20000038 = 0; 40 | *(uint32_t*)0x2000003c = 0; 41 | *(uint32_t*)0x20000040 = 0; 42 | *(uint32_t*)0x20000044 = 0; 43 | *(uint64_t*)0x20000048 = 0; 44 | *(uint32_t*)0x20000050 = 0; 45 | *(uint32_t*)0x20000054 = 0; 46 | *(uint32_t*)0x20000058 = 0; 47 | *(uint32_t*)0x2000005c = 0; 48 | *(uint32_t*)0x20000060 = 0; 49 | *(uint32_t*)0x20000064 = 0; 50 | *(uint32_t*)0x20000068 = 0; 51 | *(uint32_t*)0x2000006c = 0; 52 | *(uint64_t*)0x20000070 = 0; 53 | __sys_io_uring_setup(0x7a6, (struct io_uring_params *) 0x20000000UL); 54 | return T_EXIT_PASS; 55 | } 56 | #else 57 | int main(int argc, char *argv[]) 58 | { 59 | return T_EXIT_SKIP; 60 | } 61 | #endif 62 | -------------------------------------------------------------------------------- /test/a0908ae19763.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | // autogenerated by syzkaller (https://github.com/google/syzkaller) 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "liburing.h" 14 | #include "helpers.h" 15 | #include "../src/syscall.h" 16 | 17 | #ifndef CONFIG_USE_SANITIZER 18 | static uint64_t r[1] = {0xffffffffffffffff}; 19 | 20 | int main(int argc, char *argv[]) 21 | { 22 | if (argc > 1) 23 | return T_EXIT_SKIP; 24 | mmap((void *) 0x20000000, 0x1000000, 3, MAP_ANON|MAP_PRIVATE, -1, 0); 25 | intptr_t res = 0; 26 | *(uint32_t*)0x20000080 = 0; 27 | *(uint32_t*)0x20000084 = 0; 28 | *(uint32_t*)0x20000088 = 0; 29 | *(uint32_t*)0x2000008c = 0; 30 | *(uint32_t*)0x20000090 = 0; 31 | *(uint32_t*)0x20000094 = 0; 32 | *(uint32_t*)0x20000098 = 0; 33 | *(uint32_t*)0x2000009c = 0; 34 | *(uint32_t*)0x200000a0 = 0; 35 | *(uint32_t*)0x200000a4 = 0; 36 | *(uint32_t*)0x200000a8 = 0; 37 | *(uint32_t*)0x200000ac = 0; 38 | *(uint32_t*)0x200000b0 = 0; 39 | *(uint32_t*)0x200000b4 = 0; 40 | *(uint32_t*)0x200000b8 = 0; 41 | *(uint32_t*)0x200000bc = 0; 42 | *(uint32_t*)0x200000c0 = 0; 43 | *(uint32_t*)0x200000c4 = 0; 44 | *(uint64_t*)0x200000c8 = 0; 45 | *(uint32_t*)0x200000d0 = 0; 46 | *(uint32_t*)0x200000d4 = 0; 47 | *(uint32_t*)0x200000d8 = 0; 48 | *(uint32_t*)0x200000dc = 0; 49 | *(uint32_t*)0x200000e0 = 0; 50 | *(uint32_t*)0x200000e4 = 0; 51 | *(uint32_t*)0x200000e8 = 0; 52 | *(uint32_t*)0x200000ec = 0; 53 | *(uint64_t*)0x200000f0 = 0; 54 | res = __sys_io_uring_setup(0xa4, (struct io_uring_params *) 0x20000080); 55 | if (res != -1) 56 | r[0] = res; 57 | *(uint32_t*)0x20000280 = -1; 58 | __sys_io_uring_register(r[0], 2, (const void *) 0x20000280, 1); 59 | return T_EXIT_PASS; 60 | } 61 | #else 62 | int main(int argc, char *argv[]) 63 | { 64 | return T_EXIT_SKIP; 65 | } 66 | #endif 67 | -------------------------------------------------------------------------------- /test/b19062a56726.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | // autogenerated by syzkaller (https://github.com/google/syzkaller) 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "liburing.h" 14 | #include "helpers.h" 15 | #include "../src/syscall.h" 16 | 17 | #ifndef CONFIG_USE_SANITIZER 18 | int main(int argc, char *argv[]) 19 | { 20 | if (argc > 1) 21 | return T_EXIT_SKIP; 22 | 23 | mmap((void *) 0x20000000, 0x1000000, 3, MAP_ANON|MAP_PRIVATE, -1, 0); 24 | 25 | *(uint32_t*)0x20000200 = 0; 26 | *(uint32_t*)0x20000204 = 0; 27 | *(uint32_t*)0x20000208 = 5; 28 | *(uint32_t*)0x2000020c = 0x400; 29 | *(uint32_t*)0x20000210 = 0; 30 | *(uint32_t*)0x20000214 = 0; 31 | *(uint32_t*)0x20000218 = 0; 32 | *(uint32_t*)0x2000021c = 0; 33 | *(uint32_t*)0x20000220 = 0; 34 | *(uint32_t*)0x20000224 = 0; 35 | *(uint32_t*)0x20000228 = 0; 36 | *(uint32_t*)0x2000022c = 0; 37 | *(uint32_t*)0x20000230 = 0; 38 | *(uint32_t*)0x20000234 = 0; 39 | *(uint32_t*)0x20000238 = 0; 40 | *(uint32_t*)0x2000023c = 0; 41 | *(uint32_t*)0x20000240 = 0; 42 | *(uint32_t*)0x20000244 = 0; 43 | *(uint64_t*)0x20000248 = 0; 44 | *(uint32_t*)0x20000250 = 0; 45 | *(uint32_t*)0x20000254 = 0; 46 | *(uint32_t*)0x20000258 = 0; 47 | *(uint32_t*)0x2000025c = 0; 48 | *(uint32_t*)0x20000260 = 0; 49 | *(uint32_t*)0x20000264 = 0; 50 | *(uint32_t*)0x20000268 = 0; 51 | *(uint32_t*)0x2000026c = 0; 52 | *(uint64_t*)0x20000270 = 0; 53 | __sys_io_uring_setup(0xc9f, (struct io_uring_params *) 0x20000200); 54 | return T_EXIT_PASS; 55 | } 56 | #else 57 | int main(int argc, char *argv[]) 58 | { 59 | return T_EXIT_SKIP; 60 | } 61 | #endif 62 | -------------------------------------------------------------------------------- /test/b5837bd5311d.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Description: Check to see if wait_nr is being honored. 4 | */ 5 | #include 6 | #include "liburing.h" 7 | #include "helpers.h" 8 | 9 | int main(int argc, char *argv[]) 10 | { 11 | struct io_uring_sqe *sqe; 12 | struct io_uring_cqe *cqe; 13 | struct io_uring ring; 14 | int ret; 15 | struct __kernel_timespec ts = { 16 | .tv_sec = 0, 17 | .tv_nsec = 10000000 18 | }; 19 | 20 | if (argc > 1) 21 | return T_EXIT_SKIP; 22 | 23 | if (io_uring_queue_init(4, &ring, 0) != 0) { 24 | fprintf(stderr, "ring setup failed\n"); 25 | return T_EXIT_FAIL; 26 | } 27 | 28 | /* 29 | * First, submit the timeout sqe so we can actually finish the test 30 | * if everything is in working order. 31 | */ 32 | sqe = io_uring_get_sqe(&ring); 33 | if (!sqe) { 34 | fprintf(stderr, "get sqe failed\n"); 35 | return T_EXIT_FAIL; 36 | } 37 | io_uring_prep_timeout(sqe, &ts, (unsigned)-1, 0); 38 | 39 | ret = io_uring_submit(&ring); 40 | if (ret != 1) { 41 | fprintf(stderr, "Got submit %d, expected 1\n", ret); 42 | return T_EXIT_FAIL; 43 | } 44 | 45 | /* 46 | * Next, submit a nop and wait for two events. If everything is working 47 | * as it should, we should be waiting for more than a millisecond and we 48 | * should see two cqes. Otherwise, execution continues immediately 49 | * and we see only one cqe. 50 | */ 51 | sqe = io_uring_get_sqe(&ring); 52 | if (!sqe) { 53 | fprintf(stderr, "get sqe failed\n"); 54 | return T_EXIT_FAIL; 55 | } 56 | io_uring_prep_nop(sqe); 57 | 58 | ret = io_uring_submit_and_wait(&ring, 2); 59 | if (ret != 1) { 60 | fprintf(stderr, "Got submit %d, expected 1\n", ret); 61 | return T_EXIT_FAIL; 62 | } 63 | 64 | if (io_uring_peek_cqe(&ring, &cqe) != 0) { 65 | fprintf(stderr, "Unable to peek cqe!\n"); 66 | return T_EXIT_FAIL; 67 | } 68 | 69 | io_uring_cqe_seen(&ring, cqe); 70 | 71 | if (io_uring_peek_cqe(&ring, &cqe) != 0) { 72 | fprintf(stderr, "Unable to peek cqe!\n"); 73 | return T_EXIT_FAIL; 74 | } 75 | 76 | io_uring_queue_exit(&ring); 77 | return T_EXIT_PASS; 78 | } 79 | -------------------------------------------------------------------------------- /test/buf-ring-put.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Description: test persistence of mmap'ed provided ring buffers. Use a range 4 | * of buffer group IDs that puts us into both the lower end array 5 | * and higher end xarry. 6 | * 7 | */ 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "liburing.h" 16 | #include "helpers.h" 17 | 18 | #define BGID_START 60 19 | #define BGID_NR 10 20 | #define ENTRIES 512 21 | 22 | int main(int argc, char *argv[]) 23 | { 24 | struct io_uring_buf_ring *br[BGID_NR]; 25 | struct io_uring ring; 26 | size_t ring_size; 27 | int ret, i, j; 28 | 29 | if (argc > 1) 30 | return T_EXIT_SKIP; 31 | 32 | ret = io_uring_queue_init(1, &ring, 0); 33 | if (ret) { 34 | fprintf(stderr, "queue init failed %d\n", ret); 35 | return T_EXIT_FAIL; 36 | } 37 | 38 | ring_size = ENTRIES * sizeof(struct io_uring_buf); 39 | 40 | for (i = 0; i < BGID_NR; i++) { 41 | int bgid = BGID_START + i; 42 | struct io_uring_buf_reg reg = { 43 | .ring_entries = ENTRIES, 44 | .bgid = bgid, 45 | .flags = IOU_PBUF_RING_MMAP, 46 | }; 47 | off_t off; 48 | 49 | ret = io_uring_register_buf_ring(&ring, ®, 0); 50 | if (ret) { 51 | if (ret == -EINVAL) 52 | return T_EXIT_SKIP; 53 | fprintf(stderr, "reg buf ring: %d\n", ret); 54 | return T_EXIT_FAIL; 55 | } 56 | 57 | off = IORING_OFF_PBUF_RING | 58 | (unsigned long long) bgid << IORING_OFF_PBUF_SHIFT; 59 | br[i] = mmap(NULL, ring_size, PROT_READ | PROT_WRITE, 60 | MAP_SHARED | MAP_POPULATE, ring.ring_fd, off); 61 | if (br[i] == MAP_FAILED) { 62 | perror("mmap"); 63 | return T_EXIT_FAIL; 64 | } 65 | } 66 | 67 | for (i = 0; i < BGID_NR; i++) { 68 | ret = io_uring_unregister_buf_ring(&ring, BGID_START + i); 69 | if (ret) { 70 | fprintf(stderr, "reg buf ring: %d\n", ret); 71 | return T_EXIT_FAIL; 72 | } 73 | } 74 | 75 | for (j = 0; j < 1000; j++) { 76 | for (i = 0; i < BGID_NR; i++) 77 | memset(br[i], 0x5a, ring_size); 78 | usleep(1000); 79 | } 80 | 81 | io_uring_queue_exit(&ring); 82 | return T_EXIT_PASS; 83 | } 84 | -------------------------------------------------------------------------------- /test/config: -------------------------------------------------------------------------------- 1 | # Copy this to config.local, uncomment and define values 2 | # 3 | # NOTE: any files or devices added here will be used by tests that take 4 | # a file or device arguments This includes tests that are destructive with 5 | # respect to data contents. They may get erased or overwritten as part of tests. 6 | # 7 | # Define tests to exclude from running 8 | # TEST_EXCLUDE="" 9 | # 10 | # Define raw test devices (or files) for test cases, if any 11 | # declare -A TEST_MAP=() 12 | # 13 | # If no TEST_MAP entry exists for a test, use the ones given in TEST_FILES 14 | # TEST_FILES="/dev/somedevice /data/somefile" 15 | -------------------------------------------------------------------------------- /test/coredump.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Description: trigger segfault. A recent 6.4-rc kernel introduced a bug 4 | * via vhost where segfaults for applications using io_uring 5 | * would hang in D state forever upon trying to generate the 6 | * core file. Perform a trivial test where a child process 7 | * generates a NULL pointer dereference and ensure that we don't 8 | * hang. 9 | * 10 | */ 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include "liburing.h" 17 | #include "helpers.h" 18 | 19 | #ifndef CONFIG_USE_SANITIZER 20 | static void test(void) 21 | { 22 | struct io_uring_sqe *sqe; 23 | struct io_uring ring; 24 | int *ptr = NULL; 25 | int fds[2]; 26 | char r1; 27 | 28 | if (pipe(fds) < 0) { 29 | perror("pipe"); 30 | exit(0); 31 | } 32 | 33 | io_uring_queue_init(8, &ring, 0); 34 | 35 | sqe = io_uring_get_sqe(&ring); 36 | io_uring_prep_read(sqe, fds[0], &r1, sizeof(r1), 0); 37 | sqe->flags = IOSQE_ASYNC; 38 | sqe->user_data = 1; 39 | 40 | io_uring_submit(&ring); 41 | *ptr = 0; 42 | exit(0); 43 | } 44 | 45 | int main(int argc, char *argv[]) 46 | { 47 | pid_t pid; 48 | int wstat; 49 | 50 | pid = fork(); 51 | if (pid < 0) { 52 | perror("fork"); 53 | return T_EXIT_SKIP; 54 | } else if (!pid) { 55 | test(); 56 | } 57 | 58 | wait(&wstat); 59 | unlink("core"); 60 | return T_EXIT_PASS; 61 | } 62 | #else 63 | int main(int argc, char *argv[]) 64 | { 65 | return T_EXIT_SKIP; 66 | } 67 | #endif 68 | -------------------------------------------------------------------------------- /test/cq-full.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Description: test CQ ring overflow 4 | * 5 | */ 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "liburing.h" 14 | #include "helpers.h" 15 | 16 | static int queue_n_nops(struct io_uring *ring, int n) 17 | { 18 | struct io_uring_sqe *sqe; 19 | int i, ret; 20 | 21 | for (i = 0; i < n; i++) { 22 | sqe = io_uring_get_sqe(ring); 23 | if (!sqe) { 24 | printf("get sqe failed\n"); 25 | goto err; 26 | } 27 | 28 | io_uring_prep_nop(sqe); 29 | } 30 | 31 | ret = io_uring_submit(ring); 32 | if (ret < n) { 33 | printf("Submitted only %d\n", ret); 34 | goto err; 35 | } else if (ret < 0) { 36 | printf("sqe submit failed: %d\n", ret); 37 | goto err; 38 | } 39 | 40 | return 0; 41 | err: 42 | return 1; 43 | } 44 | 45 | int main(int argc, char *argv[]) 46 | { 47 | struct io_uring_cqe *cqe; 48 | struct io_uring_params p; 49 | struct io_uring ring; 50 | int i, ret; 51 | 52 | if (argc > 1) 53 | return T_EXIT_SKIP; 54 | 55 | memset(&p, 0, sizeof(p)); 56 | ret = io_uring_queue_init_params(4, &ring, &p); 57 | if (ret) { 58 | printf("ring setup failed\n"); 59 | return T_EXIT_FAIL; 60 | 61 | } 62 | 63 | if (queue_n_nops(&ring, 4)) 64 | goto err; 65 | if (queue_n_nops(&ring, 4)) 66 | goto err; 67 | if (queue_n_nops(&ring, 4)) 68 | goto err; 69 | 70 | i = 0; 71 | do { 72 | ret = io_uring_peek_cqe(&ring, &cqe); 73 | if (ret < 0) { 74 | if (ret == -EAGAIN) 75 | break; 76 | printf("wait completion %d\n", ret); 77 | goto err; 78 | } 79 | io_uring_cqe_seen(&ring, cqe); 80 | if (!cqe) 81 | break; 82 | i++; 83 | } while (1); 84 | 85 | if (i < 8 || 86 | ((*ring.cq.koverflow != 4) && !(p.features & IORING_FEAT_NODROP))) { 87 | printf("CQ overflow fail: %d completions, %u overflow\n", i, 88 | *ring.cq.koverflow); 89 | goto err; 90 | } 91 | 92 | io_uring_queue_exit(&ring); 93 | return T_EXIT_PASS; 94 | err: 95 | io_uring_queue_exit(&ring); 96 | return T_EXIT_FAIL; 97 | } 98 | -------------------------------------------------------------------------------- /test/cq-ready.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Description: test CQ ready 4 | * 5 | */ 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "liburing.h" 14 | #include "helpers.h" 15 | 16 | static int queue_n_nops(struct io_uring *ring, int n) 17 | { 18 | struct io_uring_sqe *sqe; 19 | int i, ret; 20 | 21 | for (i = 0; i < n; i++) { 22 | sqe = io_uring_get_sqe(ring); 23 | if (!sqe) { 24 | printf("get sqe failed\n"); 25 | goto err; 26 | } 27 | 28 | io_uring_prep_nop(sqe); 29 | } 30 | 31 | ret = io_uring_submit(ring); 32 | if (ret < n) { 33 | printf("Submitted only %d\n", ret); 34 | goto err; 35 | } else if (ret < 0) { 36 | printf("sqe submit failed: %d\n", ret); 37 | goto err; 38 | } 39 | 40 | return 0; 41 | err: 42 | return 1; 43 | } 44 | 45 | #define CHECK_READY(ring, expected) do {\ 46 | ready = io_uring_cq_ready((ring));\ 47 | if (ready != expected) {\ 48 | printf("Got %d CQs ready, expected %d\n", ready, expected);\ 49 | goto err;\ 50 | }\ 51 | } while(0) 52 | 53 | int main(int argc, char *argv[]) 54 | { 55 | struct io_uring ring; 56 | int ret; 57 | unsigned ready; 58 | 59 | if (argc > 1) 60 | return T_EXIT_SKIP; 61 | 62 | ret = io_uring_queue_init(4, &ring, 0); 63 | if (ret) { 64 | printf("ring setup failed\n"); 65 | return T_EXIT_FAIL; 66 | 67 | } 68 | 69 | CHECK_READY(&ring, 0); 70 | if (queue_n_nops(&ring, 4)) 71 | goto err; 72 | 73 | CHECK_READY(&ring, 4); 74 | io_uring_cq_advance(&ring, 4); 75 | CHECK_READY(&ring, 0); 76 | if (queue_n_nops(&ring, 4)) 77 | goto err; 78 | 79 | CHECK_READY(&ring, 4); 80 | 81 | io_uring_cq_advance(&ring, 1); 82 | CHECK_READY(&ring, 3); 83 | 84 | io_uring_cq_advance(&ring, 2); 85 | CHECK_READY(&ring, 1); 86 | 87 | io_uring_cq_advance(&ring, 1); 88 | CHECK_READY(&ring, 0); 89 | 90 | io_uring_queue_exit(&ring); 91 | return T_EXIT_PASS; 92 | err: 93 | io_uring_queue_exit(&ring); 94 | return T_EXIT_FAIL; 95 | } 96 | -------------------------------------------------------------------------------- /test/cq-size.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Description: test CQ ring sizing 4 | */ 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "liburing.h" 13 | #include "helpers.h" 14 | 15 | int main(int argc, char *argv[]) 16 | { 17 | struct io_uring_params p; 18 | struct io_uring ring; 19 | int ret; 20 | 21 | if (argc > 1) 22 | return T_EXIT_SKIP; 23 | 24 | memset(&p, 0, sizeof(p)); 25 | p.flags = IORING_SETUP_CQSIZE; 26 | p.cq_entries = 64; 27 | 28 | ret = io_uring_queue_init_params(4, &ring, &p); 29 | if (ret) { 30 | if (ret == -EINVAL) { 31 | printf("Skipped, not supported on this kernel\n"); 32 | goto done; 33 | } 34 | printf("ring setup failed\n"); 35 | return T_EXIT_FAIL; 36 | } 37 | 38 | if (p.cq_entries < 64) { 39 | printf("cq entries invalid (%d)\n", p.cq_entries); 40 | goto err; 41 | } 42 | io_uring_queue_exit(&ring); 43 | 44 | memset(&p, 0, sizeof(p)); 45 | p.flags = IORING_SETUP_CQSIZE; 46 | p.cq_entries = 0; 47 | 48 | ret = io_uring_queue_init_params(4, &ring, &p); 49 | if (ret >= 0) { 50 | printf("zero sized cq ring succeeded\n"); 51 | io_uring_queue_exit(&ring); 52 | goto err; 53 | } 54 | 55 | if (ret != -EINVAL) { 56 | printf("io_uring_queue_init_params failed, but not with -EINVAL" 57 | ", returned error %d (%s)\n", ret, strerror(-ret)); 58 | goto err; 59 | } 60 | 61 | done: 62 | return T_EXIT_PASS; 63 | err: 64 | return T_EXIT_FAIL; 65 | } 66 | -------------------------------------------------------------------------------- /test/d77a67ed5f27.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "liburing.h" 8 | #include "helpers.h" 9 | 10 | static void sig_alrm(int sig) 11 | { 12 | fprintf(stderr, "Timed out!\n"); 13 | exit(1); 14 | } 15 | 16 | int main(int argc, char *argv[]) 17 | { 18 | struct io_uring_sqe *sqe; 19 | struct io_uring_cqe *cqe; 20 | struct io_uring_params p; 21 | struct io_uring ring; 22 | int ret, data; 23 | 24 | if (argc > 1) 25 | return T_EXIT_SKIP; 26 | 27 | signal(SIGALRM, sig_alrm); 28 | 29 | memset(&p, 0, sizeof(p)); 30 | p.sq_thread_idle = 100; 31 | p.flags = IORING_SETUP_SQPOLL; 32 | ret = t_create_ring_params(4, &ring, &p); 33 | if (ret == T_SETUP_SKIP) 34 | return T_EXIT_SKIP; 35 | else if (ret < 0) 36 | return T_EXIT_FAIL; 37 | 38 | /* make sure sq thread is sleeping at this point */ 39 | usleep(150000); 40 | alarm(1); 41 | 42 | sqe = io_uring_get_sqe(&ring); 43 | if (!sqe) { 44 | fprintf(stderr, "sqe get failed\n"); 45 | return T_EXIT_FAIL; 46 | } 47 | 48 | io_uring_prep_nop(sqe); 49 | io_uring_sqe_set_data(sqe, (void *) (unsigned long) 42); 50 | io_uring_submit_and_wait(&ring, 1); 51 | 52 | ret = io_uring_peek_cqe(&ring, &cqe); 53 | if (ret) { 54 | fprintf(stderr, "cqe get failed\n"); 55 | return 1; 56 | } 57 | 58 | data = (unsigned long) io_uring_cqe_get_data(cqe); 59 | if (data != 42) { 60 | fprintf(stderr, "invalid data: %d\n", data); 61 | return T_EXIT_FAIL; 62 | } 63 | 64 | return T_EXIT_PASS; 65 | } 66 | -------------------------------------------------------------------------------- /test/drop-submit.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Description: test IORING_SETUP_SUBMIT_ALL 4 | * 5 | */ 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "liburing.h" 12 | #include "helpers.h" 13 | 14 | static int test(struct io_uring *ring, int expect_drops) 15 | { 16 | struct io_uring_sqe *sqe; 17 | char buf[32]; 18 | int ret, i; 19 | 20 | for (i = 0; i < 4; i++) { 21 | sqe = io_uring_get_sqe(ring); 22 | if (!sqe) { 23 | fprintf(stderr, "get sqe failed\n"); 24 | goto err; 25 | } 26 | 27 | io_uring_prep_nop(sqe); 28 | } 29 | 30 | /* prep two invalid reads, these will fail */ 31 | for (i = 0; i < 2; i++) { 32 | sqe = io_uring_get_sqe(ring); 33 | if (!sqe) { 34 | fprintf(stderr, "get sqe failed\n"); 35 | goto err; 36 | } 37 | 38 | io_uring_prep_read(sqe, 128, buf, sizeof(buf), 0); 39 | sqe->ioprio = (short) -1; 40 | } 41 | 42 | 43 | ret = io_uring_submit(ring); 44 | if (expect_drops) { 45 | if (ret != 5) { 46 | fprintf(stderr, "drops submit failed: %d\n", ret); 47 | goto err; 48 | } 49 | } else { 50 | if (ret != 6) { 51 | fprintf(stderr, "no drops submit failed: %d\n", ret); 52 | goto err; 53 | } 54 | } 55 | 56 | return 0; 57 | err: 58 | return 1; 59 | } 60 | 61 | int main(int argc, char *argv[]) 62 | { 63 | struct io_uring ring; 64 | int ret; 65 | 66 | if (argc > 1) 67 | return T_EXIT_SKIP; 68 | 69 | ret = io_uring_queue_init(8, &ring, IORING_SETUP_SUBMIT_ALL); 70 | if (ret) 71 | return 0; 72 | 73 | ret = test(&ring, 0); 74 | if (ret) { 75 | fprintf(stderr, "test no drops failed\n"); 76 | return ret; 77 | } 78 | 79 | io_uring_queue_exit(&ring); 80 | 81 | ret = io_uring_queue_init(8, &ring, 0); 82 | if (ret) { 83 | fprintf(stderr, "ring setup failed\n"); 84 | return T_EXIT_FAIL; 85 | } 86 | 87 | ret = test(&ring, 1); 88 | if (ret) { 89 | fprintf(stderr, "test drops failed\n"); 90 | return ret; 91 | } 92 | 93 | return T_EXIT_PASS; 94 | } 95 | -------------------------------------------------------------------------------- /test/empty-eownerdead.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Test if entering with nothing to submit/wait for SQPOLL returns an error. 4 | */ 5 | #include 6 | #include 7 | #include 8 | 9 | #include "liburing.h" 10 | #include "helpers.h" 11 | #include "../src/syscall.h" 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | struct io_uring_params p = {}; 16 | struct io_uring ring; 17 | int ret; 18 | 19 | if (argc > 1) 20 | return T_EXIT_SKIP; 21 | 22 | p.flags = IORING_SETUP_SQPOLL; 23 | p.sq_thread_idle = 100; 24 | 25 | ret = t_create_ring_params(1, &ring, &p); 26 | if (ret == T_SETUP_SKIP) 27 | return T_EXIT_SKIP; 28 | else if (ret < 0) 29 | goto err; 30 | 31 | ret = __sys_io_uring_enter(ring.ring_fd, 0, 0, 0, NULL); 32 | if (ret < 0) { 33 | int __e = errno; 34 | 35 | if (__e == EOWNERDEAD) 36 | fprintf(stderr, "sqe submit unexpected failure due old kernel bug: %s\n", strerror(__e)); 37 | else 38 | fprintf(stderr, "sqe submit unexpected failure: %s\n", strerror(__e)); 39 | goto err; 40 | } 41 | 42 | return T_EXIT_PASS; 43 | err: 44 | return T_EXIT_FAIL; 45 | } 46 | -------------------------------------------------------------------------------- /test/eploop.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Test that we don't recursively generate completion events if an io_uring 4 | * fd is added to an epoll context, and the ring itself polls for events on 5 | * the epollfd. Older kernels will stop on overflow, newer kernels will 6 | * detect this earlier and abort correctly. 7 | */ 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "liburing.h" 15 | #include "helpers.h" 16 | 17 | int main(int argc, char *argv[]) 18 | { 19 | struct io_uring ring; 20 | struct io_uring_sqe *sqe; 21 | struct io_uring_cqe *cqe; 22 | struct epoll_event ev = { }; 23 | int epollfd, ret, i; 24 | 25 | if (argc > 1) 26 | return T_EXIT_SKIP; 27 | 28 | ret = io_uring_queue_init(8, &ring, 0); 29 | if (ret) { 30 | fprintf(stderr, "Ring init failed: %d\n", ret); 31 | return T_EXIT_FAIL; 32 | } 33 | 34 | epollfd = epoll_create1(0); 35 | if (epollfd < 0) { 36 | perror("epoll_create"); 37 | return T_EXIT_FAIL; 38 | } 39 | 40 | ev.events = EPOLLIN; 41 | ev.data.fd = ring.ring_fd; 42 | ret = epoll_ctl(epollfd, EPOLL_CTL_ADD, ring.ring_fd, &ev); 43 | if (ret < 0) { 44 | perror("epoll_ctl"); 45 | return T_EXIT_FAIL; 46 | } 47 | 48 | sqe = io_uring_get_sqe(&ring); 49 | io_uring_prep_poll_multishot(sqe, epollfd, POLLIN); 50 | sqe->user_data = 1; 51 | io_uring_submit(&ring); 52 | 53 | sqe = io_uring_get_sqe(&ring); 54 | sqe->user_data = 2; 55 | io_uring_prep_nop(sqe); 56 | io_uring_submit(&ring); 57 | 58 | for (i = 0; i < 2; i++) { 59 | ret = io_uring_wait_cqe(&ring, &cqe); 60 | if (ret) { 61 | fprintf(stderr, "wait_cqe ret = %d\n", ret); 62 | break; 63 | } 64 | io_uring_cqe_seen(&ring, cqe); 65 | } 66 | 67 | ret = io_uring_peek_cqe(&ring, &cqe); 68 | if (!ret) { 69 | fprintf(stderr, "Generated too many events\n"); 70 | return T_EXIT_FAIL; 71 | } 72 | 73 | return T_EXIT_PASS; 74 | } 75 | -------------------------------------------------------------------------------- /test/eventfd-reg.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Description: test eventfd registration+unregistration 4 | * 5 | */ 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "liburing.h" 16 | #include "helpers.h" 17 | 18 | int main(int argc, char *argv[]) 19 | { 20 | struct io_uring_params p = {}; 21 | struct io_uring ring; 22 | int ret, evfd[2], i; 23 | 24 | if (argc > 1) 25 | return T_EXIT_SKIP; 26 | 27 | ret = io_uring_queue_init_params(8, &ring, &p); 28 | if (ret) { 29 | fprintf(stderr, "ring setup failed: %d\n", ret); 30 | return T_EXIT_FAIL; 31 | } 32 | 33 | evfd[0] = eventfd(0, EFD_CLOEXEC); 34 | evfd[1] = eventfd(0, EFD_CLOEXEC); 35 | if (evfd[0] < 0 || evfd[1] < 0) { 36 | perror("eventfd"); 37 | return T_EXIT_FAIL; 38 | } 39 | 40 | ret = io_uring_register_eventfd(&ring, evfd[0]); 41 | if (ret) { 42 | fprintf(stderr, "failed to register evfd: %d\n", ret); 43 | return T_EXIT_FAIL; 44 | } 45 | 46 | /* Check that registering again will get -EBUSY */ 47 | ret = io_uring_register_eventfd(&ring, evfd[1]); 48 | if (ret != -EBUSY) { 49 | fprintf(stderr, "unexpected 2nd register: %d\n", ret); 50 | return T_EXIT_FAIL; 51 | } 52 | close(evfd[1]); 53 | 54 | ret = io_uring_unregister_eventfd(&ring); 55 | if (ret) { 56 | fprintf(stderr, "unexpected unregister: %d\n", ret); 57 | return T_EXIT_FAIL; 58 | } 59 | 60 | /* loop 100 registers/unregister */ 61 | for (i = 0; i < 100; i++) { 62 | ret = io_uring_register_eventfd(&ring, evfd[0]); 63 | if (ret) { 64 | fprintf(stderr, "failed to register evfd: %d\n", ret); 65 | return T_EXIT_FAIL; 66 | } 67 | 68 | ret = io_uring_unregister_eventfd(&ring); 69 | if (ret) { 70 | fprintf(stderr, "unexpected unregister: %d\n", ret); 71 | return T_EXIT_FAIL; 72 | } 73 | } 74 | 75 | close(evfd[0]); 76 | return T_EXIT_PASS; 77 | } 78 | -------------------------------------------------------------------------------- /test/evloop.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Test that we don't recursively generate completion events if an io_uring 4 | * has an eventfd registered that triggers on completions, and we add a poll 5 | * request with multishot on the eventfd. Older kernels will stop on overflow, 6 | * newer kernels will detect this earlier and abort correctly. 7 | */ 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include "liburing.h" 17 | #include "helpers.h" 18 | 19 | int main(int argc, char *argv[]) 20 | { 21 | struct io_uring ring; 22 | struct io_uring_sqe *sqe; 23 | struct io_uring_cqe *cqe; 24 | int ret, efd, i; 25 | 26 | if (argc > 1) 27 | return T_EXIT_SKIP; 28 | 29 | ret = io_uring_queue_init(8, &ring, 0); 30 | if (ret) { 31 | fprintf(stderr, "Ring init failed: %d\n", ret); 32 | return T_EXIT_FAIL; 33 | } 34 | 35 | efd = eventfd(0, 0); 36 | if (efd < 0) { 37 | perror("eventfd"); 38 | return T_EXIT_FAIL; 39 | } 40 | 41 | ret = io_uring_register_eventfd(&ring, efd); 42 | if (ret) { 43 | fprintf(stderr, "Ring eventfd register failed: %d\n", ret); 44 | return T_EXIT_FAIL; 45 | } 46 | 47 | sqe = io_uring_get_sqe(&ring); 48 | io_uring_prep_poll_multishot(sqe, efd, POLLIN); 49 | sqe->user_data = 1; 50 | io_uring_submit(&ring); 51 | 52 | sqe = io_uring_get_sqe(&ring); 53 | sqe->user_data = 2; 54 | io_uring_prep_nop(sqe); 55 | io_uring_submit(&ring); 56 | 57 | for (i = 0; i < 2; i++) { 58 | ret = io_uring_wait_cqe(&ring, &cqe); 59 | if (ret) { 60 | fprintf(stderr, "wait_cqe ret = %d\n", ret); 61 | break; 62 | } 63 | io_uring_cqe_seen(&ring, cqe); 64 | } 65 | 66 | ret = io_uring_peek_cqe(&ring, &cqe); 67 | if (!ret) { 68 | fprintf(stderr, "Generated too many events\n"); 69 | return T_EXIT_FAIL; 70 | } 71 | 72 | return T_EXIT_PASS; 73 | } 74 | -------------------------------------------------------------------------------- /test/exec-target.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | 3 | int main(int argc, char *argv[]) 4 | { 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /test/fifo-nonblock-read.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Description: Test O_NONBLOCK reading from fifo, should result in proper 4 | * retry and a positive read results. Buggy result would be 5 | * -EAGAIN being returned to the user. 6 | */ 7 | #include 8 | #include 9 | #include 10 | 11 | #include "liburing.h" 12 | #include "helpers.h" 13 | 14 | int main(int argc, char *argv[]) 15 | { 16 | struct io_uring_sqe *sqe; 17 | struct io_uring_cqe *cqe; 18 | struct io_uring ring; 19 | char buf[32]; 20 | int fds[2]; 21 | int flags; 22 | int ret; 23 | 24 | io_uring_queue_init(1, &ring, 0); 25 | 26 | if (pipe(fds) < 0) { 27 | perror("pipe"); 28 | return T_EXIT_FAIL; 29 | } 30 | 31 | flags = fcntl(fds[0], F_GETFL, 0); 32 | if (flags < 0) { 33 | perror("fcntl get"); 34 | return T_EXIT_FAIL; 35 | } 36 | flags |= O_NONBLOCK; 37 | ret = fcntl(fds[0], F_SETFL, flags); 38 | if (ret < 0) { 39 | perror("fcntl set"); 40 | return T_EXIT_FAIL; 41 | } 42 | 43 | sqe = io_uring_get_sqe(&ring); 44 | io_uring_prep_read(sqe, fds[0], buf, sizeof(buf), 0); 45 | io_uring_submit(&ring); 46 | 47 | usleep(10000); 48 | 49 | ret = write(fds[1], "Hello\n", 6); 50 | if (ret < 0) { 51 | perror("pipe write"); 52 | return T_EXIT_FAIL; 53 | } 54 | 55 | ret = io_uring_wait_cqe(&ring, &cqe); 56 | if (ret < 0) { 57 | fprintf(stderr, "wait=%d\n", ret); 58 | return T_EXIT_FAIL; 59 | } 60 | 61 | if (cqe->res < 0) { 62 | fprintf(stderr, "cqe res %d\n", cqe->res); 63 | return T_EXIT_FAIL; 64 | } 65 | 66 | io_uring_cqe_seen(&ring, cqe); 67 | io_uring_queue_exit(&ring); 68 | return T_EXIT_PASS; 69 | } 70 | -------------------------------------------------------------------------------- /test/file-exit-unreg.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Description: test that a defer task_work file with tags unregistration 4 | * doesn't trigger a lockdep violation 5 | * 6 | */ 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "liburing.h" 13 | #include "helpers.h" 14 | 15 | int main(int argc, char *argv[]) 16 | { 17 | __u64 tags[2] = { 1, 2 }; 18 | struct io_uring ring; 19 | int fds[2], ret; 20 | 21 | if (argc > 1) 22 | return T_EXIT_SKIP; 23 | 24 | if (pipe(fds) < 0) { 25 | perror("pipe"); 26 | return 1; 27 | } 28 | 29 | ret = io_uring_queue_init(4, &ring, IORING_SETUP_SINGLE_ISSUER|IORING_SETUP_DEFER_TASKRUN); 30 | if (ret == -EINVAL) { 31 | return T_EXIT_SKIP; 32 | } else if (ret < 0) { 33 | fprintf(stderr, "queue_init: %d\n", ret); 34 | return T_EXIT_FAIL; 35 | } 36 | 37 | ret = io_uring_register_files_tags(&ring, fds, tags, 2); 38 | if (ret == -EINVAL) { 39 | return T_EXIT_SKIP; 40 | } else if (ret < 0) { 41 | fprintf(stderr, "file_register_init: %d\n", ret); 42 | return T_EXIT_FAIL; 43 | } 44 | 45 | io_uring_queue_exit(&ring); 46 | sleep(1); 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /test/ignore-single-mmap.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * 6.10-rc merge window had a bug where the rewritten mmap support caused 4 | * rings allocated with > 1 page, but asking for smaller mappings, would 5 | * cause -EFAULT to be returned rather than a successful map. This hit 6 | * applications either using an ancient liburing with IORING_FEAT_SINGLE_MMAP 7 | * support, or application just ignoring that feature flag and still doing 8 | * 3 mmap operations to map the ring. 9 | */ 10 | #include 11 | #include 12 | #include 13 | 14 | #include "../src/syscall.h" 15 | #include "liburing.h" 16 | #include "helpers.h" 17 | 18 | #define ENTRIES 128 19 | 20 | int main(int argc, char *argv[]) 21 | { 22 | struct io_uring_params p = { }; 23 | void *ptr; 24 | int fd; 25 | 26 | if (argc > 1) 27 | return T_EXIT_SKIP; 28 | 29 | fd = __sys_io_uring_setup(ENTRIES, &p); 30 | if (fd < 0) 31 | return T_EXIT_SKIP; 32 | 33 | if (!(p.features & IORING_FEAT_SINGLE_MMAP)) { 34 | close(fd); 35 | return T_EXIT_SKIP; 36 | } 37 | 38 | ptr = __sys_mmap(0, ENTRIES * sizeof(unsigned), PROT_READ | PROT_WRITE, 39 | MAP_SHARED | MAP_POPULATE, fd, 40 | IORING_OFF_SQ_RING); 41 | if (!IS_ERR(ptr)) { 42 | close(fd); 43 | return T_EXIT_PASS; 44 | } 45 | 46 | fprintf(stderr, "ring sqe array mmap: %d\n", PTR_ERR(ptr)); 47 | return T_EXIT_FAIL; 48 | } 49 | -------------------------------------------------------------------------------- /test/iopoll-leak.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Description: test a mem leak with IOPOLL 4 | */ 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "helpers.h" 14 | #include "liburing.h" 15 | 16 | #define FILE_SIZE (128 * 1024) 17 | #define BS 4096 18 | #define BUFFERS (FILE_SIZE / BS) 19 | 20 | static int do_iopoll(const char *fname) 21 | { 22 | struct io_uring_sqe *sqe; 23 | struct io_uring ring; 24 | struct iovec *iov; 25 | int fd; 26 | 27 | fd = open(fname, O_RDONLY | O_DIRECT); 28 | if (fd < 0) { 29 | if (errno == EINVAL || errno == EPERM || errno == EACCES) 30 | return T_EXIT_SKIP; 31 | perror("open"); 32 | return T_EXIT_SKIP; 33 | } 34 | 35 | iov = t_create_buffers(1, 4096); 36 | 37 | t_create_ring(2, &ring, IORING_SETUP_IOPOLL); 38 | 39 | sqe = io_uring_get_sqe(&ring); 40 | io_uring_prep_read(sqe, fd, iov->iov_base, iov->iov_len, 0); 41 | io_uring_submit(&ring); 42 | 43 | close(fd); 44 | free(iov->iov_base); 45 | free(iov); 46 | return T_EXIT_PASS; 47 | } 48 | 49 | static int test(const char *fname) 50 | { 51 | if (fork()) { 52 | int stat; 53 | 54 | wait(&stat); 55 | return WEXITSTATUS(stat); 56 | } else { 57 | int ret; 58 | 59 | ret = do_iopoll(fname); 60 | exit(ret); 61 | } 62 | } 63 | 64 | int main(int argc, char *argv[]) 65 | { 66 | char buf[256]; 67 | char *fname; 68 | int i, ret; 69 | 70 | if (argc > 1) { 71 | fname = argv[1]; 72 | } else { 73 | srand((unsigned)time(NULL)); 74 | snprintf(buf, sizeof(buf), ".iopoll-leak-%u-%u", 75 | (unsigned)rand(), (unsigned)getpid()); 76 | fname = buf; 77 | t_create_file(fname, FILE_SIZE); 78 | } 79 | 80 | for (i = 0; i < 16; i++) { 81 | ret = test(fname); 82 | if (ret == T_EXIT_SKIP || ret == T_EXIT_FAIL) 83 | break; 84 | } 85 | 86 | if (fname != argv[1]) 87 | unlink(fname); 88 | return ret; 89 | } 90 | -------------------------------------------------------------------------------- /test/napi-test.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | 3 | if [ ! -x "$(command -v ip)" ]; then 4 | echo "Need ip installed" 5 | exit 77 6 | fi 7 | if [ ! -x "$(command -v ethtool)" ]; then 8 | echo "Need ethool installed" 9 | exit 77 10 | fi 11 | 12 | function clean_namespaces { 13 | ip netns del iou-nscl 14 | ip netns del iou-nsserv 15 | } 16 | trap clean_namespaces EXIT 17 | 18 | ip link add iou-ptp-cl type veth peer name iou-ptp-serv 19 | 20 | ip netns add iou-nscl 21 | ip link set iou-ptp-cl netns iou-nscl 22 | ip netns exec iou-nscl ip addr add '10.10.10.10/24' dev iou-ptp-cl 23 | ip netns exec iou-nscl ethtool -K iou-ptp-cl tcp-segmentation-offload off 24 | ip netns exec iou-nscl ethtool -K iou-ptp-cl generic-receive-offload on 25 | ip netns exec iou-nscl ip link set dev iou-ptp-cl up 26 | 27 | ip netns add iou-nsserv 28 | ip link set iou-ptp-serv netns iou-nsserv 29 | ip netns exec iou-nsserv ip addr add '10.10.10.20/24' dev iou-ptp-serv 30 | ip netns exec iou-nsserv ethtool -K iou-ptp-serv tcp-segmentation-offload off 31 | ip netns exec iou-nsserv ethtool -K iou-ptp-serv generic-receive-offload on 32 | ip netns exec iou-nsserv ip link set dev iou-ptp-serv up 33 | 34 | # test basic init, defer_taskrun, and sqpoll 35 | QUEUE_FLAGS="0x0 0x3000 0x2" 36 | for flags in $QUEUE_FLAGS; do 37 | if [ -f "napi-test.t" ]; then 38 | NAPI_TEST="./napi-test.t" 39 | elif [ -f "test/napi-test.t" ]; then 40 | NAPI_TEST="test/napi-test.t" 41 | else 42 | echo "Can't find napi-test.t" 43 | exit 77 44 | fi 45 | ip netns exec iou-nsserv $NAPI_TEST receive $flags & 46 | ip netns exec iou-nscl $NAPI_TEST send $flags 47 | wait 48 | done 49 | -------------------------------------------------------------------------------- /test/no-mmap-inval.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Description: test that using SETUP_NO_MMAP with an invalid SQ ring 4 | * address fails. 5 | * 6 | */ 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "liburing.h" 13 | #include "helpers.h" 14 | 15 | int main(int argc, char *argv[]) 16 | { 17 | struct io_uring_params p = { 18 | .sq_entries = 2, 19 | .cq_entries = 4, 20 | .flags = IORING_SETUP_NO_MMAP, 21 | }; 22 | struct io_uring ring; 23 | void *addr; 24 | int ret; 25 | 26 | if (argc > 1) 27 | return T_EXIT_SKIP; 28 | 29 | t_posix_memalign(&addr, sysconf(_SC_PAGESIZE), 8192); 30 | p.cq_off.user_addr = (unsigned long long) (uintptr_t) addr; 31 | 32 | ret = io_uring_queue_init_params(2, &ring, &p); 33 | if (ret == -EINVAL || ret == -ENOENT) { 34 | /* kernel doesn't support SETUP_NO_MMAP */ 35 | free(addr); 36 | return T_EXIT_SKIP; 37 | } else if (ret && (ret != -EFAULT && ret != -ENOMEM)) { 38 | fprintf(stderr, "Got %d, wanted -EFAULT\n", ret); 39 | return T_EXIT_FAIL; 40 | } 41 | 42 | free(addr); 43 | return T_EXIT_PASS; 44 | } 45 | -------------------------------------------------------------------------------- /test/nolibc.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Test liburing nolibc functionality. 4 | * 5 | * Currently, supported architectures are: 6 | * 1) x86 7 | * 2) x86-64 8 | * 3) aarch64 9 | * 4) riscv64 10 | * 11 | */ 12 | #include "helpers.h" 13 | 14 | #if !defined(__x86_64__) && !defined(__i386__) && !defined(__aarch64__) && (!defined(__riscv) && __riscv_xlen != 64) 15 | 16 | 17 | /* 18 | * This arch doesn't support nolibc. 19 | */ 20 | int main(void) 21 | { 22 | return T_EXIT_SKIP; 23 | } 24 | 25 | #else /* #if !defined(__x86_64__) && !defined(__i386__) && !defined(__aarch64__) && (!defined(__riscv) && __riscv_xlen != 64) */ 26 | 27 | #ifndef CONFIG_NOLIBC 28 | #define CONFIG_NOLIBC 29 | #endif 30 | 31 | #include 32 | #include 33 | #include "../src/lib.h" 34 | 35 | static int test_get_page_size(void) 36 | { 37 | long a, b; 38 | 39 | a = sysconf(_SC_PAGESIZE); 40 | b = get_page_size(); 41 | if (a != b) { 42 | fprintf(stderr, "get_page_size() fails, %ld != %ld", a, b); 43 | return -1; 44 | } 45 | return 0; 46 | } 47 | 48 | int main(int argc, char *argv[]) 49 | { 50 | int ret; 51 | 52 | if (argc > 1) 53 | return T_EXIT_SKIP; 54 | 55 | ret = test_get_page_size(); 56 | if (ret) 57 | return T_EXIT_FAIL; 58 | 59 | return T_EXIT_PASS; 60 | } 61 | 62 | #endif /* #if !defined(__x86_64__) && !defined(__i386__) && !defined(__aarch64__) && (!defined(__riscv) && __riscv_xlen != 64) */ 63 | -------------------------------------------------------------------------------- /test/nop-all-sizes.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Description: exercise full filling of SQ and CQ ring 4 | * 5 | */ 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "liburing.h" 14 | 15 | #define MAX_ENTRIES 32768 16 | 17 | static int fill_nops(struct io_uring *ring) 18 | { 19 | struct io_uring_sqe *sqe; 20 | int filled = 0; 21 | 22 | do { 23 | sqe = io_uring_get_sqe(ring); 24 | if (!sqe) 25 | break; 26 | 27 | io_uring_prep_nop(sqe); 28 | filled++; 29 | } while (1); 30 | 31 | return filled; 32 | } 33 | 34 | static int test_nops(struct io_uring *ring) 35 | { 36 | struct io_uring_cqe *cqe; 37 | int ret, nr, total = 0, i; 38 | 39 | nr = fill_nops(ring); 40 | 41 | ret = io_uring_submit(ring); 42 | if (ret != nr) { 43 | fprintf(stderr, "submit %d, wanted %d\n", ret, nr); 44 | goto err; 45 | } 46 | total += ret; 47 | 48 | nr = fill_nops(ring); 49 | 50 | ret = io_uring_submit(ring); 51 | if (ret != nr) { 52 | fprintf(stderr, "submit %d, wanted %d\n", ret, nr); 53 | goto err; 54 | } 55 | total += ret; 56 | 57 | for (i = 0; i < total; i++) { 58 | ret = io_uring_wait_cqe(ring, &cqe); 59 | if (ret < 0) { 60 | fprintf(stderr, "wait completion %d\n", ret); 61 | goto err; 62 | } 63 | 64 | io_uring_cqe_seen(ring, cqe); 65 | } 66 | return 0; 67 | err: 68 | return 1; 69 | } 70 | 71 | int main(int argc, char *argv[]) 72 | { 73 | struct io_uring ring; 74 | int ret, depth; 75 | 76 | if (argc > 1) 77 | return 0; 78 | 79 | depth = 1; 80 | while (depth <= MAX_ENTRIES) { 81 | ret = io_uring_queue_init(depth, &ring, 0); 82 | if (ret) { 83 | if (ret == -ENOMEM) 84 | break; 85 | fprintf(stderr, "ring setup failed: %d\n", ret); 86 | return 1; 87 | } 88 | 89 | ret = test_nops(&ring); 90 | if (ret) { 91 | fprintf(stderr, "test_single_nop failed\n"); 92 | return ret; 93 | } 94 | depth <<= 1; 95 | io_uring_queue_exit(&ring); 96 | } 97 | 98 | return 0; 99 | } 100 | -------------------------------------------------------------------------------- /test/ooo-file-unreg.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Description: Test that out-of-order file updates with inflight requests 4 | * work as expected. 5 | * 6 | */ 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "liburing.h" 15 | #include "helpers.h" 16 | 17 | int main(int argc, char *argv[]) 18 | { 19 | struct io_uring_sqe *sqe; 20 | int res, fds[2], sockid; 21 | struct io_uring ring; 22 | 23 | if (argc > 1) 24 | return T_EXIT_SKIP; 25 | 26 | res = io_uring_queue_init(1, &ring, 0); 27 | if (res) { 28 | fprintf(stderr, "queue_init: %d\n", res); 29 | return T_EXIT_FAIL; 30 | } 31 | 32 | res = io_uring_register_files_sparse(&ring, 2); 33 | if (res) { 34 | if (res == -EINVAL) 35 | return T_EXIT_SKIP; 36 | fprintf(stderr, "sparse reg: %d\n", res); 37 | return T_EXIT_FAIL; 38 | } 39 | 40 | fds[0] = socket(AF_INET, SOCK_DGRAM, 0); 41 | if (fds[0] < 0) { 42 | perror("socket"); 43 | return T_EXIT_FAIL; 44 | } 45 | fds[1] = socket(AF_INET, SOCK_DGRAM, 0); 46 | if (fds[1] < 0) { 47 | perror("socket"); 48 | return T_EXIT_FAIL; 49 | } 50 | 51 | res = io_uring_register_files_update(&ring, 0, fds, 2); 52 | if (res != 2) { 53 | fprintf(stderr, "files updates; %d\n", res); 54 | return T_EXIT_FAIL; 55 | } 56 | 57 | sqe = io_uring_get_sqe(&ring); 58 | io_uring_prep_poll_add(sqe, 0, POLLIN); 59 | sqe->flags = IOSQE_FIXED_FILE; 60 | io_uring_submit(&ring); 61 | 62 | close(fds[0]); 63 | close(fds[1]); 64 | 65 | sockid = -1; 66 | res = io_uring_register_files_update(&ring, 1, &sockid, 1); 67 | if (res != 1) { 68 | fprintf(stderr, "files updates; %d\n", res); 69 | return T_EXIT_FAIL; 70 | } 71 | 72 | sockid = -1; 73 | res = io_uring_register_files_update(&ring, 0, &sockid, 1); 74 | if (res != 1) { 75 | fprintf(stderr, "files updates; %d\n", res); 76 | return T_EXIT_FAIL; 77 | } 78 | 79 | sleep(1); 80 | io_uring_queue_exit(&ring); 81 | return T_EXIT_PASS; 82 | } 83 | -------------------------------------------------------------------------------- /test/pipe-eof.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | 3 | /* 4 | * Test that closed pipe reads returns 0, instead of waiting for more 5 | * data. 6 | */ 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "liburing.h" 14 | #include "helpers.h" 15 | 16 | #define BUFSIZE 512 17 | 18 | struct data { 19 | char *str; 20 | int fds[2]; 21 | }; 22 | 23 | static void *t(void *data) 24 | { 25 | struct data *d = data; 26 | int ret; 27 | 28 | strcpy(d->str, "This is a test string"); 29 | ret = write(d->fds[1], d->str, strlen(d->str)); 30 | close(d->fds[1]); 31 | if (ret < 0) 32 | perror("write"); 33 | 34 | return NULL; 35 | } 36 | 37 | int main(int argc, char *argv[]) 38 | { 39 | static char buf[BUFSIZE]; 40 | struct io_uring ring; 41 | pthread_t thread; 42 | struct data d; 43 | int ret; 44 | 45 | if (argc > 1) 46 | return T_EXIT_SKIP; 47 | 48 | if (pipe(d.fds) < 0) { 49 | perror("pipe"); 50 | return 1; 51 | } 52 | d.str = buf; 53 | 54 | ret = io_uring_queue_init(8, &ring, 0); 55 | if (ret == -ENOMEM) { 56 | return T_EXIT_SKIP; 57 | } else if (ret) { 58 | fprintf(stderr, "queue_init: %d\n", ret); 59 | return T_EXIT_FAIL; 60 | } 61 | 62 | pthread_create(&thread, NULL, t, &d); 63 | 64 | while (1) { 65 | struct io_uring_sqe *sqe; 66 | struct io_uring_cqe *cqe; 67 | 68 | sqe = io_uring_get_sqe(&ring); 69 | io_uring_prep_read(sqe, d.fds[0], buf, BUFSIZE, 0); 70 | ret = io_uring_submit(&ring); 71 | if (ret != 1) { 72 | fprintf(stderr, "submit: %d\n", ret); 73 | return 1; 74 | } 75 | ret = io_uring_wait_cqe(&ring, &cqe); 76 | if (ret) { 77 | fprintf(stderr, "wait: %d\n", ret); 78 | return 1; 79 | } 80 | 81 | if (cqe->res < 0) { 82 | fprintf(stderr, "Read error: %s\n", strerror(-cqe->res)); 83 | return 1; 84 | } 85 | if (cqe->res == 0) 86 | break; 87 | io_uring_cqe_seen(&ring, cqe); 88 | } 89 | 90 | pthread_join(thread, NULL); 91 | io_uring_queue_exit(&ring); 92 | return 0; 93 | } 94 | -------------------------------------------------------------------------------- /test/poll-ring.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Description: Test poll against ring itself. A buggy kernel will end up 4 | * having io_wq_* workers pending, as the circular reference 5 | * will prevent full exit. 6 | * 7 | */ 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "liburing.h" 16 | 17 | int main(int argc, char *argv[]) 18 | { 19 | struct io_uring_sqe *sqe; 20 | struct io_uring ring; 21 | int ret; 22 | 23 | if (argc > 1) 24 | return 0; 25 | 26 | ret = io_uring_queue_init(1, &ring, 0); 27 | if (ret) { 28 | fprintf(stderr, "child: ring setup failed: %d\n", ret); 29 | return 1; 30 | } 31 | 32 | sqe = io_uring_get_sqe(&ring); 33 | if (!sqe) { 34 | fprintf(stderr, "get sqe failed\n"); 35 | return 1; 36 | } 37 | 38 | io_uring_prep_poll_add(sqe, ring.ring_fd, POLLIN); 39 | io_uring_sqe_set_data(sqe, sqe); 40 | 41 | ret = io_uring_submit(&ring); 42 | if (ret <= 0) { 43 | fprintf(stderr, "child: sqe submit failed: %d\n", ret); 44 | return 1; 45 | } 46 | 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /test/reg-hint.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Test alloc hint sanity after unregistering the file table 4 | */ 5 | #include 6 | #include 7 | #include 8 | 9 | #include "liburing.h" 10 | #include "helpers.h" 11 | 12 | int main(int argc, char *argv[]) 13 | { 14 | struct io_uring_sqe *sqe; 15 | struct io_uring_cqe *cqe; 16 | struct io_uring ring; 17 | int ret; 18 | 19 | if (argc > 1) 20 | return T_EXIT_SKIP; 21 | 22 | io_uring_queue_init(1, &ring, 0); 23 | 24 | ret = io_uring_register_files_sparse(&ring, 16); 25 | if (ret) { 26 | if (ret == -EINVAL) 27 | return T_EXIT_SKIP; 28 | 29 | fprintf(stderr, "Failed to register file table: %d\n", ret); 30 | return T_EXIT_FAIL; 31 | } 32 | io_uring_unregister_files(&ring); 33 | 34 | sqe = io_uring_get_sqe(&ring); 35 | io_uring_prep_socket_direct_alloc(sqe, AF_UNIX, SOCK_DGRAM, 0, 0); 36 | 37 | ret = io_uring_submit(&ring); 38 | if (ret != 1) { 39 | fprintf(stderr, "submit %d\n", ret); 40 | return T_EXIT_FAIL; 41 | } 42 | 43 | ret = io_uring_wait_cqe(&ring, &cqe); 44 | if (ret) { 45 | fprintf(stderr, "wait cqe: %d\n", ret); 46 | return T_EXIT_FAIL; 47 | } 48 | 49 | if (cqe->res != -ENFILE) { 50 | fprintf(stderr, "Bad CQE res: %d\n", cqe->res); 51 | return T_EXIT_FAIL; 52 | } 53 | 54 | io_uring_cqe_seen(&ring, cqe); 55 | return T_EXIT_PASS; 56 | } 57 | -------------------------------------------------------------------------------- /test/runtests-loop.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | TESTS=("$@") 4 | ITER=0 5 | 6 | while true; do 7 | ./runtests.sh "${TESTS[@]}" 8 | RET="$?" 9 | if [ "${RET}" -ne 0 ]; then 10 | echo "Tests failed at loop $ITER" 11 | break 12 | fi 13 | echo "Finished loop $ITER" 14 | ((ITER++)) 15 | done 16 | 17 | -------------------------------------------------------------------------------- /test/runtests-quiet.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | TESTS=("$@") 4 | RESULT_FILE=$(mktemp) 5 | ./runtests.sh "${TESTS[@]}" > "$RESULT_FILE" 2>&1 6 | RET="$?" 7 | if [ "${RET}" -ne 0 ]; then 8 | cat "$RESULT_FILE" 9 | fi 10 | rm "$RESULT_FILE" 11 | exit $RET 12 | -------------------------------------------------------------------------------- /test/self.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Description: test that pathname resolution works from async context when 4 | * using /proc/self/ which should be the original submitting task, not the 5 | * async worker. 6 | * 7 | */ 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "liburing.h" 16 | 17 | static int io_openat2(struct io_uring *ring, const char *path, int dfd) 18 | { 19 | struct io_uring_cqe *cqe; 20 | struct io_uring_sqe *sqe; 21 | struct open_how how; 22 | int ret; 23 | 24 | sqe = io_uring_get_sqe(ring); 25 | if (!sqe) { 26 | fprintf(stderr, "get sqe failed\n"); 27 | goto err; 28 | } 29 | memset(&how, 0, sizeof(how)); 30 | how.flags = O_RDONLY; 31 | io_uring_prep_openat2(sqe, dfd, path, &how); 32 | 33 | ret = io_uring_submit(ring); 34 | if (ret <= 0) { 35 | fprintf(stderr, "sqe submit failed: %d\n", ret); 36 | goto err; 37 | } 38 | 39 | ret = io_uring_wait_cqe(ring, &cqe); 40 | if (ret < 0) { 41 | fprintf(stderr, "wait completion %d\n", ret); 42 | goto err; 43 | } 44 | ret = cqe->res; 45 | io_uring_cqe_seen(ring, cqe); 46 | return ret; 47 | err: 48 | return -1; 49 | } 50 | 51 | int main(int argc, char *argv[]) 52 | { 53 | struct io_uring ring; 54 | char buf[64]; 55 | int ret; 56 | 57 | if (argc > 1) 58 | return 0; 59 | 60 | ret = io_uring_queue_init(1, &ring, 0); 61 | if (ret) { 62 | fprintf(stderr, "ring setup failed\n"); 63 | return 1; 64 | } 65 | 66 | ret = io_openat2(&ring, "/proc/self/comm", -1); 67 | if (ret < 0) { 68 | if (ret == -EOPNOTSUPP) 69 | return 0; 70 | if (ret == -EINVAL) { 71 | fprintf(stdout, "openat2 not supported, skipping\n"); 72 | return 0; 73 | } 74 | fprintf(stderr, "openat2 failed: %s\n", strerror(-ret)); 75 | return 1; 76 | } 77 | 78 | memset(buf, 0, sizeof(buf)); 79 | ret = read(ret, buf, sizeof(buf)); 80 | if (ret < 0) { 81 | perror("read"); 82 | return 1; 83 | } 84 | 85 | if (strncmp(buf, "self", 4)) { 86 | fprintf(stderr, "got comm=<%s>, wanted \n", buf); 87 | return 1; 88 | } 89 | 90 | return 0; 91 | } 92 | -------------------------------------------------------------------------------- /test/shared-wq.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Description: test wq sharing 4 | */ 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "liburing.h" 13 | 14 | static int test_attach_invalid(int ringfd) 15 | { 16 | struct io_uring_params p; 17 | struct io_uring ring; 18 | int ret; 19 | 20 | memset(&p, 0, sizeof(p)); 21 | p.flags = IORING_SETUP_ATTACH_WQ; 22 | p.wq_fd = ringfd; 23 | ret = io_uring_queue_init_params(1, &ring, &p); 24 | if (ret != -EINVAL) { 25 | fprintf(stderr, "Attach to zero: %d\n", ret); 26 | goto err; 27 | } 28 | return 0; 29 | err: 30 | return 1; 31 | } 32 | 33 | static int test_attach(int ringfd) 34 | { 35 | struct io_uring_params p; 36 | struct io_uring ring2; 37 | int ret; 38 | 39 | memset(&p, 0, sizeof(p)); 40 | p.flags = IORING_SETUP_ATTACH_WQ; 41 | p.wq_fd = ringfd; 42 | ret = io_uring_queue_init_params(1, &ring2, &p); 43 | if (ret == -EINVAL) { 44 | fprintf(stdout, "Sharing not supported, skipping\n"); 45 | return 0; 46 | } else if (ret) { 47 | fprintf(stderr, "Attach to id: %d\n", ret); 48 | goto err; 49 | } 50 | io_uring_queue_exit(&ring2); 51 | return 0; 52 | err: 53 | return 1; 54 | } 55 | 56 | int main(int argc, char *argv[]) 57 | { 58 | struct io_uring ring; 59 | int ret; 60 | 61 | if (argc > 1) 62 | return 0; 63 | 64 | ret = io_uring_queue_init(8, &ring, 0); 65 | if (ret) { 66 | fprintf(stderr, "ring setup failed\n"); 67 | return 1; 68 | } 69 | 70 | /* stdout is definitely not an io_uring descriptor */ 71 | ret = test_attach_invalid(2); 72 | if (ret) { 73 | fprintf(stderr, "test_attach_invalid failed\n"); 74 | return ret; 75 | } 76 | 77 | ret = test_attach(ring.ring_fd); 78 | if (ret) { 79 | fprintf(stderr, "test_attach failed\n"); 80 | return ret; 81 | } 82 | 83 | return 0; 84 | } 85 | -------------------------------------------------------------------------------- /test/short-read.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | #include "helpers.h" 13 | #include "liburing.h" 14 | 15 | #define BUF_SIZE 4096 16 | #define FILE_SIZE 1024 17 | 18 | int main(int argc, char *argv[]) 19 | { 20 | int ret, fd, save_errno; 21 | struct io_uring ring; 22 | struct io_uring_sqe *sqe; 23 | struct io_uring_cqe *cqe; 24 | struct iovec vec; 25 | 26 | if (argc > 1) 27 | return 0; 28 | 29 | vec.iov_base = t_malloc(BUF_SIZE); 30 | vec.iov_len = BUF_SIZE; 31 | 32 | t_create_file(".short-read", FILE_SIZE); 33 | 34 | fd = open(".short-read", O_RDONLY); 35 | save_errno = errno; 36 | unlink(".short-read"); 37 | errno = save_errno; 38 | if (fd < 0) { 39 | perror("file open"); 40 | return 1; 41 | } 42 | 43 | ret = io_uring_queue_init(32, &ring, 0); 44 | if (ret) { 45 | fprintf(stderr, "queue init failed: %d\n", ret); 46 | return ret; 47 | } 48 | 49 | sqe = io_uring_get_sqe(&ring); 50 | if (!sqe) { 51 | fprintf(stderr, "sqe get failed\n"); 52 | return 1; 53 | } 54 | io_uring_prep_readv(sqe, fd, &vec, 1, 0); 55 | 56 | ret = io_uring_submit(&ring); 57 | if (ret != 1) { 58 | fprintf(stderr, "submit failed: %d\n", ret); 59 | return 1; 60 | } 61 | 62 | ret = io_uring_wait_cqes(&ring, &cqe, 1, 0, 0); 63 | if (ret) { 64 | fprintf(stderr, "wait_cqe failed: %d\n", ret); 65 | return 1; 66 | } 67 | 68 | if (cqe->res != FILE_SIZE) { 69 | fprintf(stderr, "Read failed: %d\n", cqe->res); 70 | return 1; 71 | } 72 | 73 | io_uring_cqe_seen(&ring, cqe); 74 | free(vec.iov_base); 75 | return 0; 76 | } 77 | -------------------------------------------------------------------------------- /test/sigfd-deadlock.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Description: test that sigfd reading/polling works. A regression test for 4 | * the upstream commit: 5 | * 6 | * fd7d6de22414 ("io_uring: don't recurse on tsk->sighand->siglock with signalfd") 7 | */ 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "liburing.h" 14 | #include "helpers.h" 15 | 16 | static int setup_signal(void) 17 | { 18 | sigset_t mask; 19 | int sfd; 20 | 21 | sigemptyset(&mask); 22 | sigaddset(&mask, SIGINT); 23 | 24 | sigprocmask(SIG_BLOCK, &mask, NULL); 25 | sfd = signalfd(-1, &mask, SFD_NONBLOCK); 26 | if (sfd < 0) 27 | perror("signalfd"); 28 | return sfd; 29 | } 30 | 31 | static int test_uring(int sfd) 32 | { 33 | struct io_uring_sqe *sqe; 34 | struct io_uring_cqe *cqe; 35 | struct io_uring ring; 36 | int ret; 37 | 38 | ret = io_uring_queue_init(32, &ring, 0); 39 | if (ret) 40 | return T_EXIT_FAIL; 41 | 42 | sqe = io_uring_get_sqe(&ring); 43 | io_uring_prep_poll_add(sqe, sfd, POLLIN); 44 | ret = io_uring_submit(&ring); 45 | if (ret < 0) { 46 | ret = T_EXIT_FAIL; 47 | goto err_exit; 48 | } 49 | 50 | kill(getpid(), SIGINT); 51 | 52 | io_uring_wait_cqe(&ring, &cqe); 53 | if (cqe->res == -EOPNOTSUPP) { 54 | fprintf(stderr, "signalfd poll not supported\n"); 55 | ret = T_EXIT_SKIP; 56 | } else if (cqe->res < 0) { 57 | fprintf(stderr, "poll failed: %d\n", cqe->res); 58 | ret = T_EXIT_FAIL; 59 | } else if (cqe->res & POLLIN) { 60 | ret = T_EXIT_PASS; 61 | } else { 62 | fprintf(stderr, "Unexpected poll mask %x\n", cqe->res); 63 | ret = T_EXIT_FAIL; 64 | } 65 | io_uring_cqe_seen(&ring, cqe); 66 | err_exit: 67 | io_uring_queue_exit(&ring); 68 | return ret; 69 | } 70 | 71 | int main(int argc, char *argv[]) 72 | { 73 | int sfd, ret; 74 | 75 | if (argc > 1) 76 | return T_EXIT_PASS; 77 | 78 | sfd = setup_signal(); 79 | if (sfd < 0) 80 | return T_EXIT_FAIL; 81 | 82 | ret = test_uring(sfd); 83 | if (ret == T_EXIT_FAIL) 84 | fprintf(stderr, "test_uring signalfd failed\n"); 85 | 86 | close(sfd); 87 | return ret; 88 | } 89 | -------------------------------------------------------------------------------- /test/sq-full-cpp.cc: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Description: test SQ queue full condition 4 | * 5 | */ 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "liburing.h" 14 | 15 | int main(int argc, char *argv[]) 16 | { 17 | struct io_uring_sqe *sqe; 18 | struct io_uring ring; 19 | int ret, i; 20 | 21 | if (argc > 1) 22 | return 0; 23 | 24 | ret = io_uring_queue_init(8, &ring, 0); 25 | if (ret) { 26 | fprintf(stderr, "ring setup failed: %d\n", ret); 27 | return 1; 28 | 29 | } 30 | 31 | i = 0; 32 | while ((sqe = io_uring_get_sqe(&ring)) != NULL) 33 | i++; 34 | 35 | if (i != 8) { 36 | fprintf(stderr, "Got %d SQEs, wanted 8\n", i); 37 | goto err; 38 | } 39 | 40 | io_uring_queue_exit(&ring); 41 | return 0; 42 | err: 43 | io_uring_queue_exit(&ring); 44 | return 1; 45 | } 46 | -------------------------------------------------------------------------------- /test/sq-full.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Description: test SQ queue full condition 4 | * 5 | */ 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "liburing.h" 14 | 15 | int main(int argc, char *argv[]) 16 | { 17 | struct io_uring_sqe *sqe; 18 | struct io_uring ring; 19 | int ret, i; 20 | 21 | if (argc > 1) 22 | return 0; 23 | 24 | ret = io_uring_queue_init(8, &ring, 0); 25 | if (ret) { 26 | fprintf(stderr, "ring setup failed: %d\n", ret); 27 | return 1; 28 | 29 | } 30 | 31 | i = 0; 32 | while ((sqe = io_uring_get_sqe(&ring)) != NULL) 33 | i++; 34 | 35 | if (i != 8) { 36 | fprintf(stderr, "Got %d SQEs, wanted 8\n", i); 37 | goto err; 38 | } 39 | 40 | io_uring_queue_exit(&ring); 41 | return 0; 42 | err: 43 | io_uring_queue_exit(&ring); 44 | return 1; 45 | } 46 | -------------------------------------------------------------------------------- /test/sqpoll-exit-hang.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Test that we exit properly with SQPOLL and having a request that 4 | * adds a circular reference to the ring itself. 5 | */ 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "liburing.h" 13 | #include "helpers.h" 14 | 15 | int main(int argc, char *argv[]) 16 | { 17 | struct io_uring_params p = {}; 18 | struct timeval tv; 19 | struct io_uring ring; 20 | struct io_uring_sqe *sqe; 21 | int ret; 22 | 23 | if (argc > 1) 24 | return 0; 25 | 26 | p.flags = IORING_SETUP_SQPOLL; 27 | p.sq_thread_idle = 100; 28 | 29 | ret = io_uring_queue_init_params(1, &ring, &p); 30 | if (ret) { 31 | if (geteuid()) { 32 | printf("%s: skipped, not root\n", argv[0]); 33 | return 0; 34 | } 35 | fprintf(stderr, "queue_init=%d\n", ret); 36 | return 1; 37 | } 38 | 39 | if (!(p.features & IORING_FEAT_SQPOLL_NONFIXED)) { 40 | fprintf(stdout, "Skipping\n"); 41 | return 0; 42 | } 43 | 44 | sqe = io_uring_get_sqe(&ring); 45 | io_uring_prep_poll_add(sqe, ring.ring_fd, POLLIN); 46 | io_uring_submit(&ring); 47 | 48 | gettimeofday(&tv, NULL); 49 | do { 50 | usleep(1000); 51 | } while (mtime_since_now(&tv) < 1000); 52 | 53 | return 0; 54 | } 55 | -------------------------------------------------------------------------------- /test/sqpoll-sleep.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Test that the sqthread goes to sleep around the specified time, and that 4 | * the NEED_WAKEUP flag is then set. 5 | */ 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "liburing.h" 12 | #include "helpers.h" 13 | 14 | int main(int argc, char *argv[]) 15 | { 16 | struct io_uring_params p = {}; 17 | struct io_uring_sqe *sqe; 18 | struct io_uring_cqe *cqe; 19 | struct timeval tv; 20 | struct io_uring ring; 21 | unsigned long elapsed; 22 | bool seen_wakeup; 23 | int ret; 24 | 25 | if (argc > 1) 26 | return T_EXIT_SKIP; 27 | 28 | p.flags = IORING_SETUP_SQPOLL; 29 | p.sq_thread_idle = 100; 30 | 31 | ret = io_uring_queue_init_params(1, &ring, &p); 32 | if (ret) { 33 | if (geteuid()) { 34 | printf("%s: skipped, not root\n", argv[0]); 35 | return T_EXIT_SKIP; 36 | } 37 | fprintf(stderr, "queue_init=%d\n", ret); 38 | return T_EXIT_FAIL; 39 | } 40 | 41 | sqe = io_uring_get_sqe(&ring); 42 | io_uring_prep_nop(sqe); 43 | io_uring_submit(&ring); 44 | 45 | ret = io_uring_wait_cqe(&ring, &cqe); 46 | if (ret) { 47 | fprintf(stderr, "wait_cqe: %d\n", ret); 48 | return T_EXIT_FAIL; 49 | } 50 | io_uring_cqe_seen(&ring, cqe); 51 | 52 | elapsed = 0; 53 | seen_wakeup = false; 54 | gettimeofday(&tv, NULL); 55 | do { 56 | usleep(100); 57 | if (IO_URING_READ_ONCE(*ring.sq.kflags) & IORING_SQ_NEED_WAKEUP) { 58 | seen_wakeup = true; 59 | break; 60 | } 61 | elapsed = mtime_since_now(&tv); 62 | } while (elapsed < 1000); 63 | 64 | if (!seen_wakeup) { 65 | fprintf(stderr, "SQPOLL didn't flag wakeup\n"); 66 | return T_EXIT_FAIL; 67 | } 68 | 69 | /* should be around 100 msec */ 70 | if (elapsed < 90 || elapsed > 110) { 71 | fprintf(stderr, "SQPOLL wakeup timing off %lu\n", elapsed); 72 | return T_EXIT_FAIL; 73 | } 74 | 75 | return T_EXIT_PASS; 76 | } 77 | -------------------------------------------------------------------------------- /test/submit-and-wait.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Description: Test that io_uring_submit_and_wait_timeout() returns the 4 | * right value (submit count) and that it doesn't end up waiting twice. 5 | * 6 | */ 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "liburing.h" 16 | #include "helpers.h" 17 | #include "test.h" 18 | 19 | static int test(struct io_uring *ring) 20 | { 21 | struct io_uring_cqe *cqe; 22 | struct io_uring_sqe *sqe; 23 | struct __kernel_timespec ts; 24 | struct timeval tv; 25 | int ret, i; 26 | 27 | for (i = 0; i < 1; i++) { 28 | sqe = io_uring_get_sqe(ring); 29 | if (!sqe) { 30 | fprintf(stderr, "get sqe failed at %d\n", i); 31 | goto err; 32 | } 33 | io_uring_prep_nop(sqe); 34 | } 35 | 36 | ts.tv_sec = 1; 37 | ts.tv_nsec = 0; 38 | gettimeofday(&tv, NULL); 39 | ret = io_uring_submit_and_wait_timeout(ring, &cqe, 2, &ts, NULL); 40 | if (ret < 0) { 41 | fprintf(stderr, "submit_and_wait_timeout: %d\n", ret); 42 | goto err; 43 | } 44 | ret = mtime_since_now(&tv); 45 | /* allow some slack, should be around 1s */ 46 | if (ret > 1200) { 47 | fprintf(stderr, "wait took too long: %d\n", ret); 48 | goto err; 49 | } 50 | return 0; 51 | err: 52 | return 1; 53 | } 54 | 55 | static int test_ring(void) 56 | { 57 | struct io_uring ring; 58 | struct io_uring_params p = { }; 59 | int ret; 60 | 61 | p.flags = 0; 62 | ret = io_uring_queue_init_params(8, &ring, &p); 63 | if (ret) { 64 | fprintf(stderr, "ring setup failed: %d\n", ret); 65 | return 1; 66 | } 67 | 68 | ret = test(&ring); 69 | if (ret) { 70 | fprintf(stderr, "test failed\n"); 71 | goto err; 72 | } 73 | err: 74 | io_uring_queue_exit(&ring); 75 | return ret; 76 | } 77 | 78 | int main(int argc, char *argv[]) 79 | { 80 | if (argc > 1) 81 | return 0; 82 | 83 | return test_ring(); 84 | } 85 | -------------------------------------------------------------------------------- /test/teardowns.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "liburing.h" 12 | 13 | static void loop(void) 14 | { 15 | int i, ret = 0; 16 | 17 | for (i = 0; i < 100; i++) { 18 | struct io_uring ring; 19 | int fd; 20 | 21 | memset(&ring, 0, sizeof(ring)); 22 | fd = io_uring_queue_init(0xa4, &ring, 0); 23 | if (fd >= 0) { 24 | close(fd); 25 | continue; 26 | } 27 | if (fd != -ENOMEM) 28 | ret++; 29 | } 30 | exit(ret); 31 | } 32 | 33 | int main(int argc, char *argv[]) 34 | { 35 | int i, ret, status; 36 | 37 | if (argc > 1) 38 | return 0; 39 | 40 | for (i = 0; i < 12; i++) { 41 | if (!fork()) { 42 | loop(); 43 | break; 44 | } 45 | } 46 | 47 | ret = 0; 48 | for (i = 0; i < 12; i++) { 49 | if (waitpid(-1, &status, 0) < 0) { 50 | perror("waitpid"); 51 | return 1; 52 | } 53 | if (WEXITSTATUS(status)) 54 | ret++; 55 | } 56 | 57 | return ret; 58 | } 59 | -------------------------------------------------------------------------------- /test/test.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Description: Test configs for tests. 4 | */ 5 | #ifndef LIBURING_TEST_H 6 | #define LIBURING_TEST_H 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | typedef struct io_uring_test_config { 13 | unsigned int flags; 14 | const char *description; 15 | } io_uring_test_config; 16 | 17 | __attribute__((__unused__)) 18 | static io_uring_test_config io_uring_test_configs[] = { 19 | { 0, "default" }, 20 | { IORING_SETUP_SQE128, "large SQE"}, 21 | { IORING_SETUP_CQE32, "large CQE"}, 22 | { IORING_SETUP_SQE128 | IORING_SETUP_CQE32, "large SQE/CQE" }, 23 | }; 24 | 25 | #define FOR_ALL_TEST_CONFIGS \ 26 | for (int i = 0; i < sizeof(io_uring_test_configs) / sizeof(io_uring_test_configs[0]); i++) 27 | 28 | #define IORING_GET_TEST_CONFIG_FLAGS() (io_uring_test_configs[i].flags) 29 | #define IORING_GET_TEST_CONFIG_DESCRIPTION() (io_uring_test_configs[i].description) 30 | 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /test/tty-write-dpoll.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Test double poll tty write. A test case for the regression fixed by: 4 | * 5 | * commit 6e295a664efd083ac9a5c1a8130c45be1db0cde7 6 | * Author: Jens Axboe 7 | * Date: Tue Mar 22 13:11:28 2022 -0600 8 | * 9 | * io_uring: fix assuming triggered poll waitqueue is the single poll 10 | * 11 | */ 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include "liburing.h" 19 | #include "helpers.h" 20 | 21 | #define SQES 128 22 | #define BUFSIZE 512 23 | 24 | int main(int argc, char *argv[]) 25 | { 26 | static char buf[BUFSIZE]; 27 | struct iovec vecs[SQES]; 28 | struct io_uring ring; 29 | int ret, i, fd; 30 | 31 | if (argc > 1) 32 | return 0; 33 | 34 | fd = open("/dev/ttyS0", O_RDWR | O_NONBLOCK); 35 | if (fd < 0) 36 | return 0; 37 | 38 | ret = t_create_ring(SQES, &ring, 0); 39 | if (ret == T_SETUP_SKIP) 40 | return 0; 41 | else if (ret < 0) 42 | return 1; 43 | 44 | for (i = 0; i < SQES; i++) { 45 | struct io_uring_sqe *sqe; 46 | 47 | sqe = io_uring_get_sqe(&ring); 48 | vecs[i].iov_base = buf; 49 | vecs[i].iov_len = sizeof(buf); 50 | io_uring_prep_writev(sqe, fd, &vecs[i], 1, 0); 51 | } 52 | 53 | ret = io_uring_submit(&ring); 54 | if (ret != SQES) { 55 | fprintf(stderr, "submit: %d\n", ret); 56 | return 1; 57 | } 58 | 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /test/version.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Description: check version macros and runtime checks work 4 | * 5 | */ 6 | #include "liburing.h" 7 | #include "helpers.h" 8 | 9 | int main(int argc, char *argv[]) 10 | { 11 | if (IO_URING_CHECK_VERSION(io_uring_major_version(), io_uring_minor_version())) 12 | return T_EXIT_FAIL; 13 | 14 | if (io_uring_major_version() != IO_URING_VERSION_MAJOR) 15 | return T_EXIT_FAIL; 16 | 17 | if (io_uring_minor_version() != IO_URING_VERSION_MINOR) 18 | return T_EXIT_FAIL; 19 | 20 | #if IO_URING_CHECK_VERSION(IO_URING_VERSION_MAJOR, IO_URING_VERSION_MINOR) 21 | return T_EXIT_FAIL; 22 | #endif 23 | 24 | return T_EXIT_PASS; 25 | } 26 | -------------------------------------------------------------------------------- /test/xfail_prep_link_timeout_out_of_scope.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Description: Check to see if the asan checks catch an stack-use-after-free for prep_link_timeout 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "liburing.h" 12 | #include "helpers.h" 13 | 14 | #include 15 | 16 | int main(int argc, char *argv[]) 17 | { 18 | struct io_uring ring; 19 | struct io_uring_sqe *sqe; 20 | int ret; 21 | 22 | if (argc > 1) 23 | return T_EXIT_SKIP; 24 | 25 | ret = io_uring_queue_init(8, &ring, 0); 26 | if (ret < 0) { 27 | printf("io_uring_queue_init ret %i\n", ret); 28 | return T_EXIT_PASS; // this test expects an inverted exit code 29 | } 30 | 31 | // force timespec to go out of scope, test "passes" if asan catches this bug. 32 | { 33 | struct __kernel_timespec timespec; 34 | timespec.tv_sec = 0; 35 | timespec.tv_nsec = 5000; 36 | 37 | sqe = io_uring_get_sqe(&ring); 38 | io_uring_prep_timeout(sqe, ×pec, 0, 0); 39 | io_uring_sqe_set_data(sqe, (void *) 1); 40 | } 41 | 42 | ret = io_uring_submit_and_wait(&ring, 1); 43 | printf("submit_and_wait %i\n", ret); 44 | 45 | return T_EXIT_PASS; // this test expects an inverted exit code 46 | } 47 | -------------------------------------------------------------------------------- /test/xfail_register_buffers_out_of_scope.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT */ 2 | /* 3 | * Description: Check to see if the asan checks catch an stack-use-after-free for io_uring_sqe_set_data 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "liburing.h" 13 | #include "helpers.h" 14 | 15 | #include 16 | 17 | #define BUFFERS 8 18 | #define BUFFER_SIZE 128 19 | 20 | int main(int argc, char *argv[]) 21 | { 22 | struct io_uring ring; 23 | struct iovec *iovs; 24 | int i; 25 | int ret; 26 | 27 | if (argc > 1) 28 | return T_EXIT_SKIP; 29 | 30 | ret = io_uring_queue_init(8, &ring, 0); 31 | if (ret < 0) { 32 | printf("io_uring_queue_init ret %i\n", ret); 33 | return T_EXIT_PASS; // this test expects an inverted exit code 34 | } 35 | 36 | iovs = calloc(BUFFERS, sizeof(struct iovec)); 37 | for (i = 0; i < BUFFERS; i++) { 38 | iovs[i].iov_base = malloc(BUFFER_SIZE); 39 | iovs[i].iov_len = BUFFER_SIZE; 40 | } 41 | // force one iov_base to be freed, test "passes" if asan catches this bug. 42 | free(iovs[4].iov_base); 43 | 44 | ret = io_uring_register_buffers(&ring, iovs, BUFFERS); 45 | printf("io_uring_register_buffers %i\n", ret); 46 | 47 | ret = io_uring_submit_and_wait(&ring, 1); 48 | printf("submit_and_wait %i\n", ret); 49 | 50 | return T_EXIT_PASS; // this test expects an inverted exit code 51 | } 52 | --------------------------------------------------------------------------------