···11+liburing-2.4 release
22+33+- Add io_uring_{major,minor,check}_version() functions.
44+- Add IO_URING_{MAJOR,MINOR,CHECK}_VERSION() macros.
55+- FFI support (for non-C/C++ languages integration).
66+- Add io_uring_prep_msg_ring_cqe_flags() function.
77+- Deprecate --nolibc configure option.
88+- CONFIG_NOLIBC is always enabled on x86-64, x86, and aarch64.
99+- Add support for IORING_REGISTER_USE_REGISTERED_RING and use if available.
1010+- Add io_uring_close_ring_fd() function.
1111+- Add io_uring_prep_msg_ring_fd_alloc function.
1212+- Add io_uring_free_buf_ring() and io_uring_setup_buf_ring() functions.
1313+- Ensure that io_uring_prep_accept_direct(), io_uring_prep_openat_direct(),
1414+ io_uring_prep_openat2_direct(), io_uring_prep_msg_ring_fd(), and
1515+ io_uring_prep_socket_direct() factor in being called with
1616+ IORING_FILE_INDEX_ALLOC for allocating a direct descriptor.
1717+- Add io_uring_prep_sendto() function.
1818+119liburing-2.3 release
220321- Support non-libc build for aarch64.
···4747pass on older kernels, and may even crash or hang older kernels!
484849495050+Building liburing
5151+-----------------
5252+5353+ #
5454+ # Prepare build config (optional).
5555+ #
5656+ # --cc specifies the C compiler.
5757+ # --cxx speficies the C++ compiler.
5858+ #
5959+ ./configure --cc=gcc --cxx=g++;
6060+6161+ #
6262+ # Build liburing.
6363+ #
6464+ make -j$(nproc);
6565+6666+ #
6767+ # Install liburing (headers, shared/static libs, and manpage).
6868+ #
6969+ sudo make install;
7070+7171+See './configure --help' for more information about build config options.
7272+7373+7474+FFI support
7575+-----------
7676+7777+By default, the build results in 4 lib files:
7878+7979+ 2 shared libs:
8080+8181+ liburing.so
8282+ liburing-ffi.so
8383+8484+ 2 static libs:
8585+8686+ liburing.a
8787+ liburing-ffi.a
8888+8989+Languages and applications that can't use 'static inline' functions in
9090+liburing.h should use the FFI variants.
9191+9292+liburing's main public interface lives in liburing.h as 'static inline'
9393+functions. Users wishing to consume liburing purely as a binary dependency
9494+should link against liburing-ffi. It contains definitions for every 'static
9595+inline' function.
9696+9797+5098License
5199-------
52100
+76-6
vendor/opam/uring/vendor/liburing/configure
···55cc=${CC:-gcc}
66cxx=${CXX:-g++}
7788+#
99+# TODO(ammarfaizi2): Remove this notice and `--nolibc` option.
1010+#
1111+nolibc_deprecated() {
1212+ echo "";
1313+ echo "=================================================================";
1414+ echo "";
1515+ echo " --nolibc option is deprecated and has no effect.";
1616+ echo " It will be removed in a future liburing release.";
1717+ echo "";
1818+ echo " liburing on x86-64, x86 (32-bit) and aarch64 always use CONFIG_NOLIBC.";
1919+ echo "";
2020+ echo "=================================================================";
2121+ echo "";
2222+}
2323+824for opt do
925 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)' || true)
1026 case "$opt" in
···2642 ;;
2743 --cxx=*) cxx="$optarg"
2844 ;;
2929- --nolibc) liburing_nolibc="yes"
4545+ --nolibc) nolibc_deprecated
3046 ;;
3147 *)
3248 echo "ERROR: unknown option $opt"
···115131}
116132117133# Default CFLAGS
118118-CFLAGS="-D_GNU_SOURCE -include config-host.h"
134134+CFLAGS="-D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -include config-host.h"
119135BUILD_CFLAGS=""
120136121137# Print configure header at the top of $config_host_h
···385401print_config "NVMe uring command support" "$nvme_uring_cmd"
386402387403#############################################################################
404404+#
405405+# Currently, CONFIG_NOLIBC is only enabled on x86-64, x86 (32-bit) and aarch64.
406406+#
407407+cat > $TMPC << EOF
408408+int main(void){
409409+#if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__)
410410+ return 0;
411411+#else
412412+#error libc is needed
413413+#endif
414414+}
415415+EOF
416416+if compile_prog "" "" "nolibc support"; then
417417+ liburing_nolibc="yes"
418418+fi
419419+print_config "nolibc support" "$liburing_nolibc";
420420+#############################################################################
421421+422422+####################################################
423423+# Most Android devices don't have sys/fanotify.h
424424+has_fanotify="no"
425425+cat > $TMPC << EOF
426426+#include <sys/fanotify.h>
427427+int main(void)
428428+{
429429+ return 0;
430430+}
431431+EOF
432432+if compile_prog "" "" "fanotify"; then
433433+ has_fanotify="yes"
434434+fi
435435+print_config "has_fanotify" "$has_fanotify"
436436+####################################################
437437+388438if test "$liburing_nolibc" = "yes"; then
389439 output_sym "CONFIG_NOLIBC"
390390-else
391391- liburing_nolibc="no"
392440fi
393393-print_config "liburing_nolibc" "$liburing_nolibc"
394394-395441if test "$__kernel_rwf_t" = "yes"; then
396442 output_sym "CONFIG_HAVE_KERNEL_RWF_T"
397443fi
···422468if test "$nvme_uring_cmd" = "yes"; then
423469 output_sym "CONFIG_HAVE_NVME_URING"
424470fi
471471+if test "$has_fanotify" = "yes"; then
472472+ output_sym "CONFIG_HAVE_FANOTIFY"
473473+fi
425474426475echo "CC=$cc" >> $config_host_mak
427476print_config "CC" "$cc"
428477echo "CXX=$cxx" >> $config_host_mak
429478print_config "CXX" "$cxx"
430479480480+# generate io_uring_version.h
481481+MAKE_PRINT_VARS="include Makefile.common\nprint-%: ; @echo \$(\$*)\n"
482482+VERSION_MAJOR=$(env echo -e "$MAKE_PRINT_VARS" | make -s --no-print-directory -f - print-VERSION_MAJOR)
483483+VERSION_MINOR=$(env echo -e "$MAKE_PRINT_VARS" | make -s --no-print-directory -f - print-VERSION_MINOR)
484484+io_uring_version_h="src/include/liburing/io_uring_version.h"
485485+cat > $io_uring_version_h << EOF
486486+/* SPDX-License-Identifier: MIT */
487487+#ifndef LIBURING_VERSION_H
488488+#define LIBURING_VERSION_H
489489+490490+#define IO_URING_VERSION_MAJOR $VERSION_MAJOR
491491+#define IO_URING_VERSION_MINOR $VERSION_MINOR
492492+493493+#endif
494494+EOF
495495+431496# generate compat.h
432497compat_h="src/include/liburing/compat.h"
433498cat > $compat_h << EOF
···452517 long long tv_nsec;
453518};
454519520520+/* <linux/time_types.h> is not available, so it can't be included */
521521+#define UAPI_LINUX_IO_URING_H_SKIP_LINUX_TIME_TYPES_H 1
522522+455523EOF
456524else
457525cat >> $compat_h << EOF
458526#include <linux/time_types.h>
527527+/* <linux/time_types.h> is included above and not needed again */
528528+#define UAPI_LINUX_IO_URING_H_SKIP_LINUX_TIME_TYPES_H 1
459529460530EOF
461531fi
···11+liburing (2.2-1) stable; urgency=low
22+33+ * Update to 2.2
44+ * Bump up so version to 2
55+ * Drop liburing1-udeb
66+ * Package using dh instead of using dh_* helpers manually
77+ * Add linux header dependency to liburing-dev
88+ * Bump up debhelper-compact level to 13
99+1010+ -- Kefu Chai <tchaikov@gmail.com> Sun, 16 Oct 2022 16:30:48 +0800
1111+112liburing (0.7-1) stable; urgency=low
213314 * Update to 0.7
···11Name: liburing
22-Version: 2.3
22+Version: 2.4
33Release: 1%{?dist}
44Summary: Linux-native io_uring I/O access library
55License: (GPLv2 with exceptions and LGPLv2+) or MIT
+3-3
vendor/opam/uring/vendor/liburing/make-debs.sh
···1313# GNU General Public License for more details.
1414#
1515# You should have received a copy of the GNU General Public License
1616-# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616+# along with this program. If not, see <https://www.gnu.org/licenses/>.
1717#
1818set -xe
19192020# Create dir for build
2121base=${1:-/tmp/release}
2222-codename=$(lsb_release -sc)
2222+distro=unstable
2323releasedir=$base/$(lsb_release -si)/liburing
2424rm -rf $releasedir
2525mkdir -p $releasedir
···4040# Change changelog if it's needed
4141cur_ver=`head -l debian/changelog | sed -n -e 's/.* (\(.*\)) .*/\1/p'`
4242if [ "$cur_ver" != "$version-1" ]; then
4343- dch -D $codename --force-distribution -b -v "$version-1" "new version"
4343+ dch -D $distro --force-distribution -b -v "$version-1" "new version"
4444fi
45454646# Create tar archieve
···1212.BI "void io_uring_buf_ring_cq_advance(struct io_uring *" ring ",
1313.BI " struct io_uring_buf_ring *" br ",
1414.BI " int " count ");"
1515+.PP
1616+.BI "void __io_uring_buf_ring_cq_advance(struct io_uring *" ring ",
1717+.BI " struct io_uring_buf_ring *" br ",
1818+.BI " int " cq_count ",
1919+.BI " int " buf_count ");"
1520.fi
1621.SH DESCRIPTION
1722.PP
···2934amount. This effectively bundles both a
3035.BR io_uring_buf_ring_advance (3)
3136call and a
3232-.BR io_uring_cq_avance (3)
3737+.BR io_uring_cq_advance (3)
3338into one operation. Since updating either ring index entails a store memory
3439barrier, doing both at once is more efficient.
4040+4141+The
4242+.BR __io_uring_buf_ring_cq_advance (3)
4343+function performs the same operation, except it splits the counts into two
4444+separate values. It advances the CQ ring by
4545+.I cq_count
4646+entries, and the buffer ring by
4747+.I buf_count
4848+entries rather than increment both by the same value.
35493650.SH RETURN VALUE
3751None
···11+.\" Copyright (C) 2022 Christian Hergert <chergert@redhat.com>
22+.\"
33+.\" SPDX-License-Identifier: LGPL-2.0-or-later
44+.\"
55+.TH io_uring_check_version 3 "December 1, 2022" "liburing-2.4" "liburing Manual"
66+.SH NAME
77+io_uring_check_version \- functions and macros to check the liburing version
88+.SH SYNOPSIS
99+.nf
1010+.B #include <liburing.h>
1111+.PP
1212+.BI "bool io_uring_check_version(int " major ", int " minor ");"
1313+.BI "IO_URING_CHECK_VERSION(" major ", " minor ");"
1414+.PP
1515+.BI "int io_uring_major_version(void);"
1616+.BI "IO_URING_VERSION_MAJOR;"
1717+.PP
1818+.BI "int io_uring_minor_version(void);"
1919+.BI "IO_URING_VERSION_MINOR;"
2020+.fi
2121+.SH DESCRIPTION
2222+.PP
2323+The
2424+.BR io_uring_check_version (3)
2525+function returns
2626+.I true
2727+if the liburing library loaded by the dynamic linker is greater-than
2828+or equal-to the
2929+.I major
3030+and
3131+.I minor
3232+numbers provided.
3333+3434+.PP
3535+The
3636+.BR IO_URING_CHECK_VERSION (3)
3737+macro returns
3838+.I 1
3939+if the liburing library being compiled against is greater-than or equal-to the
4040+.I major
4141+and
4242+.I minor
4343+numbers provided.
4444+4545+.PP
4646+The
4747+.BR io_uring_major_version (3)
4848+function returns the
4949+.I major
5050+version number of the liburing library loaded by the dynamic linker.
5151+5252+.PP
5353+The
5454+.BR IO_URING_VERSION_MAJOR (3)
5555+macro returns the
5656+.I major
5757+version number of the liburing library being compiled against.
5858+5959+.PP
6060+The
6161+.BR io_uring_minor_version (3)
6262+function returns the
6363+.I minor
6464+version number of the liburing library loaded by the dynamic linker.
6565+6666+.PP
6767+The
6868+.BR IO_URING_VERSION_MINOR (3)
6969+macro returns the
7070+.I minor
7171+version number of the liburing library being compiled against.
7272+
···11+.\" Copyright (C) 2022 Jens Axboe <axboe@kernel.dk>
22+.\" Copyright (C) 2022 Josh Triplett <josh@joshtriplett.org>
33+.\"
44+.\" SPDX-License-Identifier: LGPL-2.0-or-later
55+.\"
66+.TH io_uring_close_ring_fd 3 "September 25, 2022" "liburing-2.4" "liburing Manual"
77+.SH NAME
88+io_uring_close_ring_fd \- close a ring file descriptor and use it only via registered index
99+.SH SYNOPSIS
1010+.nf
1111+.B #include <liburing.h>
1212+.PP
1313+.BI "int io_uring_close_ring_fd(struct io_uring *" ring ");"
1414+.fi
1515+.SH DESCRIPTION
1616+.PP
1717+.BR io_uring_close_ring_fd (3)
1818+closes the ring file descriptor, which must have been previously registered.
1919+The file will remain open, but accessible only via the registered index, not
2020+via any file descriptor. Subsequent liburing calls will continue to work, using
2121+the registered ring fd.
2222+2323+The kernel must support
2424+.BR IORING_FEAT_REG_REG_RING .
2525+2626+Libraries that must avoid disrupting their users' uses of file descriptors, and
2727+must continue working even in the face of
2828+.BR close_range (2)
2929+and similar, can use
3030+.BR io_uring_close_ring_fd (3)
3131+to work with liburing without having any open file descriptor.
3232+3333+.SH NOTES
3434+Each thread that wants to make use of io_uring must register the fd. A library
3535+that may get called from arbitrary theads may need to detect when it gets
3636+called on a previously unseen thread and create and register a ring for that
3737+thread.
3838+.SH RETURN VALUE
3939+Returns 1 on success, or
4040+.BR -errno
4141+on error.
4242+.SH SEE ALSO
4343+.BR io_uring_register_ring_fd (3)
···4646If the
4747.I user_data
4848value has been set before submitting the request, it will be returned.
4949-Otherwise the functions returns NULL.
4949+Otherwise, the return value is undefined.
5050.SH SEE ALSO
5151.BR io_uring_get_sqe (3),
5252.BR io_uring_sqe_set_data (3),
···8181must be set to the size of this structure. The definition is as follows:
82828383.nf
8484-.BI "struct io_uring_getevents_args {
8484+.BI "struct io_uring_getevents_arg {
8585.BI " __u64 sigmask;
8686.BI " __u32 sigmask_sz;
8787.BI " __u32 pad;
···11+.\" Copyright (C) 2023 Jens Axboe <axboe@kernel.dk>
22+.\"
33+.\" SPDX-License-Identifier: LGPL-2.0-or-later
44+.\"
55+.TH io_uring_for_each_cqe 3 "June 04, 2023" "liburing-2.4" "liburing Manual"
66+.SH NAME
77+io_uring_for_each_cqe \- iterate pending completion events
88+.SH SYNOPSIS
99+.nf
1010+.B #include <liburing.h>
1111+.PP
1212+.BI "io_uring_for_each_cqe(struct io_uring *" ring ","
1313+.BI " unsigned " head ","
1414+.BI " struct io_uring_cqe *" cqe ") { }
1515+.fi
1616+.SH DESCRIPTION
1717+.PP
1818+The
1919+.BR io_uring_for_each_cqe (3)
2020+is a macro helper that iterates completion events belonging to the
2121+.I ring
2222+using
2323+.I head
2424+as a temporary iterator, and points
2525+.I cqe
2626+to each pending event when iterating.
2727+2828+This helper provides an efficient way to iterate all pending events in
2929+the ring, and then advancing the CQ ring by calling
3030+.BR io_uring_cq_advance (3)
3131+with the number of CQEs consumed when done. As updating the kernel visible
3232+CQ ring state involves an ordered write, doing it once for a number of
3333+events is more efficient than handling each completion separately and
3434+calling
3535+.BR io_uring_cqe_seen (3)
3636+for each of them.
3737+3838+.SH EXAMPLE
3939+.EX
4040+void handle_cqes(struct io_uring *ring)
4141+{
4242+ struct io_uring_cqe *cqe;
4343+ unsigned head;
4444+ unsigned i = 0;
4545+4646+ io_uring_for_each_cqe(ring, head, cqe) {
4747+ /* handle completion */
4848+ printf("cqe: %d\\n", cqe->res);
4949+ i++;
5050+ }
5151+5252+ io_uring_cq_advance(ring, i);
5353+}
5454+.EE
5555+5656+.SH RETURN VALUE
5757+None
5858+.SH SEE ALSO
5959+.BR io_uring_wait_cqe_timeout (3),
6060+.BR io_uring_wait_cqe (3),
6161+.BR io_uring_wait_cqes (3),
6262+.BR io_uring_cqe_seen (3),
6363+.BR io_uring_buf_ring_cq_advance (3)
···11+.\" Copyright (C) 2022 Jens Axboe <axboe@kernel.dk>
22+.\"
33+.\" SPDX-License-Identifier: LGPL-2.0-or-later
44+.\"
55+.TH io_uring_free_buf_ring 3 "Mar 07, 2023" "liburing-2.4" "liburing Manual"
66+.SH NAME
77+io_uring_free_buf_ring \- register and free a buffer ring for provided buffers
88+.SH SYNOPSIS
99+.nf
1010+.B #include <liburing.h>
1111+.PP
1212+.BI "int io_uring_free_buf_ring(struct io_uring *" ring ",
1313+.BI " struct io_uring_buf_ring *" br ",
1414+.BI " unsigned int " nentries ",
1515+.BI " int " bgid ");"
1616+.BI "
1717+.fi
1818+.SH DESCRIPTION
1919+.PP
2020+The
2121+.BR io_uring_free_buf_ring (3)
2222+function unregisters a previously registered shared buffer ring. The ring must
2323+have heen previously returned from
2424+.BR io_uring_setup_buf_ring (3) .
2525+2626+The
2727+.I ring
2828+argument must pointer to the ring for which the provided buffer ring is being
2929+registered,
3030+.I br
3131+must point to a buffer ring previously returned by
3232+.BR io_uring_setup_buf_ring (3) ,
3333+.I nentries
3434+is the number of entries requested in the buffer ring, and
3535+.I bgid
3636+is the buffer group ID that
3737+.I br
3838+was setup with.
3939+4040+Under the covers, this function uses
4141+.BR io_uring_unregister_buf_ring (3)
4242+to unregister the ring, and handles the freeing of the ring rather than
4343+letting the application open code it.
4444+4545+Available since 5.19.
4646+4747+.SH RETURN VALUE
4848+On success
4949+.BR io_uring_register_free_ring (3)
5050+returns a pointer to the buffe ring. On failure it returns
5151+.BR -errno .
5252+.SH SEE ALSO
5353+.BR io_uring_setup_buf_ring (3)
···9292If both forms of direct selection will be employed, specific and dynamic, see
9393.BR io_uring_register_file_alloc_range (3)
9494for setting up the table so dynamically chosen entries are made against
9595-a different range than that targetted by specific requests.
9595+a different range than that targeted by specific requests.
96969797Note that old kernels don't check the SQE
9898.I file_index
···11+.\" Copyright (C) 2023 Rutvik Patel <heyrutvik@gmail.com>
22+.\"
33+.\" SPDX-License-Identifier: LGPL-2.0-or-later
44+.\"
55+.TH io_uring_prep_getxattr 3 "January 23, 2023" "liburing-2.4" "liburing Manual"
66+.SH NAME
77+io_uring_prep_getxattr, io_uring_prep_fgetxattr \- prepare a request to get an
88+extended attribute value
99+.SH SYNOPSIS
1010+.nf
1111+.B #include <liburing.h>
1212+.PP
1313+.BI "void io_uring_prep_getxattr(struct io_uring_sqe *" sqe ","
1414+.BI " const char *" name ","
1515+.BI " char *" value ","
1616+.BI " const char *" path ","
1717+.BI " unsigned int " len ");"
1818+.PP
1919+.BI "void io_uring_prep_fgetxattr(struct io_uring_sqe *" sqe ","
2020+.BI " int " fd ","
2121+.BI " const char *" name ","
2222+.BI " char *" value ","
2323+.BI " unsigned int " len ");"
2424+.fi
2525+.SH DESCRIPTION
2626+.PP
2727+The
2828+.BR io_uring_prep_getxattr (3)
2929+function prepares a request to get an extended attribute value. The submission
3030+queue entry
3131+.I sqe
3232+is setup to get the
3333+.I value
3434+of the extended attribute identified by
3535+.I name
3636+and associated with the given
3737+.I path
3838+in the filesystem.
3939+The
4040+.I len
4141+argument specifies the size (in bytes) of
4242+.IR value .
4343+4444+.BR io_uring_prep_fgetxattr (3)
4545+is identical to
4646+.BR io_uring_prep_getxattr (3),
4747+only the open file referred to by
4848+.I fd
4949+is interrogated in place of
5050+.IR path .
5151+5252+This function prepares an async
5353+.BR getxattr (2)
5454+request. See that man page for details.
5555+5656+.SH RETURN VALUE
5757+None
5858+5959+.SH SEE ALSO
6060+.BR io_uring_get_sqe (3),
6161+.BR getxattr (2)
···11+.\" Copyright (C) 2023 Rutvik Patel <heyrutvik@gmail.com>
22+.\"
33+.\" SPDX-License-Identifier: LGPL-2.0-or-later
44+.\"
55+.TH io_uring_prep_link_timeout 3 "January 23, 2023" "liburing-2.4" "liburing Manual"
66+.SH NAME
77+io_uring_prep_link_timeout \- a timeout request for linked sqes
88+.SH SYNOPSIS
99+.nf
1010+.B #include <liburing.h>
1111+.PP
1212+.BI "void io_uring_prep_link_timeout(struct io_uring_sqe *" sqe ","
1313+.BI " struct __kernel_timespec *" ts ","
1414+.BI " unsigned " flags ");"
1515+.fi
1616+.SH DESCRIPTION
1717+.PP
1818+The
1919+.BR io_uring_prep_link_timeout (3)
2020+function prepares a timeout request for linked sqes. The submission queue entry
2121+.I sqe
2222+is setup a timeout specified by
2323+.IR ts .
2424+The flags argument holds modifier
2525+.I flags
2626+for the timeout behaviour of the request.
2727+2828+The
2929+.I ts
3030+argument must be filled in with the appropriate information for the timeout. It looks as follows:
3131+.PP
3232+.in +4n
3333+.EX
3434+struct __kernel_timespec {
3535+ __kernel_time64_t tv_sec;
3636+ long long tv_nsec;
3737+};
3838+.EE
3939+.in
4040+.PP
4141+4242+The
4343+.I flags
4444+argument may contain:
4545+.TP
4646+.B IORING_TIMEOUT_ABS
4747+The value specified in
4848+.I ts
4949+is an absolute value rather than a relative one.
5050+.TP
5151+.B IORING_TIMEOUT_BOOTTIME
5252+The boottime clock source should be used.
5353+.TP
5454+.B IORING_TIMEOUT_REALTIME
5555+The realtime clock source should be used.
5656+.TP
5757+.B IORING_TIMEOUT_ETIME_SUCCESS
5858+Consider an expired timeout a success in terms of the posted completion.
5959+.PP
6060+6161+It is invalid to create a chain (linked sqes) consisting only of a link timeout
6262+request. If all the requests in the chain are completed before timeout, then the
6363+link timeout request gets cancelled. Upon timeout, all the uncompleted requests
6464+in the chain get cancelled.
6565+6666+.SH RETURN VALUE
6767+None
6868+6969+.SH ERRORS
7070+.PP
7171+These are the errors that are reported in the CQE
7272+.I res
7373+field. On success,
7474+.B 0
7575+is returned.
7676+.TP
7777+.B -ETIME
7878+The specified timeout occurred and triggered the completion event.
7979+.TP
8080+.B -EINVAL
8181+One of the fields set in the SQE was invalid. For example, two clock sources
8282+where given, or the specified timeout seconds or nanoseconds where < 0.
8383+.TP
8484+.B -EFAULT
8585+io_uring was unable to access the data specified by ts.
8686+.TP
8787+.B -ECANCELED
8888+The timeout was canceled because all submitted requests were completed successfully
8989+or one of the requests resulted in failure.
9090+9191+9292+.SH SEE ALSO
9393+.BR io_uring_get_sqe (3),
9494+.BR io_uring_prep_timeout (3)
···1414.BI " unsigned int " len ","
1515.BI " __u64 " data ","
1616.BI " unsigned int " flags ");"
1717+.PP
1818+.BI "void io_uring_prep_msg_ring_cqe_flags(struct io_uring_sqe *" sqe ","
1919+.BI " int " fd ","
2020+.BI " unsigned int " len ","
2121+.BI " __u64 " data ","
2222+.BI " unsigned int " flags ","
2323+.BI " unsigned int " cqe_flags ");"
1724.fi
1825.SH DESCRIPTION
1926.PP
2027.BR io_uring_prep_msg_ring (3)
2121-prepares a to send a CQE to an io_uring file descriptor. The submission queue
2828+prepares to send a CQE to an io_uring file descriptor. The submission queue
2229entry
2330.I sqe
2431is setup to use the file descriptor
···4754on the targeted ring, or it can be used to pass messages between the two
4855rings.
49565757+.BR io_uring_prep_msg_ring_cqe_flags (3)
5858+is similar to
5959+.BR io_uring_prep_msg_ring (3) .
6060+But has an addition
6161+.I cqe_flags
6262+parameter, which is used to set
6363+.I flags
6464+field on CQE side. That way, you can set the CQE flags field
6565+.I cqe->flags
6666+when sending a message. Be aware that io_uring could potentially set additional
6767+bits into this field.
6868+5069.SH RETURN VALUE
5170None
5271···6483.B -EBADFD
6584The descriptor passed in
6685.I fd
6767-does not refer to an io_uring file descriptor.
8686+does not refer to an io_uring file descriptor, or the ring is in a disabled
8787+state.
6888.TP
6989.B -EOVERFLOW
7090The kernel was unable to fill a CQE on the target ring. This can happen if
···11+.\" Copyright (C) 2022 Jens Axboe <axboe@kernel.dk>
22+.\"
33+.\" SPDX-License-Identifier: LGPL-2.0-or-later
44+.\"
55+.TH io_uring_prep_msg_ring 3 "Mar 16, 2023" "liburing-2.4" "liburing Manual"
66+.SH NAME
77+io_uring_prep_msg_ring_fd \- send a direct descriptor to another ring
88+.SH SYNOPSIS
99+.nf
1010+.B #include <liburing.h>
1111+.PP
1212+.BI "void io_uring_prep_msg_ring_fd(struct io_uring_sqe *" sqe ","
1313+.BI " int " fd ","
1414+.BI " int " source_fd ","
1515+.BI " int " target_fd ","
1616+.BI " __u64 " data ","
1717+.BI " unsigned int " flags ");"
1818+.PP
1919+.BI "void io_uring_prep_msg_ring_fd_alloc(struct io_uring_sqe *" sqe ","
2020+.BI " int " fd ","
2121+.BI " int " source_fd ","
2222+.BI " __u64 " data ","
2323+.BI " unsigned int " flags ");"
2424+.fi
2525+.SH DESCRIPTION
2626+.PP
2727+.BR io_uring_prep_msg_ring_fd (3)
2828+prepares an SQE to send a direct file descriptor to another ring. The submission
2929+queue entry
3030+.I sqe
3131+is setup to use the file descriptor
3232+.IR fd ,
3333+which must identify a target io_uring context, to send the locally registered
3434+file descriptor with value
3535+.I source_fd
3636+to the destination ring into index
3737+.I target_fd
3838+and passing
3939+.I data
4040+as the user data in the target CQE with the request modifier flags set by
4141+.IR flags .
4242+Currently there are no valid flag modifiers, this field must contain
4343+.BR 0 .
4444+4545+.BR io_uring_prep_msg_ring_fd_alloc (3)
4646+is similar to
4747+.BR io_uring_prep_msg_ring_fd (3) ,
4848+but doesn't specify a target index for the direct descriptor. Instead, this
4949+index is allocated in the target ring and returned in the CQE
5050+.IR res
5151+field.
5252+5353+.SH RETURN VALUE
5454+None
5555+5656+.SH ERRORS
5757+These are the errors that are reported in the CQE
5858+.I res
5959+field.
6060+.TP
6161+.B -ENOMEM
6262+The kernel was unable to allocate memory for the request.
6363+.TP
6464+.B -EINVAL
6565+One of the fields set in the SQE was invalid.
6666+.TP
6767+.B -EINVAL
6868+Target ring is identical to the source ring.
6969+.TP
7070+.B -EBADFD
7171+The descriptor passed in
7272+.I fd
7373+does not refer to an io_uring file descriptor, or the ring is in a disabled
7474+state.
7575+.TP
7676+.B -EOVERFLOW
7777+The kernel was unable to fill a CQE on the target ring. This can happen if
7878+the target CQ ring is in an overflow state and the kernel wasn't able to
7979+allocate memory for a new CQE entry.
8080+.TP
8181+.B -ENFILE
8282+The direct descriptor table in the target ring was full, no new descriptors
8383+could be successfully allocated.
···3333The default behavior is a single-shot poll request. When the specified event
3434has triggered, a completion CQE is posted and no more events will be generated
3535by the poll request.
3636-.BR io_uring_prep_multishot (3)
3636+.BR io_uring_prep_poll_multishot (3)
3737behaves identically in terms of events, but it persist across notifications
3838and will repeatedly post notifications for the same registration. A CQE
3939posted from a multishot poll request will have
···2424submission queue entry
2525.I sqe
2626is setup to consume
2727+.I nr
2828+number of
2729.I len
2828-number of buffers starting at
3030+sized buffers starting at
2931.I addr
3032and identified by the buffer group ID of
3133.I bgid
···6870The application must be aware of this to make sense of the buffer ID passed
6971back in the CQE.
70727373+Buffer IDs always range from
7474+.B 0
7575+to
7676+.B 65535 ,
7777+as there are only 16-bits available in the CQE to pass them back. This range
7878+is independent of how the buffer group initially got created. Attempting to
7979+add buffer IDs larger than that, or buffer IDs that will wrap when cast to
8080+a 16-bit value, will cause the request to fail with
8181+.B -E2BIG
8282+or
8383+.B -EINVAL .
8484+7185Not all requests support buffer selection, as it only really makes sense for
7286requests that receive data from the kernel rather than write or provide data.
7387Currently, this mode of operation is supported for any file read or socket
···88102.I res
89103field. On success,
90104.I res
9191-will contain the number of successfully provided buffers. On error,
9292-the following errors can occur.
105105+will contain
106106+.B 0
107107+or the number of successfully provided buffers.
93108.TP
94109.B -ENOMEM
95110The kernel was unable to allocate memory for the request.
···106121.TP
107122.B -EFAULT
108123Some of the user memory given was invalid for the application.
109109-.TP
110110-.B -EBADF
111111-On of the descriptors located in
112112-.I fds
113113-didn't refer to a valid file descriptor, or one of the file descriptors in
114114-the array referred to an io_uring instance.
115124.TP
116125.B -EOVERFLOW
117126The product of
···43434444On files that are not capable of seeking, the offset must be 0 or -1.
45454646-After the write has been prepared it can be submitted with one of the submit
4646+After the read has been prepared it can be submitted with one of the submit
4747functions.
48484949.SH RETURN VALUE
···6464.I res
6565field.
6666.SH NOTES
6767-Unless an application explicitly needs to pass in more than iovec, it is more
6868-efficient to use
6767+Unless an application explicitly needs to pass in more than one iovec, it
6868+is more efficient to use
6969.BR io_uring_prep_read (3)
7070rather than this function, as no state has to be maintained for a
7171non-vectored IO request.
···69697070On files that are not capable of seeking, the offset must be 0 or -1.
71717272-After the write has been prepared, it can be submitted with one of the submit
7272+After the read has been prepared, it can be submitted with one of the submit
7373functions.
74747575.SH RETURN VALUE
···9090.I res
9191field.
9292.SH NOTES
9393-Unless an application explicitly needs to pass in more than iovec, it is more
9494-efficient to use
9393+Unless an application explicitly needs to pass in more than one iovec, it
9494+is more efficient to use
9595.BR io_uring_prep_read (3)
9696rather than this function, as no state has to be maintained for a
9797non-vectored IO request.
···3030.I sqe
3131is setup to use the file descriptor
3232.I sockfd
3333-to start receiving the data into the buffer destination
3333+to start receiving the data into the destination buffer
3434.I buf
3535of size
3636-.I size
3636+.I len
3737and with modifier flags
3838.IR flags .
3939···4343prep helper.
44444545The multishot version allows the application to issue a single receive request,
4646-which repeatedly posts a CQE when data is available. It requires length to be 0
4747-, the
4646+which repeatedly posts a CQE when data is available. It requires length to
4747+be 0, the
4848.B IOSQE_BUFFER_SELECT
4949flag to be set and no
5050.B MSG_WAITALL
5151flag to be set.
5252Therefore each CQE will take a buffer out of a provided buffer pool for receiving.
5353-The application should check the flags of each CQE, regardless of it's result.
5353+The application should check the flags of each CQE, regardless of its result.
5454If a posted CQE does not have the
5555.B IORING_CQE_F_MORE
5656flag set then the multishot receive will be done and the application should issue a
···4949.B MSG_WAITALL
5050flag to be set.
5151Therefore each CQE will take a buffer out of a provided buffer pool for receiving.
5252-The application should check the flags of each CQE, regardless of it's result.
5252+The application should check the flags of each CQE, regardless of its result.
5353If a posted CQE does not have the
5454.B IORING_CQE_F_MORE
5555flag set then the multishot receive will be done and the application should issue a
5656new request.
57575858Unlike
5959-.BR recvmsg (2)
6060-, multishot recvmsg will prepend a
5959+.BR recvmsg (2),
6060+multishot recvmsg will prepend a
6161.I struct io_uring_recvmsg_out
6262which describes the layout of the rest of the buffer in combination with the initial
6363.I struct msghdr
6464submitted with the request. See
6565-.B io_uring_recvmsg_out (3)
6565+.BR io_uring_recvmsg_out (3)
6666for more information on accessing the data.
67676868Multishot variants are available since kernel 6.0.
···1414.BI " const void *" buf ","
1515.BI " size_t " len ","
1616.BI " int " flags ");"
1717+.PP
1818+.BI "void io_uring_prep_sendto(struct io_uring_sqe *" sqe ","
1919+.BI " int " sockfd ","
2020+.BI " const void *" buf ","
2121+.BI " size_t " len ","
2222+.BI " int " flags ","
2323+.BI " const struct sockaddr *" addr ","
2424+.BI " socklen_t " addrlen ");"
1725.fi
1826.SH DESCRIPTION
1927.PP
···3038bytes and with modifier flags
3139.IR flags .
32404141+Note that using
4242+.B IOSQE_IO_LINK
4343+with this request type requires the setting of
4444+.B MSG_WAITALL
4545+in the
4646+.IR flags
4747+argument, as a short send isn't a considered an error condition without
4848+that being set.
4949+3350This function prepares an async
3451.BR send (2)
3552request. See that man page for details.
36535454+The
5555+.BR io_uring_prep_sendto (3)
5656+function prepares a sendto request. The submission queue entry
5757+.I sqe
5858+is setup to use the file descriptor
5959+.I sockfd
6060+to start sending the data from
6161+.I buf
6262+of size
6363+.I len
6464+bytes and with modifier flags
6565+.IR flags .
6666+The destination address is specified by
6767+.I addr
6868+and
6969+.I addrlen
7070+and must be a valid address for the socket type.
7171+7272+This function prepares an async
7373+.BR sendto (2)
7474+request. See that man page for details.
7575+3776.SH RETURN VALUE
3877None
3978.SH ERRORS
···5594.BR io_uring_get_sqe (3),
5695.BR io_uring_submit (3),
5796.BR send (2)
9797+.BR sendto (2)
···1010.B #include <liburing.h>
1111.PP
1212.BI "void io_uring_prep_send_zc(struct io_uring_sqe *" sqe ","
1313-.BI " int " sockfd ","
1414-.BI " const void *" buf ","
1515-.BI " size_t " len ","
1616-.BI " int " flags ","
1717-.BI " int " zc_flags ");"
1313+.BI " int " sockfd ","
1414+.BI " const void *" buf ","
1515+.BI " size_t " len ","
1616+.BI " int " flags ","
1717+.BI " unsigned " zc_flags ");"
1818+.PP
1919+.BI "void io_uring_prep_send_zc_fixed(struct io_uring_sqe *" sqe ","
2020+.BI " int " sockfd ","
2121+.BI " const void *" buf ","
2222+.BI " size_t " len ","
2323+.BI " int " flags ","
2424+.BI " unsigned " zc_flags ");"
2525+.BI " unsigned " buf_index ");"
1826.fi
1927.SH DESCRIPTION
2028.PP
···2937of size
3038.I len
3139bytes with send modifier flags
3232-.IR flags
4040+.I flags
3341and zerocopy modifier flags
3442.IR zc_flags .
35433636-This function prepares an async zerocopy
4444+The
4545+.BR io_uring_prep_send_zc_fixed (3)
4646+works just like
4747+.BR io_uring_prep_send_zc (3)
4848+except it requires the use of buffers that have been registered with
4949+.BR io_uring_register_buffers (3).
5050+The
5151+.I buf
5252+and
5353+.I len
5454+arguments must fall within a region specified by
5555+.I buf_index
5656+in the previously registered buffer. The buffer need not be aligned with the
5757+start of the registered buffer.
5858+5959+Note that using
6060+.B IOSQE_IO_LINK
6161+with this request type requires the setting of
6262+.B MSG_WAITALL
6363+in the
6464+.I flags
6565+argument, as a short send isn't considered an error condition without
6666+that being set.
6767+6868+These functions prepare an async zerocopy
3769.BR send (2)
3870request. See that man page for details. For details on the zerocopy nature
3971of it, see
···1515.BI " int " fd ","
1616.BI " const struct msghdr *" msg ","
1717.BI " unsigned " flags ");"
1818+.PP
1919+.BI "void io_uring_prep_sendmsg_zc(struct io_uring_sqe *" sqe ","
2020+.BI " int " fd ","
2121+.BI " const struct msghdr *" msg ","
2222+.BI " unsigned " flags ");"
1823.fi
1924.SH DESCRIPTION
2025.PP
···3136defined flags in the
3237.I flags
3338argument.
3939+4040+The
4141+.BR io_uring_prep_sendmsg_zc (3)
4242+accepts the same parameters as
4343+.BR io_uring_prep_sendmsg (3)
4444+but prepares a zerocopy sendmsg request.
4545+4646+Note that using
4747+.B IOSQE_IO_LINK
4848+with this request type requires the setting of
4949+.B MSG_WAITALL
5050+in the
5151+.I flags
5252+argument, as a short send isn't considered an error condition without
5353+that being set.
34543555This function prepares an async
3656.BR sendmsg (2)
···11+.\" Copyright (C) 2023 Rutvik Patel <heyrutvik@gmail.com>
22+.\"
33+.\" SPDX-License-Identifier: LGPL-2.0-or-later
44+.\"
55+.TH io_uring_prep_setxattr 3 "January 23, 2023" "liburing-2.4" "liburing Manual"
66+.SH NAME
77+io_uring_prep_setxattr, io_uring_prep_fsetxattr \- prepare a request to set an
88+extended attribute value
99+.SH SYNOPSIS
1010+.nf
1111+.B #include <liburing.h>
1212+.PP
1313+.BI "void io_uring_prep_setxattr(struct io_uring_sqe *" sqe ","
1414+.BI " const char *" name ","
1515+.BI " const char *" value ","
1616+.BI " const char *" path ","
1717+.BI " int " flags ","
1818+.BI " unsigned int " len ");"
1919+.PP
2020+.BI "void io_uring_prep_fsetxattr(struct io_uring_sqe *" sqe ","
2121+.BI " int " fd ","
2222+.BI " const char *" name ","
2323+.BI " const char *" value ","
2424+.BI " int " flags ","
2525+.BI " unsigned int " len ");"
2626+.fi
2727+.SH DESCRIPTION
2828+.PP
2929+The
3030+.BR io_uring_prep_setxattr (3)
3131+function prepares a request to set an extended attribute value. The submission
3232+queue entry
3333+.I sqe
3434+is setup to set the
3535+.I value
3636+of the extended attribute identified by
3737+.I name
3838+and associated with the given
3939+.I path
4040+in the filesystem with modifier flags
4141+.IR flags .
4242+The
4343+.I len
4444+argument specifies the size (in bytes) of
4545+.IR value .
4646+4747+.BR io_uring_prep_fsetxattr (3)
4848+is identical to
4949+.BR io_uring_prep_setxattr (3),
5050+only the extended attribute is set on the open file referred to by
5151+.I fd
5252+in place of
5353+.IR path .
5454+5555+This function prepares an async
5656+.BR setxattr (2)
5757+request. See that man page for details.
5858+5959+.SH RETURN VALUE
6060+None
6161+6262+.SH SEE ALSO
6363+.BR io_uring_get_sqe (3),
6464+.BR setxattr (2)
···5252.I fd_in
5353given as a registered file descriptor offset.
54545555+If
5656+.I fd_in
5757+refers to a pipe,
5858+.I off_in
5959+is ignored and must be set to -1.
6060+6161+If
6262+.I fd_in
6363+does not refer to a pipe and
6464+.I off_in
6565+is -1, then
6666+.I nbytes
6767+are read from
6868+.I fd_in
6969+starting from the file offset, which is incremented by the number of bytes read.
7070+7171+If
7272+.I fd_in
7373+does not refer to a pipe and
7474+.I off_in
7575+is not -1, then the starting offset of
7676+.I fd_in
7777+will be
7878+.IR off_in .
7979+8080+The same rules apply to
8181+.I fd_out
8282+and
8383+.IR off_out .
8484+5585This function prepares an async
5686.BR splice (2)
5787request. See that man page for details.
···78108.BR io_uring_submit (3),
79109.BR io_uring_register (2),
80110.BR splice (2)
111111+112112+.SH NOTES
113113+Note that even if
114114+.I fd_in
115115+or
116116+.I fd_out
117117+refers to a pipe, the splice operation can still fail with
118118+.B EINVAL
119119+if one of the fd doesn't explicitly support splice operation, e.g. reading from
120120+terminal is unsupported from kernel 5.7 to 5.11.
···5151CQE
5252.I res
5353value.
5454+.TP
5555+.B IORING_TIMEOUT_MULTISHOT
5656+The request will return multiple timeout completions. The completion flag
5757+IORING_CQE_F_MORE is set if more timeouts are expected. The value specified in
5858+.I count
5959+is the number of repeats. A value of 0 means the timeout is indefinite and can
6060+only be stopped by a removal request.
5461.PP
5562The timeout completion event will trigger if either the specified timeout
5663has occurred, or the specified number of events to wait for have been posted
···6464.I res
6565field.
6666.SH NOTES
6767-Unless an application explicitly needs to pass in more than iovec, it is more
6868-efficient to use
6767+Unless an application explicitly needs to pass in more than one iovec, it
6868+is more efficient to use
6969.BR io_uring_prep_write (3)
7070rather than this function, as no state has to be maintained for a
7171non-vectored IO request.
···9090.I res
9191field.
9292.SH NOTES
9393-Unless an application explicitly needs to pass in more than iovec, it is more
9494-efficient to use
9393+Unless an application explicitly needs to pass in more than one iovec, it
9494+is more efficient to use
9595.BR io_uring_prep_write (3)
9696rather than this function, as no state has to be maintained for a
9797non-vectored IO request.
···3333By default, the CQ ring will have twice the number of entries as specified by
3434.I entries
3535for the SQ ring. This is adequate for regular file or storage workloads, but
3636-may be too small networked workloads. The SQ ring entries do not impose a limit
3737-on the number of in-flight requests that the ring can support, it merely limits
3838-the number that can be submitted to the kernel in one go (batch). if the CQ
3939-ring overflows, e.g. more entries are generated than fits in the ring before the
4040-application can reap them, then the ring enters a CQ ring overflow state. This
4141-is indicated by
3636+may be too small for networked workloads. The SQ ring entries do not impose a
3737+limit on the number of in-flight requests that the ring can support, it merely
3838+limits the number that can be submitted to the kernel in one go (batch). if the
3939+CQ ring overflows, e.g. more entries are generated than fits in the ring before
4040+the application can reap them, then the ring enters a CQ ring overflow state.
4141+This is indicated by
4242.B IORING_SQ_CQ_OVERFLOW
4343being set in the SQ ring flags. Unless the kernel runs out of available memory,
4444entries are not dropped, but it is a much slower completion path and will slow
···3131.I fd
3232is the file descriptor returned by a call to
3333.BR io_uring_setup (2).
3434+If
3535+.I opcode
3636+has the flag
3737+.B IORING_REGISTER_USE_REGISTERED_RING
3838+ored into it,
3939+.I fd
4040+is instead the index of a registered ring fd.
4141+3442.I opcode
3543can be one of:
3644···93101wait for those to finish before proceeding.
9410295103An application need not unregister buffers explicitly before shutting
9696-down the io_uring instance. Available since 5.1.
104104+down the io_uring instance. Note, however, that shutdown processing may run
105105+asynchronously within the kernel. As a result, it is not guaranteed that
106106+pages are immediately unpinned in this case. Available since 5.1.
9710798108.TP
99109.B IORING_REGISTER_BUFFERS2
···193203This operation takes no argument, and
194204.I arg
195205must be passed as NULL. All previously registered buffers associated
196196-with the io_uring instance will be released. Available since 5.1.
206206+with the io_uring instance will be released synchronously. Available since 5.1.
197207198208.TP
199209.B IORING_REGISTER_FILES
···620630size allowed is 2^15 (32768).
621631.I bgid
622632is the buffer group ID associated with this ring. SQEs that select a buffer
623623-has a buffer group associated with them in their
633633+have a buffer group associated with them in their
624634.I buf_group
625625-field, and the associated CQE will have
635635+field, and the associated CQEs will have
626636.B IORING_CQE_F_BUFFER
627637set in their
628638.I flags
629639member, which will also contain the specific ID of the buffer selected. The rest
630640of the fields are reserved and must be cleared to zero.
631641632632-The
633633-.I flags
634634-argument is currently unused and must be set to zero.
635635-636636-.i nr_args
642642+.I nr_args
637643must be set to 1.
638644639645Also see
···828834.TP
829835.B EOPNOTSUPP
830836User buffers point to file-backed memory.
837837+.TP
838838+.B EFAULT
839839+User buffers point to file-backed memory (newer kernels).
···5959size allowed is 2^15 (32768).
6060.I bgid
6161is the buffer group ID associated with this ring. SQEs that select a buffer
6262-has a buffer group associated with them in their
6262+have a buffer group associated with them in their
6363.I buf_group
6464-field, and the associated CQE will have
6464+field, and the associated CQEs will have
6565.B IORING_CQE_F_BUFFER
6666set in their
6767.I flags
···118118119119Reserved fields must not be touched. Applications must use
120120.BR io_uring_buf_ring_init (3)
121121-to initialise the buffer ring. Applications may use
121121+to initialise the buffer ring before use. Applications may use
122122.BR io_uring_buf_ring_add (3)
123123and
124124.BR io_uring_buf_ring_advance (3)
125125or
126126-.BR io_uring_buf_ring_advance (3)
126126+.BR io_uring_buf_ring_cq_advance (3)
127127to provide buffers, which will set these fields and update the tail.
128128129129Available since 5.19.
···1313.BI " const int *" files ","
1414.BI " unsigned " nr_files ");"
1515.PP
1616+.BI "int io_uring_register_files_tags(struct io_uring *" ring ","
1717+.BI " const int *" files ","
1818+.BI " const __u64 *" tags ","
1919+.BI " unsigned " nr ");"
2020+.PP
1621.BI "int io_uring_register_files_sparse(struct io_uring *" ring ","
1717-.BI " unsigned " nr_files ");"
2222+.BI " unsigned " nr_files ");"
2323+.PP
2424+.BI "int io_uring_register_files_update(struct io_uring *" ring ","
2525+.BI " unsigned " off ","
2626+.BI " const int *" files ","
2727+.BI " unsigned " nr_files ");"
2828+.PP
2929+.BI "int io_uring_register_files_update_tag(struct io_uring *" ring ","
3030+.BI " unsigned " off ","
3131+.BI " const int *" files ","
3232+.BI " const __u64 *" tags ","
3333+.BI " unsigned " nr_files ");"
1834.fi
1935.SH DESCRIPTION
2036.PP
···2945for subsequent operations.
30463147The
4848+.BR io_uring_register_files_tags (3)
4949+function behaves the same as
5050+.BR io_uring_register_files (3)
5151+function but additionally takes
5252+.I tags
5353+parameter. See
5454+.B IORING_REGISTER_BUFFERS2
5555+for the resource tagging description.
5656+5757+The
3258.BR io_uring_register_files_sparse (3)
3359function registers an empty file table of
3460.I nr_files
3535-number of file descriptors. The sparse variant is available in kernels 5.19
3636-and later.
6161+number of file descriptors. These files must be updated before use, using eg
6262+.BR io_uring_register_files_update_tag (3).
6363+The sparse variant is available in kernels 5.19 and later.
37643865Registering a file table is a prerequisite for using any request that uses
3966direct descriptors.
···4572cost goes up even more. Using registered files reduces the overhead of
4673file reference management across requests that operate on a file.
47747575+The
7676+.BR io_uring_register_files_update (3)
7777+function updates existing registered files. The
7878+.I off
7979+is offset on which to start the update
8080+.I nr_files
8181+number of files defined by the array
8282+.I files
8383+belonging to the
8484+.IR ring .
8585+8686+The
8787+.BR io_uring_register_files_update_tag (3)
8888+function behaves the same as
8989+.BR io_uring_register_files_update (3)
9090+function but additionally takes
9191+.I tags
9292+parameter. See
9393+.B IORING_REGISTER_BUFFERS2
9494+for the resource tagging description.
9595+4896.SH RETURN VALUE
4997On success
5050-.BR io_uring_register_files (3)
9898+.BR io_uring_register_files (3),
9999+.BR io_uring_register_files_tags (3)
51100and
52101.BR io_uring_register_files_sparse (3)
5353-return 0. On failure they return
102102+return 0.
103103+.BR io_uring_register_files_update (3)
104104+and
105105+.BR io_uring_register_files_update_tag (3)
106106+return number of files updated.
107107+On failure they return
54108.BR -errno .
55109.SH SEE ALSO
110110+.BR io_uring_register (2),
56111.BR io_uring_get_sqe (3),
57112.BR io_uring_unregister_files (3)
···1313.PP
1414.BI "int io_uring_setup(u32 " entries ", struct io_uring_params *" p );
1515.fi
1616-.PPAA
1616+.PP
1717.SH DESCRIPTION
1818.PP
1919The
···7171It is illegal to mix and match polled and non-polled I/O on an io_uring
7272instance.
73737474+This is only applicable for storage devices for now, and the storage device
7575+must be configured for polling. How to do that depends on the device type
7676+in question. For NVMe devices, the nvme driver must be loaded with the
7777+.I poll_queues
7878+parameter set to the desired number of polling queues. The polling queues
7979+will be shared appropriately between the CPUs in the system, if the number
8080+is less than the number of online CPU threads.
8181+7482.TP
7583.B IORING_SETUP_SQPOLL
7684When this flag is specified, a kernel thread is created to perform
···119127described below.
120128.TP
121129.BR
130130+Note that, when using a ring setup with
131131+.B IORING_SETUP_SQPOLL,
132132+you never directly call the
133133+.BR io_uring_enter (2)
134134+system call. That is usually taken care of by liburing's
135135+.BR io_uring_submit (3)
136136+function. It automatically determines if you are using
137137+polling mode or not and deals with when your program needs to call
138138+.BR io_uring_enter (2)
139139+without you having to bother about it.
140140+.TP
141141+.BR
122142Before version 5.11 of the Linux kernel, to successfully use this feature, the
123143application must register a set of files to be used for IO through
124144.BR io_uring_register (2)
···132152In version 5.11 and later, it is no longer necessary to register files to use
133153this feature. 5.11 also allows using this as non-root, if the user has the
134154.B CAP_SYS_NICE
135135-capability.
155155+capability. In 5.13 this requirement was also relaxed, and no special privileges
156156+are needed for SQPOLL in newer kernels. Certain stable kernels older than 5.13
157157+may also support unprivileged SQPOLL.
136158.TP
137159.B IORING_SETUP_SQ_AFF
138160If this flag is specified, then the poll thread will be bound to the
···445467execution of that SQE. If this flag is set, then the kernel will defer
446468file assignment until execution of a given request is started. Available since
447469kernel 5.17.
470470+.TP
471471+.B IORING_FEAT_REG_REG_RING
472472+If this flag is set, then io_uring supports calling
473473+.BR io_uring_register (2)
474474+using a registered ring fd, via
475475+.BR IORING_REGISTER_USE_REGISTERED_RING .
476476+Available since kernel 6.3.
448477449478.PP
450479The rest of the fields in the
···498527.BR io_uring_setup (2).
499528The addition of
500529.I sq_off.array
501501-to the length of the region accounts for the fact that the ring
530530+to the length of the region accounts for the fact that the ring is
502531located at the end of the data structure. As an example, the ring
503532buffer head pointer can be accessed by adding
504533.I sq_off.head
···581610.PP
582611Closing the file descriptor returned by
583612.BR io_uring_setup (2)
584584-will free all resources associated with the io_uring context.
613613+will free all resources associated with the io_uring context. Note that this
614614+may happen asynchronously within the kernel, so it is not guaranteed that
615615+resources are freed immediately.
585616.PP
586617.SH RETURN VALUE
587618.BR io_uring_setup (2)
···11+.\" Copyright (C) 2022 Jens Axboe <axboe@kernel.dk>
22+.\"
33+.\" SPDX-License-Identifier: LGPL-2.0-or-later
44+.\"
55+.TH io_uring_setup_buf_ring 3 "Mar 07, 2023" "liburing-2.4" "liburing Manual"
66+.SH NAME
77+io_uring_setup_buf_ring \- setup and register buffer ring for provided buffers
88+.SH SYNOPSIS
99+.nf
1010+.B #include <liburing.h>
1111+.PP
1212+.BI "struct io_uring_buf_ring *io_uring_setup_buf_ring(struct io_uring *" ring ",
1313+.BI " unsigned int " nentries ",
1414+.BI " int " bgid ",
1515+.BI " unsigned int " flags ",
1616+.BI " int *" ret ");"
1717+.BI "
1818+.fi
1919+.SH DESCRIPTION
2020+.PP
2121+The
2222+.BR io_uring_setup_buf_ring (3)
2323+function registers a shared buffer ring to be used with provided buffers. For
2424+the request types that support it, provided buffers are given to the ring and
2525+one is selected by a request if it has
2626+.B IOSQE_BUFFER_SELECT
2727+set in the SQE
2828+.IR flags ,
2929+when the request is ready to receive data. This allows both clear ownership
3030+of the buffer lifetime, and a way to have more read/receive type of operations
3131+in flight than buffers available.
3232+3333+The
3434+.I ring
3535+argument must pointer to the ring for which the provided buffer ring is being
3636+registered,
3737+.I nentries
3838+is the number of entries requested in the buffer ring. This argument must be
3939+a power-of 2 in size.
4040+.I bgid
4141+is the chosen buffer group ID,
4242+.I flags
4343+are modifier flags for the operation, and
4444+.I *ret
4545+is is a pointer to an integer for the error value if any part of the ring
4646+allocation and registration fails.
4747+4848+The
4949+.I flags
5050+argument is currently unused and must be set to zero.
5151+5252+Under the covers, this function uses
5353+.BR io_uring_register_buf_ring (3)
5454+to register the ring, and handles the allocation of the ring rather than
5555+letting the application open code it.
5656+5757+To unregister and free a buffer group ID setup with this function, the
5858+application must call
5959+.BR io_uring_free_buf_ring (3) .
6060+6161+Available since 5.19.
6262+6363+.SH RETURN VALUE
6464+On success
6565+.BR io_uring_register_setup_ring (3)
6666+returns a pointer to the buffe ring. On failure it returns
6767+.BR NULL
6868+and sets
6969+.I *ret
7070+to -errno.
7171+.SH SEE ALSO
7272+.BR io_uring_register_buf_ring (3),
7373+.BR io_uring_buf_ring_init (3),
7474+.BR io_uring_buf_ring_add (3),
7575+.BR io_uring_buf_ring_advance (3),
7676+.BR io_uring_buf_ring_cq_advance (3)
···3737relation to the CQE result itself.
3838.SH SEE ALSO
3939.BR io_uring_submit (3),
4040+.BR io_uring_wait_cqe_timeout (3),
4041.BR io_uring_wait_cqes (3)
···42424343.SH RETURN VALUE
4444On success
4545-.BR io_uring_wait_cqes (3)
4545+.BR io_uring_wait_cqe_timeout (3)
4646returns 0 and the cqe_ptr param is filled in. On failure it returns
4747.BR -errno .
4848The return value indicates the result of waiting for a CQE, and it has no
4949relation to the CQE result itself.
5050.SH SEE ALSO
5151.BR io_uring_submit (3),
5252-.BR io_uring_wait_cqe_timeout (3),
5252+.BR io_uring_wait_cqes (3),
5353.BR io_uring_wait_cqe (3)
···32323333The
3434.I cqe_ptr
3535-param is filled in on success.
3535+param is filled in on success with the first CQE. Callers of this function
3636+should use
3737+.BR io_uring_for_each_cqe (3)
3838+to iterate all available CQEs.
36393740If
3841.I ts
···5255.BR -errno .
5356.SH SEE ALSO
5457.BR io_uring_submit (3),
5858+.BR io_uring_for_each_cqe (3),
5559.BR io_uring_wait_cqe_timeout (3),
5660.BR io_uring_wait_cqe (3)
···2121 ssize_t x;
22222323 x = __sys_read(fd, buf, sizeof(buf));
2424- if (x < sizeof(buf))
2424+ if (x < (long) sizeof(buf))
2525 break;
26262727 if (buf[0] == AT_PAGESZ) {
+15
vendor/opam/uring/vendor/liburing/src/ffi.c
···11+/* SPDX-License-Identifier: MIT */
22+#define IOURINGINLINE
33+44+#ifdef __clang__
55+// clang doesn't seem to particularly like that we're including a header that
66+// deliberately contains function definitions so we explicitly silence it
77+#pragma clang diagnostic push
88+#pragma clang diagnostic ignored "-Wmissing-prototypes"
99+#endif
1010+1111+#include "liburing.h"
1212+1313+#ifdef __clang__
1414+#pragma clang diagnostic pop
1515+#endif
···77#include "lib.h"
88#include "syscall.h"
991010-void *memset(void *s, int c, size_t n)
1010+void *__uring_memset(void *s, int c, size_t n)
1111{
1212 size_t i;
1313 unsigned char *p = s;
14141515- for (i = 0; i < n; i++)
1515+ for (i = 0; i < n; i++) {
1616 p[i] = (unsigned char) c;
1717+1818+ /*
1919+ * An empty inline ASM to avoid auto-vectorization
2020+ * because it's too bloated for liburing.
2121+ */
2222+ __asm__ volatile ("");
2323+ }
17241825 return s;
1926}
+2-2
vendor/opam/uring/vendor/liburing/src/queue.c
···8181 }
8282 if (!cqe && !data->wait_nr && !data->submit) {
8383 /*
8484- * If we already looped once, we already entererd
8484+ * If we already looped once, we already entered
8585 * the kernel. Since there's nothing to submit or
8686 * wait for, don't keep retrying.
8787 */
···201201 * Sync internal state with kernel ring state on the SQ side. Returns the
202202 * number of pending items in the SQ ring, for the shared ring.
203203 */
204204-unsigned __io_uring_flush_sq(struct io_uring *ring)
204204+static unsigned __io_uring_flush_sq(struct io_uring *ring)
205205{
206206 struct io_uring_sq *sq = &ring->sq;
207207 unsigned tail = sq->sqe_tail;
···11/* SPDX-License-Identifier: MIT */
22/*
33- * Description: run various nop tests
33+ * Description: test use of eventfds with multiple rings
44 *
55 */
66#include <errno.h>
+1-1
vendor/opam/uring/vendor/liburing/test/eventfd.c
···11/* SPDX-License-Identifier: MIT */
22/*
33- * Description: run various nop tests
33+ * Description: run various eventfd tests
44 *
55 */
66#include <errno.h>
+73
vendor/opam/uring/vendor/liburing/test/evloop.c
···11+/* SPDX-License-Identifier: MIT */
22+/*
33+ * Test that we don't recursively generate completion events if an io_uring
44+ * has an eventfd registered that triggers on completions, and we add a poll
55+ * request with multishot on the eventfd. Older kernels will stop on overflow,
66+ * newer kernels will detect this earlier and abort correctly.
77+ */
88+#include <errno.h>
99+#include <stdio.h>
1010+#include <unistd.h>
1111+#include <stdlib.h>
1212+#include <sys/eventfd.h>
1313+#include <sys/types.h>
1414+#include <poll.h>
1515+#include <assert.h>
1616+#include "liburing.h"
1717+#include "helpers.h"
1818+1919+int main(int argc, char *argv[])
2020+{
2121+ struct io_uring ring;
2222+ struct io_uring_sqe *sqe;
2323+ struct io_uring_cqe *cqe;
2424+ int ret, efd, i;
2525+2626+ if (argc > 1)
2727+ return T_EXIT_SKIP;
2828+2929+ ret = io_uring_queue_init(8, &ring, 0);
3030+ if (ret) {
3131+ fprintf(stderr, "Ring init failed: %d\n", ret);
3232+ return T_EXIT_FAIL;
3333+ }
3434+3535+ efd = eventfd(0, 0);
3636+ if (efd < 0) {
3737+ perror("eventfd");
3838+ return T_EXIT_FAIL;
3939+ }
4040+4141+ ret = io_uring_register_eventfd(&ring, efd);
4242+ if (ret) {
4343+ fprintf(stderr, "Ring eventfd register failed: %d\n", ret);
4444+ return T_EXIT_FAIL;
4545+ }
4646+4747+ sqe = io_uring_get_sqe(&ring);
4848+ io_uring_prep_poll_multishot(sqe, efd, POLLIN);
4949+ sqe->user_data = 1;
5050+ io_uring_submit(&ring);
5151+5252+ sqe = io_uring_get_sqe(&ring);
5353+ sqe->user_data = 2;
5454+ io_uring_prep_nop(sqe);
5555+ io_uring_submit(&ring);
5656+5757+ for (i = 0; i < 2; i++) {
5858+ ret = io_uring_wait_cqe(&ring, &cqe);
5959+ if (ret) {
6060+ fprintf(stderr, "wait_cqe ret = %d\n", ret);
6161+ break;
6262+ }
6363+ io_uring_cqe_seen(&ring, cqe);
6464+ }
6565+6666+ ret = io_uring_peek_cqe(&ring, &cqe);
6767+ if (!ret) {
6868+ fprintf(stderr, "Generated too many events\n");
6969+ return T_EXIT_FAIL;
7070+ }
7171+7272+ return T_EXIT_PASS;
7373+}
···186186 }
187187188188 /* too hard to reliably test, just ignore */
189189- if (0 && bad > good) {
189189+ if ((0) && bad > good) {
190190 fprintf(stderr, "Suspicious timings\n");
191191 goto err;
192192 }
···88#include <stdio.h>
99#include <fcntl.h>
1010#include <unistd.h>
1111+#include <stdarg.h>
1112#include <sys/types.h>
12131314#include <arpa/inet.h>
···134135 return T_SETUP_SKIP;
135136 }
136137137137- fprintf(stderr, "queue_init: %s\n", strerror(-ret));
138138+ if (ret != -EINVAL)
139139+ fprintf(stderr, "queue_init: %s\n", strerror(-ret));
138140 return ret;
139141}
140142···173175 int val;
174176 struct sockaddr_in serv_addr;
175177 struct sockaddr *paddr;
176176- size_t paddrlen;
178178+ socklen_t paddrlen;
177179178180 type |= SOCK_CLOEXEC;
179181 fd[0] = socket(AF_INET, type, 0);
···266268 io_uring_queue_exit(&ring);
267269 return true;
268270}
271271+272272+/*
273273+ * Sync internal state with kernel ring state on the SQ side. Returns the
274274+ * number of pending items in the SQ ring, for the shared ring.
275275+ */
276276+unsigned __io_uring_flush_sq(struct io_uring *ring)
277277+{
278278+ struct io_uring_sq *sq = &ring->sq;
279279+ unsigned tail = sq->sqe_tail;
280280+281281+ if (sq->sqe_head != tail) {
282282+ sq->sqe_head = tail;
283283+ /*
284284+ * Ensure kernel sees the SQE updates before the tail update.
285285+ */
286286+ if (!(ring->flags & IORING_SETUP_SQPOLL))
287287+ IO_URING_WRITE_ONCE(*sq->ktail, tail);
288288+ else
289289+ io_uring_smp_store_release(sq->ktail, tail);
290290+ }
291291+ /*
292292+ * This _may_ look problematic, as we're not supposed to be reading
293293+ * SQ->head without acquire semantics. When we're in SQPOLL mode, the
294294+ * kernel submitter could be updating this right now. For non-SQPOLL,
295295+ * task itself does it, and there's no potential race. But even for
296296+ * SQPOLL, the load is going to be potentially out-of-date the very
297297+ * instant it's done, regardless or whether or not it's done
298298+ * atomically. Worst case, we're going to be over-estimating what
299299+ * we can submit. The point is, we need to be able to deal with this
300300+ * situation regardless of any perceived atomicity.
301301+ */
302302+ return tail - *sq->khead;
303303+}
304304+305305+/*
306306+ * Implementation of error(3), prints an error message and exits.
307307+ */
308308+void t_error(int status, int errnum, const char *format, ...)
309309+{
310310+ va_list args;
311311+ va_start(args, format);
312312+313313+ vfprintf(stderr, format, args);
314314+ if (errnum)
315315+ fprintf(stderr, ": %s", strerror(errnum));
316316+317317+ fprintf(stderr, "\n");
318318+ va_end(args);
319319+ exit(status);
320320+}
···9696 return 1;
9797}
98989999-int test_link_drain_multi(struct io_uring *ring)
9999+static int test_link_drain_multi(struct io_uring *ring)
100100{
101101 struct io_uring_cqe *cqe;
102102 struct io_uring_sqe *sqe[9];
···198198199199}
200200201201-int main(int argc, char *argv[])
201201+static int test_drain(bool defer)
202202{
203203 struct io_uring ring;
204204 int i, ret;
205205+ unsigned int flags = 0;
205206206206- if (argc > 1)
207207- return 0;
207207+ if (defer)
208208+ flags = IORING_SETUP_SINGLE_ISSUER |
209209+ IORING_SETUP_DEFER_TASKRUN;
208210209209- ret = io_uring_queue_init(100, &ring, 0);
211211+ ret = io_uring_queue_init(100, &ring, flags);
210212 if (ret) {
211213 printf("ring setup failed\n");
212214 return 1;
···227229228230 return ret;
229231}
232232+233233+int main(int argc, char *argv[])
234234+{
235235+ int ret;
236236+237237+ if (argc > 1)
238238+ return T_EXIT_SKIP;
239239+240240+ ret = test_drain(false);
241241+ if (ret) {
242242+ fprintf(stderr, "test_drain(false) failed\n");
243243+ return T_EXIT_FAIL;
244244+ }
245245+246246+ if (t_probe_defer_taskrun()) {
247247+ ret = test_drain(true);
248248+ if (ret) {
249249+ fprintf(stderr, "test_drain(true) failed\n");
250250+ return T_EXIT_FAIL;
251251+ }
252252+ }
253253+254254+ return T_EXIT_PASS;
255255+}
+1-1
vendor/opam/uring/vendor/liburing/test/madvise.c
···182182 }
183183184184 /* too hard to reliably test, just ignore */
185185- if (0 && bad > good)
185185+ if ((0) && bad > good)
186186 fprintf(stderr, "Suspicious timings (%u > %u)\n", bad, good);
187187 if (fname != argv[1])
188188 unlink(fname);
···11/* SPDX-License-Identifier: MIT */
22/*
33- * Description: run various nop tests
33+ * Description: run various rename tests
44 *
55 */
66#include <errno.h>
···11-/* SPDX-License-Identifier: MIT */
11+/* SPDX-License-Identifier: GPL-2.0-or-later */
22/*
33 * repro-CVE-2020-29373 -- Reproducer for CVE-2020-29373.
44 *
···1616 * GNU General Public License for more details.
1717 *
1818 * You should have received a copy of the GNU General Public License
1919- * along with this program; if not, see <http://www.gnu.org/licenses/>.
1919+ * along with this program; if not, see <https://www.gnu.org/licenses/>.
2020 */
21212222#include <unistd.h>
···11-/* SPDX-License-Identifier: MIT */
22-/*
33- * Description: run timeout overflow test
44- *
55- */
66-#include <errno.h>
77-#include <stdio.h>
88-#include <limits.h>
99-#include <string.h>
1010-#include <sys/time.h>
1111-1212-#include "liburing.h"
1313-#include "helpers.h"
1414-1515-#define TIMEOUT_MSEC 200
1616-static int not_supported;
1717-1818-static void msec_to_ts(struct __kernel_timespec *ts, unsigned int msec)
1919-{
2020- ts->tv_sec = msec / 1000;
2121- ts->tv_nsec = (msec % 1000) * 1000000;
2222-}
2323-2424-static int check_timeout_support(void)
2525-{
2626- struct io_uring_sqe *sqe;
2727- struct io_uring_cqe *cqe;
2828- struct __kernel_timespec ts;
2929- struct io_uring_params p;
3030- struct io_uring ring;
3131- int ret;
3232-3333- memset(&p, 0, sizeof(p));
3434- ret = io_uring_queue_init_params(1, &ring, &p);
3535- if (ret) {
3636- fprintf(stderr, "ring setup failed: %d\n", ret);
3737- return T_EXIT_FAIL;
3838- }
3939-4040- /* not really a match, but same kernel added batched completions */
4141- if (p.features & IORING_FEAT_POLL_32BITS) {
4242- not_supported = 1;
4343- return T_EXIT_SKIP;
4444- }
4545-4646- sqe = io_uring_get_sqe(&ring);
4747- msec_to_ts(&ts, TIMEOUT_MSEC);
4848- io_uring_prep_timeout(sqe, &ts, 1, 0);
4949-5050- ret = io_uring_submit(&ring);
5151- if (ret < 0) {
5252- fprintf(stderr, "sqe submit failed: %d\n", ret);
5353- goto err;
5454- }
5555-5656- ret = io_uring_wait_cqe(&ring, &cqe);
5757- if (ret < 0) {
5858- fprintf(stderr, "wait completion %d\n", ret);
5959- goto err;
6060- }
6161-6262- if (cqe->res == -EINVAL) {
6363- not_supported = 1;
6464- fprintf(stdout, "Timeout not supported, ignored\n");
6565- return 0;
6666- }
6767-6868- io_uring_cqe_seen(&ring, cqe);
6969- io_uring_queue_exit(&ring);
7070- return T_EXIT_PASS;
7171-err:
7272- io_uring_queue_exit(&ring);
7373- return T_EXIT_FAIL;
7474-}
7575-7676-/*
7777- * We first setup 4 timeout requests, which require a count value of 1, 1, 2,
7878- * UINT_MAX, so the sequence is 1, 2, 4, 2. Before really timeout, this 4
7979- * requests will not lead the change of cq_cached_tail, so as sq_dropped.
8080- *
8181- * And before this patch. The order of this four requests will be req1->req2->
8282- * req4->req3. Actually, it should be req1->req2->req3->req4.
8383- *
8484- * Then, if there is 2 nop req. All timeout requests expect req4 will completed
8585- * successful after the patch. And req1/req2 will completed successful with
8686- * req3/req4 return -ETIME without this patch!
8787- */
8888-static int test_timeout_overflow(void)
8989-{
9090- struct io_uring_sqe *sqe;
9191- struct io_uring_cqe *cqe;
9292- struct __kernel_timespec ts;
9393- struct io_uring ring;
9494- int i, ret;
9595-9696- ret = io_uring_queue_init(16, &ring, 0);
9797- if (ret) {
9898- fprintf(stderr, "ring setup failed: %d\n", ret);
9999- return 1;
100100- }
101101-102102- msec_to_ts(&ts, TIMEOUT_MSEC);
103103- for (i = 0; i < 4; i++) {
104104- unsigned num = 0;
105105- sqe = io_uring_get_sqe(&ring);
106106- switch (i) {
107107- case 0:
108108- case 1:
109109- num = 1;
110110- break;
111111- case 2:
112112- num = 2;
113113- break;
114114- case 3:
115115- num = UINT_MAX;
116116- break;
117117- }
118118- io_uring_prep_timeout(sqe, &ts, num, 0);
119119- }
120120-121121- for (i = 0; i < 2; i++) {
122122- sqe = io_uring_get_sqe(&ring);
123123- io_uring_prep_nop(sqe);
124124- io_uring_sqe_set_data(sqe, (void *) 1);
125125- }
126126- ret = io_uring_submit(&ring);
127127- if (ret < 0) {
128128- fprintf(stderr, "sqe submit failed: %d\n", ret);
129129- goto err;
130130- }
131131-132132- i = 0;
133133- while (i < 6) {
134134- ret = io_uring_wait_cqe(&ring, &cqe);
135135- if (ret < 0) {
136136- fprintf(stderr, "wait completion %d\n", ret);
137137- goto err;
138138- }
139139-140140- /*
141141- * cqe1: first nop req
142142- * cqe2: first timeout req, because of cqe1
143143- * cqe3: second timeout req because of cqe1 + cqe2
144144- * cqe4: second nop req
145145- * cqe5~cqe6: the left three timeout req
146146- */
147147- switch (i) {
148148- case 0:
149149- case 3:
150150- if (io_uring_cqe_get_data(cqe) != (void *) 1) {
151151- fprintf(stderr, "nop not seen as 1 or 2\n");
152152- goto err;
153153- }
154154- break;
155155- case 1:
156156- case 2:
157157- case 4:
158158- if (cqe->res == -ETIME) {
159159- fprintf(stderr, "expected not return -ETIME "
160160- "for the #%d timeout req\n", i - 1);
161161- goto err;
162162- }
163163- break;
164164- case 5:
165165- if (cqe->res != -ETIME) {
166166- fprintf(stderr, "expected return -ETIME for "
167167- "the #%d timeout req\n", i - 1);
168168- goto err;
169169- }
170170- break;
171171- }
172172- io_uring_cqe_seen(&ring, cqe);
173173- i++;
174174- }
175175-176176- return 0;
177177-err:
178178- return 1;
179179-}
180180-181181-int main(int argc, char *argv[])
182182-{
183183- int ret;
184184-185185- if (argc > 1)
186186- return T_EXIT_SKIP;
187187-188188- ret = check_timeout_support();
189189- if (ret == T_EXIT_FAIL) {
190190- fprintf(stderr, "check_timeout_support failed: %d\n", ret);
191191- return T_EXIT_FAIL;
192192- }
193193-194194- if (not_supported)
195195- return T_EXIT_SKIP;
196196-197197- ret = test_timeout_overflow();
198198- if (ret) {
199199- fprintf(stderr, "test_timeout_overflow failed\n");
200200- return T_EXIT_FAIL;
201201- }
202202-203203- return T_EXIT_PASS;
204204-}
+277-2
vendor/opam/uring/vendor/liburing/test/timeout.c
···1414#include <sys/types.h>
1515#include <sys/stat.h>
16161717+#include "helpers.h"
1718#include "liburing.h"
1819#include "../src/syscall.h"
19202021#define TIMEOUT_MSEC 200
2122static int not_supported;
2223static int no_modify;
2424+static int no_multishot;
23252426static void msec_to_ts(struct __kernel_timespec *ts, unsigned int msec)
2527{
···176178 goto err;
177179 }
178180 i++;
179179- };
181181+ }
180182181183 return 0;
182184err:
···13031305 fprintf(stderr, "%s: wait completion %d\n", __FUNCTION__, ret);
13041306 return 1;
13051307 } else if (cqe->user_data == 1 && cqe->res == -EINVAL) {
13061306- fprintf(stderr, "ETIME_SUCCESS is not supported, skip\n");
13071308 goto done;
13081309 } else if (cqe->res != -ETIME || cqe->user_data != 1) {
13091310 fprintf(stderr, "timeout failed %i %i\n", cqe->res,
···13281329}
132913301330133113321332+static int test_timeout_multishot(struct io_uring *ring)
13331333+{
13341334+ struct io_uring_cqe *cqe;
13351335+ struct io_uring_sqe *sqe;
13361336+ struct __kernel_timespec ts;
13371337+ int ret;
13381338+13391339+ sqe = io_uring_get_sqe(ring);
13401340+ if (!sqe) {
13411341+ fprintf(stderr, "%s: get sqe failed\n", __FUNCTION__);
13421342+ goto err;
13431343+ }
13441344+13451345+ msec_to_ts(&ts, TIMEOUT_MSEC);
13461346+ io_uring_prep_timeout(sqe, &ts, 0, IORING_TIMEOUT_MULTISHOT);
13471347+ io_uring_sqe_set_data(sqe, (void *) 1);
13481348+13491349+ ret = io_uring_submit(ring);
13501350+ if (ret <= 0) {
13511351+ fprintf(stderr, "%s: sqe submit failed: %d\n", __FUNCTION__, ret);
13521352+ goto err;
13531353+ }
13541354+13551355+ for (int i = 0; i < 2; i++) {
13561356+ ret = io_uring_wait_cqe(ring, &cqe);
13571357+ if (ret < 0) {
13581358+ fprintf(stderr, "%s: wait completion %d\n", __FUNCTION__, ret);
13591359+ goto err;
13601360+ }
13611361+13621362+ ret = cqe->res;
13631363+ if (ret == -EINVAL) {
13641364+ no_multishot = 1;
13651365+ return T_EXIT_SKIP;
13661366+ }
13671367+13681368+ if (!(cqe->flags & IORING_CQE_F_MORE)) {
13691369+ fprintf(stderr, "%s: flag not set in cqe\n", __FUNCTION__);
13701370+ goto err;
13711371+ }
13721372+13731373+ if (ret != -ETIME) {
13741374+ fprintf(stderr, "%s: Timeout: %s\n", __FUNCTION__, strerror(-ret));
13751375+ goto err;
13761376+ }
13771377+13781378+ io_uring_cqe_seen(ring, cqe);
13791379+ }
13801380+13811381+ sqe = io_uring_get_sqe(ring);
13821382+ if (!sqe) {
13831383+ fprintf(stderr, "%s: get sqe failed\n", __FUNCTION__);
13841384+ goto err;
13851385+ }
13861386+13871387+ io_uring_prep_timeout_remove(sqe, 1, 0);
13881388+ io_uring_sqe_set_data(sqe, (void *) 2);
13891389+13901390+ ret = io_uring_submit(ring);
13911391+ if (ret <= 0) {
13921392+ fprintf(stderr, "%s: sqe submit failed: %d\n", __FUNCTION__, ret);
13931393+ goto err;
13941394+ }
13951395+13961396+ ret = io_uring_wait_cqe(ring, &cqe);
13971397+ if (ret < 0) {
13981398+ fprintf(stderr, "%s: wait completion %d\n", __FUNCTION__, ret);
13991399+ goto err;
14001400+ }
14011401+14021402+ ret = cqe->res;
14031403+ if (ret < 0) {
14041404+ fprintf(stderr, "%s: remove failed: %s\n", __FUNCTION__, strerror(-ret));
14051405+ goto err;
14061406+ }
14071407+14081408+ io_uring_cqe_seen(ring, cqe);
14091409+14101410+ ret = io_uring_wait_cqe(ring, &cqe);
14111411+ if (ret < 0) {
14121412+ fprintf(stderr, "%s: wait completion %d\n", __FUNCTION__, ret);
14131413+ goto err;
14141414+ }
14151415+14161416+ ret = cqe->res;
14171417+ if (ret != -ECANCELED) {
14181418+ fprintf(stderr, "%s: timeout canceled: %s %llu\n", __FUNCTION__, strerror(-ret), cqe->user_data);
14191419+ goto err;
14201420+ }
14211421+14221422+ io_uring_cqe_seen(ring, cqe);
14231423+ return 0;
14241424+err:
14251425+ return 1;
14261426+}
14271427+14281428+14291429+static int test_timeout_multishot_nr(struct io_uring *ring)
14301430+{
14311431+ struct io_uring_cqe *cqe;
14321432+ struct io_uring_sqe *sqe;
14331433+ struct __kernel_timespec ts;
14341434+ int ret;
14351435+14361436+ if (no_multishot)
14371437+ return T_EXIT_SKIP;
14381438+14391439+ sqe = io_uring_get_sqe(ring);
14401440+ if (!sqe) {
14411441+ fprintf(stderr, "%s: get sqe failed\n", __FUNCTION__);
14421442+ goto err;
14431443+ }
14441444+14451445+ msec_to_ts(&ts, TIMEOUT_MSEC);
14461446+ io_uring_prep_timeout(sqe, &ts, 3, IORING_TIMEOUT_MULTISHOT);
14471447+ io_uring_sqe_set_data(sqe, (void *) 1);
14481448+14491449+ ret = io_uring_submit(ring);
14501450+ if (ret <= 0) {
14511451+ fprintf(stderr, "%s: sqe submit failed: %d\n", __FUNCTION__, ret);
14521452+ goto err;
14531453+ }
14541454+14551455+ for (int i = 0; i < 3; i++) {
14561456+ ret = io_uring_wait_cqe(ring, &cqe);
14571457+ if (ret < 0) {
14581458+ fprintf(stderr, "%s: wait completion %d\n", __FUNCTION__, ret);
14591459+ goto err;
14601460+ }
14611461+14621462+ if (i < 2 && !(cqe->flags & IORING_CQE_F_MORE)) {
14631463+ fprintf(stderr, "%s: flag not set in cqe\n", __FUNCTION__);
14641464+ goto err;
14651465+ }
14661466+ if (i == 3 && (cqe->flags & IORING_CQE_F_MORE)) {
14671467+ fprintf(stderr, "%s: flag set in cqe\n", __FUNCTION__);
14681468+ goto err;
14691469+ }
14701470+14711471+ ret = cqe->res;
14721472+ if (ret != -ETIME) {
14731473+ fprintf(stderr, "%s: Timeout: %s\n", __FUNCTION__, strerror(-ret));
14741474+ goto err;
14751475+ }
14761476+14771477+ io_uring_cqe_seen(ring, cqe);
14781478+ }
14791479+14801480+ msec_to_ts(&ts, 2 * TIMEOUT_MSEC);
14811481+ ret = io_uring_wait_cqe_timeout(ring, &cqe, &ts);
14821482+ if (ret != -ETIME) {
14831483+ fprintf(stderr, "%s: wait completion timeout %s\n", __FUNCTION__, strerror(-ret));
14841484+ goto err;
14851485+ }
14861486+14871487+ return 0;
14881488+err:
14891489+ return 1;
14901490+}
14911491+14921492+14931493+static int test_timeout_multishot_overflow(struct io_uring *ring)
14941494+{
14951495+ struct io_uring_cqe *cqe;
14961496+ struct io_uring_sqe *sqe;
14971497+ struct __kernel_timespec ts;
14981498+ int ret;
14991499+15001500+ if (no_multishot)
15011501+ return T_EXIT_SKIP;
15021502+15031503+ sqe = io_uring_get_sqe(ring);
15041504+ if (!sqe) {
15051505+ fprintf(stderr, "%s: get sqe failed\n", __FUNCTION__);
15061506+ goto err;
15071507+ }
15081508+15091509+ msec_to_ts(&ts, 10);
15101510+ io_uring_prep_timeout(sqe, &ts, 0, IORING_TIMEOUT_MULTISHOT);
15111511+ io_uring_sqe_set_data(sqe, (void *) 1);
15121512+15131513+ ret = io_uring_submit(ring);
15141514+ if (ret <= 0) {
15151515+ fprintf(stderr, "%s: sqe submit failed: %d\n", __FUNCTION__, ret);
15161516+ goto err;
15171517+ }
15181518+15191519+ ret = io_uring_wait_cqe(ring, &cqe);
15201520+ if (ret < 0) {
15211521+ fprintf(stderr, "%s: wait completion %d\n", __FUNCTION__, ret);
15221522+ goto err;
15231523+ }
15241524+15251525+ ret = cqe->res;
15261526+ if (ret != -ETIME) {
15271527+ fprintf(stderr, "%s: Timeout: %s\n", __FUNCTION__, strerror(-ret));
15281528+ goto err;
15291529+ }
15301530+15311531+ io_uring_cqe_seen(ring, cqe);
15321532+ sleep(1);
15331533+15341534+ if (!((*ring->sq.kflags) & IORING_SQ_CQ_OVERFLOW)) {
15351535+ goto err;
15361536+ }
15371537+15381538+ /* multishot timer should be gone */
15391539+ sqe = io_uring_get_sqe(ring);
15401540+ if (!sqe) {
15411541+ fprintf(stderr, "%s: get sqe failed\n", __FUNCTION__);
15421542+ goto err;
15431543+ }
15441544+15451545+ io_uring_prep_timeout_remove(sqe, 1, 0);
15461546+15471547+ ret = io_uring_submit(ring);
15481548+ if (ret <= 0) {
15491549+ fprintf(stderr, "%s: sqe submit failed: %d\n", __FUNCTION__, ret);
15501550+ goto err;
15511551+ }
15521552+15531553+ ret = io_uring_wait_cqe(ring, &cqe);
15541554+ if (ret < 0) {
15551555+ fprintf(stderr, "%s: wait completion %d\n", __FUNCTION__, ret);
15561556+ goto err;
15571557+ }
15581558+15591559+ ret = cqe->res;
15601560+ io_uring_cqe_seen(ring, cqe);
15611561+ if (ret != -ETIME) {
15621562+ fprintf(stderr, "%s: remove failed: %d %s\n", __FUNCTION__, ret, strerror(-ret));
15631563+ goto err;
15641564+ }
15651565+15661566+ return 0;
15671567+err:
15681568+ return 1;
15691569+}
15701570+15711571+13311572int main(int argc, char *argv[])
13321573{
13331574 struct io_uring ring, sqpoll_ring;
···14181659 if (ret) {
14191660 fprintf(stderr, "test_timeout_flags3 failed\n");
14201661 return ret;
16621662+ }
16631663+16641664+ ret = test_timeout_multishot(&ring);
16651665+ if (ret && ret != T_EXIT_SKIP) {
16661666+ fprintf(stderr, "test_timeout_multishot failed\n");
16671667+ return ret;
16681668+ }
16691669+16701670+ ret = test_timeout_multishot_nr(&ring);
16711671+ if (ret && ret != T_EXIT_SKIP) {
16721672+ fprintf(stderr, "test_timeout_multishot_nr failed\n");
16731673+ return ret;
16741674+ }
16751675+16761676+ /* io_uring_wait_cqe_timeout() may have left a timeout, reinit ring */
16771677+ io_uring_queue_exit(&ring);
16781678+ ret = io_uring_queue_init(8, &ring, 0);
16791679+ if (ret) {
16801680+ fprintf(stderr, "ring setup failed\n");
16811681+ return 1;
16821682+ }
16831683+16841684+ ret = test_timeout_multishot_overflow(&ring);
16851685+ if (ret && ret != T_EXIT_SKIP) {
16861686+ fprintf(stderr, "test_timeout_multishot_overflow failed\n");
16871687+ return ret;
16881688+ }
16891689+16901690+ /* io_uring_wait_cqe_timeout() may have left a timeout, reinit ring */
16911691+ io_uring_queue_exit(&ring);
16921692+ ret = io_uring_queue_init(8, &ring, 0);
16931693+ if (ret) {
16941694+ fprintf(stderr, "ring setup failed\n");
16951695+ return 1;
14211696 }
1422169714231698 ret = test_single_timeout_wait(&ring, &p);
+1-1
vendor/opam/uring/vendor/liburing/test/unlink.c
···11/* SPDX-License-Identifier: MIT */
22/*
33- * Description: run various nop tests
33+ * Description: run various unlink tests
44 *
55 */
66#include <errno.h>
+25
vendor/opam/uring/vendor/liburing/test/version.c
···11+/* SPDX-License-Identifier: MIT */
22+/*
33+ * Description: check version macros and runtime checks work
44+ *
55+ */
66+#include "liburing.h"
77+#include "helpers.h"
88+99+int main(int argc, char *argv[])
1010+{
1111+ if (!IO_URING_CHECK_VERSION(io_uring_major_version(), io_uring_minor_version()))
1212+ return T_EXIT_FAIL;
1313+1414+ if (io_uring_major_version() != IO_URING_VERSION_MAJOR)
1515+ return T_EXIT_FAIL;
1616+1717+ if (io_uring_minor_version() != IO_URING_VERSION_MINOR)
1818+ return T_EXIT_FAIL;
1919+2020+#if !IO_URING_CHECK_VERSION(IO_URING_VERSION_MAJOR, IO_URING_VERSION_MINOR)
2121+ return T_EXIT_FAIL;
2222+#endif
2323+2424+ return T_EXIT_PASS;
2525+}