···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/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
vendor/liburing/debian/changelog
···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/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
+72
vendor/liburing/man/io_uring_check_version.3
···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+
+43
vendor/liburing/man/io_uring_close_ring_fd.3
···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)
+1-1
vendor/liburing/man/io_uring_cqe_get_data.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;
+63
vendor/liburing/man/io_uring_for_each_cqe.3
···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)
+53
vendor/liburing/man/io_uring_free_buf_ring.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)
+94
vendor/liburing/man/io_uring_prep_link_timeout.3
···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)
+22-2
vendor/liburing/man/io_uring_prep_msg_ring.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
+3-3
vendor/liburing/man/io_uring_prep_readv.3
···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.
+3-3
vendor/liburing/man/io_uring_prep_readv2.3
···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.
+5-5
vendor/liburing/man/io_uring_prep_recv.3
···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
+4-4
vendor/liburing/man/io_uring_prep_recvmsg.3
···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.
+40
vendor/liburing/man/io_uring_prep_send.3
···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)
+38
vendor/liburing/man/io_uring_prep_send_set_addr.3
···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_send_set_addr 3 "January 23, 2023" "liburing-2.4" "liburing Manual"
66+.SH NAME
77+io_uring_prep_send_set_addr \- set address details for send requests
88+.SH SYNOPSIS
99+.nf
1010+.B #include <liburing.h>
1111+.PP
1212+.BI "void io_uring_prep_send_set_addr(struct io_uring_sqe *" sqe ","
1313+.BI " const struct sockaddr *" dest_addr ","
1414+.BI " __u16 " addr_len ");"
1515+.fi
1616+.SH DESCRIPTION
1717+.PP
1818+The
1919+.BR io_uring_prep_send_set_addr (3)
2020+function sets a socket destination address specified by
2121+.I dest_addr
2222+and its length using
2323+.I addr_len
2424+parameters. It can be used once
2525+.I sqe
2626+is prepared using any of the
2727+.BR send (2)
2828+io_uring helpers. See man pages of
2929+.BR io_uring_prep_send (3)
3030+or
3131+.BR io_uring_prep_send_zc (3).
3232+.SH RETURN VALUE
3333+None
3434+.SH SEE ALSO
3535+.BR io_uring_get_sqe (3),
3636+.BR io_uring_prep_send (3),
3737+.BR io_uring_prep_send_zc (3),
3838+.BR send (2)
+39-7
vendor/liburing/man/io_uring_prep_send_zc.3
···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)
+40
vendor/liburing/man/io_uring_prep_splice.3
···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.
+7
vendor/liburing/man/io_uring_prep_timeout.3
···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
···5454.I res
5555value.
5656.PP
5757+The timeout remove command does not currently accept any flags.
57585859.SH RETURN VALUE
5960None
+2-2
vendor/liburing/man/io_uring_prep_writev.3
···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.
+2-2
vendor/liburing/man/io_uring_prep_writev2.3
···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.
+6-6
vendor/liburing/man/io_uring_queue_init.3
···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
+13-9
vendor/liburing/man/io_uring_recvmsg_out.3
···22.\"
33.\" SPDX-License-Identifier: LGPL-2.0-or-later
44.\"
55-.TH io_uring_recvmsg_out 3 "Julyu 26, 2022" "liburing-2.2" "liburing Manual"
55+.TH io_uring_recvmsg_out 3 "July 26, 2022" "liburing-2.2" "liburing Manual"
66.SH NAME
77io_uring_recvmsg_out - access data from multishot recvmsg
88.SH SYNOPSIS
···1515.PP
1616.BI "void *io_uring_recvmsg_name(struct io_uring_recvmsg_out *" o ");"
1717.PP
1818-.BI "struct cmsghdr *io_uring_recvmsg_cmsg_firsthdr(struct io_uring_recvmsg_out * " o ","
1919-.BI " struct msghdr *" msgh ");"
2020-.BI "struct cmsghdr *io_uring_recvmsg_cmsg_nexthdr(struct io_uring_recvmsg_out * " o ","
1818+.BI "struct cmsghdr *io_uring_recvmsg_cmsg_firsthdr(struct io_uring_recvmsg_out *" o ","
1919+.BI " struct msghdr *" msgh ");"
2020+.BI "struct cmsghdr *io_uring_recvmsg_cmsg_nexthdr(struct io_uring_recvmsg_out *" o ","
2121.BI " struct msghdr *" msgh ","
2222.BI " struct cmsghdr *" cmsg ");"
2323.PP
2424-.BI "void *io_uring_recvmsg_payload(struct io_uring_recvmsg_out * " o ","
2424+.BI "void *io_uring_recvmsg_payload(struct io_uring_recvmsg_out *" o ","
2525.BI " struct msghdr *" msgh ");"
2626.BI "unsigned int io_uring_recvmsg_payload_length(struct io_uring_recvmsg_out *" o ","
2727.BI " int " buf_len ","
···3232.SH DESCRIPTION
33333434These functions are used to access data in the payload delivered by
3535-.BR io_uring_prep_recv_multishot (3)
3636-.
3535+.BR io_uring_prep_recvmsg_multishot (3).
3636+.PP
3737+.I msgh
3838+should point to the
3939+.I struct msghdr
4040+submitted with the request.
3741.PP
3842.BR io_uring_recvmsg_validate (3)
3943will validate a buffer delivered by
4040-.BR io_uring_prep_recv_multishot (3)
4444+.BR io_uring_prep_recvmsg_multishot (3)
4145and extract the
4246.I io_uring_recvmsg_out
4347if it is valid, returning a pointer to it or else NULL.
···757976807781.SH "SEE ALSO"
7878-.BR io_uring_prep_recv_multishot (3)
8282+.BR io_uring_prep_recvmsg_multishot (3)
+18-9
vendor/liburing/man/io_uring_register.2
···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).
+4-4
vendor/liburing/man/io_uring_register_buf_ring.3
···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.
+49-6
vendor/liburing/man/io_uring_register_buffers.3
···99.nf
1010.B #include <liburing.h>
1111.PP
1212-.BI "int io_uring_register_buffers(struct io_uring *" ring ",
1313-.BI " const struct iovec *" iovecs ",
1212+.BI "int io_uring_register_buffers(struct io_uring *" ring ","
1313+.BI " const struct iovec *" iovecs ","
1414.BI " unsigned " nr_iovecs ");"
1515.PP
1616-.BI "int io_uring_register_buffers_sparse(struct io_uring *" ring ",
1717-.BI " unsigned " nr_iovecs ");"
1616+.BI "int io_uring_register_buffers_tags(struct io_uring *" ring ","
1717+.BI " const struct iovec *" iovecs ","
1818+.BI " const __u64 *" tags ","
1919+.BI " unsigned " nr ");"
2020+.PP
2121+.BI "int io_uring_register_buffers_sparse(struct io_uring *" ring ","
2222+.BI " unsigned " nr_iovecs ");"
2323+.PP
2424+.BI "int io_uring_register_buffers_update_tag(struct io_uring *" ring ","
2525+.BI " unsigned " off ","
2626+.BI " const struct iovec *" iovecs ","
2727+.BI " const __u64 *" tags ","
2828+.BI " unsigned " nr ");"
1829.fi
1930.SH DESCRIPTION
2031.PP
···2839.IR ring .
29403041The
4242+.BR io_uring_register_buffers_tags (3)
4343+function behaves the same as
4444+.BR io_uring_register_buffers (3)
4545+function but additionally takes
4646+.I tags
4747+parameter. See
4848+.B IORING_REGISTER_BUFFERS2
4949+for the resource tagging description.
5050+5151+The
3152.BR io_uring_register_buffers_sparse (3)
3253function registers
3354.I nr_iovecs
···4667every time IO is performed to that region. Additionally, it also avoids
4768manipulating the page reference counts for each IO.
48697070+The
7171+.BR io_uring_register_buffers_update_tag (3)
7272+function updates registered buffers with new ones, either turning a sparse
7373+entry into a real one, or replacing an existing entry. The
7474+.I off
7575+is offset on which to start the update
7676+.I nr
7777+number of buffers defined by the array
7878+.I iovecs
7979+belonging to the
8080+.IR ring .
8181+The
8282+.I tags
8383+points to an array of tags. See
8484+.B IORING_REGISTER_BUFFERS2
8585+for the resource tagging description.
8686+4987.SH RETURN VALUE
5088On success
5151-.BR io_uring_register_buffers (3)
8989+.BR io_uring_register_buffers (3),
9090+.BR io_uring_register_buffers_tags (3)
5291and
5392.BR io_uring_register_buffers_sparse (3)
5454-return 0. On failure they return
9393+return 0.
9494+.BR io_uring_register_buffers_update_tag (3)
9595+return number of buffers updated.
9696+On failure they return
5597.BR -errno .
5698.SH SEE ALSO
9999+.BR io_uring_register (2),
57100.BR io_uring_get_sqe (3),
58101.BR io_uring_unregister_buffers (3),
59102.BR io_uring_register_buf_ring (3),
···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)
+76
vendor/liburing/man/io_uring_setup_buf_ring.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_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)
+1
vendor/liburing/man/io_uring_wait_cqe.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)
+2-2
vendor/liburing/man/io_uring_wait_cqe_timeout.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)
+5-1
vendor/liburing/man/io_uring_wait_cqes.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/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
+249-158
vendor/liburing/src/include/liburing.h
···2323#include <linux/swab.h>
2424#include "liburing/compat.h"
2525#include "liburing/io_uring.h"
2626+#include "liburing/io_uring_version.h"
2627#include "liburing/barrier.h"
27282829#ifndef uring_unlikely
···31323233#ifndef uring_likely
3334#define uring_likely(cond) __builtin_expect(!!(cond), 1)
3535+#endif
3636+3737+#ifndef IOURINGINLINE
3838+#define IOURINGINLINE static inline
3439#endif
35403641#ifdef __alpha__
···151156 */
152157void io_uring_free_probe(struct io_uring_probe *probe);
153158154154-static inline int io_uring_opcode_supported(const struct io_uring_probe *p,
159159+IOURINGINLINE int io_uring_opcode_supported(const struct io_uring_probe *p,
155160 int op)
156161{
157162 if (op > p->last_op)
···226231 unsigned int *values);
227232int io_uring_register_ring_fd(struct io_uring *ring);
228233int io_uring_unregister_ring_fd(struct io_uring *ring);
234234+int io_uring_close_ring_fd(struct io_uring *ring);
229235int io_uring_register_buf_ring(struct io_uring *ring,
230236 struct io_uring_buf_reg *reg, unsigned int flags);
231237int io_uring_unregister_buf_ring(struct io_uring *ring, int bgid);
···251257 unsigned int nr_args);
252258253259/*
260260+ * Mapped buffer ring alloc/register + unregister/free helpers
261261+ */
262262+struct io_uring_buf_ring *io_uring_setup_buf_ring(struct io_uring *ring,
263263+ unsigned int nentries,
264264+ int bgid, unsigned int flags,
265265+ int *ret);
266266+int io_uring_free_buf_ring(struct io_uring *ring, struct io_uring_buf_ring *br,
267267+ unsigned int nentries, int bgid);
268268+269269+/*
254270 * Helper for the peek/wait single cqe functions. Exported because of that,
255271 * but probably shouldn't be used directly in an application.
256272 */
···283299/*
284300 * Must be called after io_uring_for_each_cqe()
285301 */
286286-static inline void io_uring_cq_advance(struct io_uring *ring,
287287- unsigned nr)
302302+IOURINGINLINE void io_uring_cq_advance(struct io_uring *ring, unsigned nr)
288303{
289304 if (nr) {
290305 struct io_uring_cq *cq = &ring->cq;
···301316 * Must be called after io_uring_{peek,wait}_cqe() after the cqe has
302317 * been processed by the application.
303318 */
304304-static inline void io_uring_cqe_seen(struct io_uring *ring,
319319+IOURINGINLINE void io_uring_cqe_seen(struct io_uring *ring,
305320 struct io_uring_cqe *cqe)
306321{
307322 if (cqe)
···316331 * Associate pointer @data with the sqe, for later retrieval from the cqe
317332 * at command completion time with io_uring_cqe_get_data().
318333 */
319319-static inline void io_uring_sqe_set_data(struct io_uring_sqe *sqe, void *data)
334334+IOURINGINLINE void io_uring_sqe_set_data(struct io_uring_sqe *sqe, void *data)
320335{
321336 sqe->user_data = (unsigned long) data;
322337}
323338324324-static inline void *io_uring_cqe_get_data(const struct io_uring_cqe *cqe)
339339+IOURINGINLINE void *io_uring_cqe_get_data(const struct io_uring_cqe *cqe)
325340{
326341 return (void *) (uintptr_t) cqe->user_data;
327342}
···331346 * time with io_uring_cqe_get_data64. Just like the non-64 variants, except
332347 * these store a 64-bit type rather than a data pointer.
333348 */
334334-static inline void io_uring_sqe_set_data64(struct io_uring_sqe *sqe,
349349+IOURINGINLINE void io_uring_sqe_set_data64(struct io_uring_sqe *sqe,
335350 __u64 data)
336351{
337352 sqe->user_data = data;
338353}
339354340340-static inline __u64 io_uring_cqe_get_data64(const struct io_uring_cqe *cqe)
355355+IOURINGINLINE __u64 io_uring_cqe_get_data64(const struct io_uring_cqe *cqe)
341356{
342357 return cqe->user_data;
343358}
···347362 */
348363#define LIBURING_HAVE_DATA64
349364350350-static inline void io_uring_sqe_set_flags(struct io_uring_sqe *sqe,
365365+IOURINGINLINE void io_uring_sqe_set_flags(struct io_uring_sqe *sqe,
351366 unsigned flags)
352367{
353368 sqe->flags = (__u8) flags;
354369}
355370356356-static inline void __io_uring_set_target_fixed_file(struct io_uring_sqe *sqe,
371371+IOURINGINLINE void __io_uring_set_target_fixed_file(struct io_uring_sqe *sqe,
357372 unsigned int file_index)
358373{
359374 /* 0 means no fixed files, indexes should be encoded as "index + 1" */
360375 sqe->file_index = file_index + 1;
361376}
362377363363-static inline void io_uring_prep_rw(int op, struct io_uring_sqe *sqe, int fd,
378378+IOURINGINLINE void io_uring_prep_rw(int op, struct io_uring_sqe *sqe, int fd,
364379 const void *addr, unsigned len,
365380 __u64 offset)
366381{
···379394 sqe->__pad2[0] = 0;
380395}
381396382382-/**
383383- * @pre Either fd_in or fd_out must be a pipe.
384384- * @param off_in If fd_in refers to a pipe, off_in must be (int64_t) -1;
385385- * If fd_in does not refer to a pipe and off_in is (int64_t) -1,
386386- * then bytes are read from fd_in starting from the file offset
387387- * and it is adjust appropriately;
388388- * If fd_in does not refer to a pipe and off_in is not
389389- * (int64_t) -1, then the starting offset of fd_in will be
390390- * off_in.
391391- * @param off_out The description of off_in also applied to off_out.
392392- * @param splice_flags see man splice(2) for description of flags.
397397+/*
398398+ * io_uring_prep_splice() - Either @fd_in or @fd_out must be a pipe.
399399+ *
400400+ * - If @fd_in refers to a pipe, @off_in is ignored and must be set to -1.
401401+ *
402402+ * - If @fd_in does not refer to a pipe and @off_in is -1, then @nbytes are read
403403+ * from @fd_in starting from the file offset, which is incremented by the
404404+ * number of bytes read.
405405+ *
406406+ * - If @fd_in does not refer to a pipe and @off_in is not -1, then the starting
407407+ * offset of @fd_in will be @off_in.
393408 *
394409 * This splice operation can be used to implement sendfile by splicing to an
395410 * intermediate pipe first, then splice to the final destination.
396411 * In fact, the implementation of sendfile in kernel uses splice internally.
397412 *
398413 * NOTE that even if fd_in or fd_out refers to a pipe, the splice operation
399399- * can still failed with EINVAL if one of the fd doesn't explicitly support
400400- * splice operation, e.g. reading from terminal is unsupported from kernel 5.7
401401- * to 5.11.
414414+ * can still fail with EINVAL if one of the fd doesn't explicitly support splice
415415+ * operation, e.g. reading from terminal is unsupported from kernel 5.7 to 5.11.
402416 * Check issue #291 for more information.
403417 */
404404-static inline void io_uring_prep_splice(struct io_uring_sqe *sqe,
418418+IOURINGINLINE void io_uring_prep_splice(struct io_uring_sqe *sqe,
405419 int fd_in, int64_t off_in,
406420 int fd_out, int64_t off_out,
407421 unsigned int nbytes,
···414428 sqe->splice_flags = splice_flags;
415429}
416430417417-static inline void io_uring_prep_tee(struct io_uring_sqe *sqe,
431431+IOURINGINLINE void io_uring_prep_tee(struct io_uring_sqe *sqe,
418432 int fd_in, int fd_out,
419433 unsigned int nbytes,
420434 unsigned int splice_flags)
···425439 sqe->splice_flags = splice_flags;
426440}
427441428428-static inline void io_uring_prep_readv(struct io_uring_sqe *sqe, int fd,
442442+IOURINGINLINE void io_uring_prep_readv(struct io_uring_sqe *sqe, int fd,
429443 const struct iovec *iovecs,
430444 unsigned nr_vecs, __u64 offset)
431445{
432446 io_uring_prep_rw(IORING_OP_READV, sqe, fd, iovecs, nr_vecs, offset);
433447}
434448435435-static inline void io_uring_prep_readv2(struct io_uring_sqe *sqe, int fd,
449449+IOURINGINLINE void io_uring_prep_readv2(struct io_uring_sqe *sqe, int fd,
436450 const struct iovec *iovecs,
437451 unsigned nr_vecs, __u64 offset,
438452 int flags)
···441455 sqe->rw_flags = flags;
442456}
443457444444-static inline void io_uring_prep_read_fixed(struct io_uring_sqe *sqe, int fd,
458458+IOURINGINLINE void io_uring_prep_read_fixed(struct io_uring_sqe *sqe, int fd,
445459 void *buf, unsigned nbytes,
446460 __u64 offset, int buf_index)
447461{
···449463 sqe->buf_index = (__u16) buf_index;
450464}
451465452452-static inline void io_uring_prep_writev(struct io_uring_sqe *sqe, int fd,
466466+IOURINGINLINE void io_uring_prep_writev(struct io_uring_sqe *sqe, int fd,
453467 const struct iovec *iovecs,
454468 unsigned nr_vecs, __u64 offset)
455469{
456470 io_uring_prep_rw(IORING_OP_WRITEV, sqe, fd, iovecs, nr_vecs, offset);
457471}
458472459459-static inline void io_uring_prep_writev2(struct io_uring_sqe *sqe, int fd,
473473+IOURINGINLINE void io_uring_prep_writev2(struct io_uring_sqe *sqe, int fd,
460474 const struct iovec *iovecs,
461475 unsigned nr_vecs, __u64 offset,
462476 int flags)
···465479 sqe->rw_flags = flags;
466480}
467481468468-static inline void io_uring_prep_write_fixed(struct io_uring_sqe *sqe, int fd,
482482+IOURINGINLINE void io_uring_prep_write_fixed(struct io_uring_sqe *sqe, int fd,
469483 const void *buf, unsigned nbytes,
470484 __u64 offset, int buf_index)
471485{
···473487 sqe->buf_index = (__u16) buf_index;
474488}
475489476476-static inline void io_uring_prep_recvmsg(struct io_uring_sqe *sqe, int fd,
490490+IOURINGINLINE void io_uring_prep_recvmsg(struct io_uring_sqe *sqe, int fd,
477491 struct msghdr *msg, unsigned flags)
478492{
479493 io_uring_prep_rw(IORING_OP_RECVMSG, sqe, fd, msg, 1, 0);
480494 sqe->msg_flags = flags;
481495}
482496483483-static inline void io_uring_prep_recvmsg_multishot(struct io_uring_sqe *sqe, int fd,
484484- struct msghdr *msg, unsigned flags)
497497+IOURINGINLINE void io_uring_prep_recvmsg_multishot(struct io_uring_sqe *sqe,
498498+ int fd, struct msghdr *msg,
499499+ unsigned flags)
485500{
486501 io_uring_prep_recvmsg(sqe, fd, msg, flags);
487502 sqe->ioprio |= IORING_RECV_MULTISHOT;
488503}
489504490490-static inline void io_uring_prep_sendmsg(struct io_uring_sqe *sqe, int fd,
505505+IOURINGINLINE void io_uring_prep_sendmsg(struct io_uring_sqe *sqe, int fd,
491506 const struct msghdr *msg,
492507 unsigned flags)
493508{
···495510 sqe->msg_flags = flags;
496511}
497512498498-static inline unsigned __io_uring_prep_poll_mask(unsigned poll_mask)
513513+IOURINGINLINE unsigned __io_uring_prep_poll_mask(unsigned poll_mask)
499514{
500515#if __BYTE_ORDER == __BIG_ENDIAN
501516 poll_mask = __swahw32(poll_mask);
···503518 return poll_mask;
504519}
505520506506-static inline void io_uring_prep_poll_add(struct io_uring_sqe *sqe, int fd,
521521+IOURINGINLINE void io_uring_prep_poll_add(struct io_uring_sqe *sqe, int fd,
507522 unsigned poll_mask)
508523{
509524 io_uring_prep_rw(IORING_OP_POLL_ADD, sqe, fd, NULL, 0, 0);
510525 sqe->poll32_events = __io_uring_prep_poll_mask(poll_mask);
511526}
512527513513-static inline void io_uring_prep_poll_multishot(struct io_uring_sqe *sqe,
528528+IOURINGINLINE void io_uring_prep_poll_multishot(struct io_uring_sqe *sqe,
514529 int fd, unsigned poll_mask)
515530{
516531 io_uring_prep_poll_add(sqe, fd, poll_mask);
517532 sqe->len = IORING_POLL_ADD_MULTI;
518533}
519534520520-static inline void io_uring_prep_poll_remove(struct io_uring_sqe *sqe,
535535+IOURINGINLINE void io_uring_prep_poll_remove(struct io_uring_sqe *sqe,
521536 __u64 user_data)
522537{
523538 io_uring_prep_rw(IORING_OP_POLL_REMOVE, sqe, -1, NULL, 0, 0);
524539 sqe->addr = user_data;
525540}
526541527527-static inline void io_uring_prep_poll_update(struct io_uring_sqe *sqe,
542542+IOURINGINLINE void io_uring_prep_poll_update(struct io_uring_sqe *sqe,
528543 __u64 old_user_data,
529544 __u64 new_user_data,
530545 unsigned poll_mask, unsigned flags)
···535550 sqe->poll32_events = __io_uring_prep_poll_mask(poll_mask);
536551}
537552538538-static inline void io_uring_prep_fsync(struct io_uring_sqe *sqe, int fd,
553553+IOURINGINLINE void io_uring_prep_fsync(struct io_uring_sqe *sqe, int fd,
539554 unsigned fsync_flags)
540555{
541556 io_uring_prep_rw(IORING_OP_FSYNC, sqe, fd, NULL, 0, 0);
542557 sqe->fsync_flags = fsync_flags;
543558}
544559545545-static inline void io_uring_prep_nop(struct io_uring_sqe *sqe)
560560+IOURINGINLINE void io_uring_prep_nop(struct io_uring_sqe *sqe)
546561{
547562 io_uring_prep_rw(IORING_OP_NOP, sqe, -1, NULL, 0, 0);
548563}
549564550550-static inline void io_uring_prep_timeout(struct io_uring_sqe *sqe,
565565+IOURINGINLINE void io_uring_prep_timeout(struct io_uring_sqe *sqe,
551566 struct __kernel_timespec *ts,
552567 unsigned count, unsigned flags)
553568{
···555570 sqe->timeout_flags = flags;
556571}
557572558558-static inline void io_uring_prep_timeout_remove(struct io_uring_sqe *sqe,
573573+IOURINGINLINE void io_uring_prep_timeout_remove(struct io_uring_sqe *sqe,
559574 __u64 user_data, unsigned flags)
560575{
561576 io_uring_prep_rw(IORING_OP_TIMEOUT_REMOVE, sqe, -1, NULL, 0, 0);
···563578 sqe->timeout_flags = flags;
564579}
565580566566-static inline void io_uring_prep_timeout_update(struct io_uring_sqe *sqe,
581581+IOURINGINLINE void io_uring_prep_timeout_update(struct io_uring_sqe *sqe,
567582 struct __kernel_timespec *ts,
568583 __u64 user_data, unsigned flags)
569584{
···573588 sqe->timeout_flags = flags | IORING_TIMEOUT_UPDATE;
574589}
575590576576-static inline void io_uring_prep_accept(struct io_uring_sqe *sqe, int fd,
591591+IOURINGINLINE void io_uring_prep_accept(struct io_uring_sqe *sqe, int fd,
577592 struct sockaddr *addr,
578593 socklen_t *addrlen, int flags)
579594{
···583598}
584599585600/* accept directly into the fixed file table */
586586-static inline void io_uring_prep_accept_direct(struct io_uring_sqe *sqe, int fd,
601601+IOURINGINLINE void io_uring_prep_accept_direct(struct io_uring_sqe *sqe, int fd,
587602 struct sockaddr *addr,
588603 socklen_t *addrlen, int flags,
589604 unsigned int file_index)
590605{
591606 io_uring_prep_accept(sqe, fd, addr, addrlen, flags);
607607+ /* offset by 1 for allocation */
608608+ if (file_index == IORING_FILE_INDEX_ALLOC)
609609+ file_index--;
592610 __io_uring_set_target_fixed_file(sqe, file_index);
593611}
594612595595-static inline void io_uring_prep_multishot_accept(struct io_uring_sqe *sqe,
613613+IOURINGINLINE void io_uring_prep_multishot_accept(struct io_uring_sqe *sqe,
596614 int fd, struct sockaddr *addr,
597615 socklen_t *addrlen, int flags)
598616{
···601619}
602620603621/* multishot accept directly into the fixed file table */
604604-static inline void io_uring_prep_multishot_accept_direct(struct io_uring_sqe *sqe,
622622+IOURINGINLINE void io_uring_prep_multishot_accept_direct(struct io_uring_sqe *sqe,
605623 int fd,
606624 struct sockaddr *addr,
607625 socklen_t *addrlen,
···611629 __io_uring_set_target_fixed_file(sqe, IORING_FILE_INDEX_ALLOC - 1);
612630}
613631614614-static inline void io_uring_prep_cancel64(struct io_uring_sqe *sqe,
632632+IOURINGINLINE void io_uring_prep_cancel64(struct io_uring_sqe *sqe,
615633 __u64 user_data, int flags)
616634{
617635 io_uring_prep_rw(IORING_OP_ASYNC_CANCEL, sqe, -1, NULL, 0, 0);
···619637 sqe->cancel_flags = (__u32) flags;
620638}
621639622622-static inline void io_uring_prep_cancel(struct io_uring_sqe *sqe,
640640+IOURINGINLINE void io_uring_prep_cancel(struct io_uring_sqe *sqe,
623641 void *user_data, int flags)
624642{
625643 io_uring_prep_cancel64(sqe, (__u64) (uintptr_t) user_data, flags);
626644}
627645628628-static inline void io_uring_prep_cancel_fd(struct io_uring_sqe *sqe, int fd,
646646+IOURINGINLINE void io_uring_prep_cancel_fd(struct io_uring_sqe *sqe, int fd,
629647 unsigned int flags)
630648{
631649 io_uring_prep_rw(IORING_OP_ASYNC_CANCEL, sqe, fd, NULL, 0, 0);
632650 sqe->cancel_flags = (__u32) flags | IORING_ASYNC_CANCEL_FD;
633651}
634652635635-static inline void io_uring_prep_link_timeout(struct io_uring_sqe *sqe,
653653+IOURINGINLINE void io_uring_prep_link_timeout(struct io_uring_sqe *sqe,
636654 struct __kernel_timespec *ts,
637655 unsigned flags)
638656{
···640658 sqe->timeout_flags = flags;
641659}
642660643643-static inline void io_uring_prep_connect(struct io_uring_sqe *sqe, int fd,
661661+IOURINGINLINE void io_uring_prep_connect(struct io_uring_sqe *sqe, int fd,
644662 const struct sockaddr *addr,
645663 socklen_t addrlen)
646664{
647665 io_uring_prep_rw(IORING_OP_CONNECT, sqe, fd, addr, 0, addrlen);
648666}
649667650650-static inline void io_uring_prep_files_update(struct io_uring_sqe *sqe,
668668+IOURINGINLINE void io_uring_prep_files_update(struct io_uring_sqe *sqe,
651669 int *fds, unsigned nr_fds,
652670 int offset)
653671{
···655673 (__u64) offset);
656674}
657675658658-static inline void io_uring_prep_fallocate(struct io_uring_sqe *sqe, int fd,
659659- int mode, off_t offset, off_t len)
676676+IOURINGINLINE void io_uring_prep_fallocate(struct io_uring_sqe *sqe, int fd,
677677+ int mode, __u64 offset, __u64 len)
660678{
661679 io_uring_prep_rw(IORING_OP_FALLOCATE, sqe, fd,
662680 0, (unsigned int) mode, (__u64) offset);
663681 sqe->addr = (__u64) len;
664682}
665683666666-static inline void io_uring_prep_openat(struct io_uring_sqe *sqe, int dfd,
684684+IOURINGINLINE void io_uring_prep_openat(struct io_uring_sqe *sqe, int dfd,
667685 const char *path, int flags,
668686 mode_t mode)
669687{
···672690}
673691674692/* open directly into the fixed file table */
675675-static inline void io_uring_prep_openat_direct(struct io_uring_sqe *sqe,
693693+IOURINGINLINE void io_uring_prep_openat_direct(struct io_uring_sqe *sqe,
676694 int dfd, const char *path,
677695 int flags, mode_t mode,
678696 unsigned file_index)
679697{
680698 io_uring_prep_openat(sqe, dfd, path, flags, mode);
699699+ /* offset by 1 for allocation */
700700+ if (file_index == IORING_FILE_INDEX_ALLOC)
701701+ file_index--;
681702 __io_uring_set_target_fixed_file(sqe, file_index);
682703}
683704684684-static inline void io_uring_prep_close(struct io_uring_sqe *sqe, int fd)
705705+IOURINGINLINE void io_uring_prep_close(struct io_uring_sqe *sqe, int fd)
685706{
686707 io_uring_prep_rw(IORING_OP_CLOSE, sqe, fd, NULL, 0, 0);
687708}
688709689689-static inline void io_uring_prep_close_direct(struct io_uring_sqe *sqe,
710710+IOURINGINLINE void io_uring_prep_close_direct(struct io_uring_sqe *sqe,
690711 unsigned file_index)
691712{
692713 io_uring_prep_close(sqe, 0);
693714 __io_uring_set_target_fixed_file(sqe, file_index);
694715}
695716696696-static inline void io_uring_prep_read(struct io_uring_sqe *sqe, int fd,
717717+IOURINGINLINE void io_uring_prep_read(struct io_uring_sqe *sqe, int fd,
697718 void *buf, unsigned nbytes, __u64 offset)
698719{
699720 io_uring_prep_rw(IORING_OP_READ, sqe, fd, buf, nbytes, offset);
700721}
701722702702-static inline void io_uring_prep_write(struct io_uring_sqe *sqe, int fd,
723723+IOURINGINLINE void io_uring_prep_write(struct io_uring_sqe *sqe, int fd,
703724 const void *buf, unsigned nbytes,
704725 __u64 offset)
705726{
···707728}
708729709730struct statx;
710710-static inline void io_uring_prep_statx(struct io_uring_sqe *sqe, int dfd,
711711- const char *path, int flags, unsigned mask,
712712- struct statx *statxbuf)
731731+IOURINGINLINE void io_uring_prep_statx(struct io_uring_sqe *sqe, int dfd,
732732+ const char *path, int flags,
733733+ unsigned mask, struct statx *statxbuf)
713734{
714735 io_uring_prep_rw(IORING_OP_STATX, sqe, dfd, path, mask,
715736 (__u64) (unsigned long) statxbuf);
716737 sqe->statx_flags = (__u32) flags;
717738}
718739719719-static inline void io_uring_prep_fadvise(struct io_uring_sqe *sqe, int fd,
740740+IOURINGINLINE void io_uring_prep_fadvise(struct io_uring_sqe *sqe, int fd,
720741 __u64 offset, off_t len, int advice)
721742{
722743 io_uring_prep_rw(IORING_OP_FADVISE, sqe, fd, NULL, (__u32) len, offset);
723744 sqe->fadvise_advice = (__u32) advice;
724745}
725746726726-static inline void io_uring_prep_madvise(struct io_uring_sqe *sqe, void *addr,
747747+IOURINGINLINE void io_uring_prep_madvise(struct io_uring_sqe *sqe, void *addr,
727748 off_t length, int advice)
728749{
729750 io_uring_prep_rw(IORING_OP_MADVISE, sqe, -1, addr, (__u32) length, 0);
730751 sqe->fadvise_advice = (__u32) advice;
731752}
732753733733-static inline void io_uring_prep_send(struct io_uring_sqe *sqe, int sockfd,
754754+IOURINGINLINE void io_uring_prep_send(struct io_uring_sqe *sqe, int sockfd,
734755 const void *buf, size_t len, int flags)
735756{
736757 io_uring_prep_rw(IORING_OP_SEND, sqe, sockfd, buf, (__u32) len, 0);
737758 sqe->msg_flags = (__u32) flags;
738759}
739760740740-static inline void io_uring_prep_send_zc(struct io_uring_sqe *sqe, int sockfd,
761761+IOURINGINLINE void io_uring_prep_send_set_addr(struct io_uring_sqe *sqe,
762762+ const struct sockaddr *dest_addr,
763763+ __u16 addr_len)
764764+{
765765+ sqe->addr2 = (unsigned long)(const void *)dest_addr;
766766+ sqe->addr_len = addr_len;
767767+}
768768+769769+IOURINGINLINE void io_uring_prep_sendto(struct io_uring_sqe *sqe, int sockfd,
770770+ const void *buf, size_t len, int flags,
771771+ const struct sockaddr *addr,
772772+ socklen_t addrlen)
773773+{
774774+ io_uring_prep_send(sqe, sockfd, buf, len, flags);
775775+ io_uring_prep_send_set_addr(sqe, addr, addrlen);
776776+}
777777+778778+IOURINGINLINE void io_uring_prep_send_zc(struct io_uring_sqe *sqe, int sockfd,
741779 const void *buf, size_t len, int flags,
742780 unsigned zc_flags)
743781{
···746784 sqe->ioprio = zc_flags;
747785}
748786749749-static inline void io_uring_prep_send_zc_fixed(struct io_uring_sqe *sqe,
787787+IOURINGINLINE void io_uring_prep_send_zc_fixed(struct io_uring_sqe *sqe,
750788 int sockfd, const void *buf,
751789 size_t len, int flags,
752790 unsigned zc_flags,
···757795 sqe->buf_index = buf_index;
758796}
759797760760-static inline void io_uring_prep_sendmsg_zc(struct io_uring_sqe *sqe, int fd,
798798+IOURINGINLINE void io_uring_prep_sendmsg_zc(struct io_uring_sqe *sqe, int fd,
761799 const struct msghdr *msg,
762800 unsigned flags)
763801{
···765803 sqe->opcode = IORING_OP_SENDMSG_ZC;
766804}
767805768768-static inline void io_uring_prep_send_set_addr(struct io_uring_sqe *sqe,
769769- const struct sockaddr *dest_addr,
770770- __u16 addr_len)
771771-{
772772- sqe->addr2 = (unsigned long)(const void *)dest_addr;
773773- sqe->addr_len = addr_len;
774774-}
775775-776776-static inline void io_uring_prep_recv(struct io_uring_sqe *sqe, int sockfd,
806806+IOURINGINLINE void io_uring_prep_recv(struct io_uring_sqe *sqe, int sockfd,
777807 void *buf, size_t len, int flags)
778808{
779809 io_uring_prep_rw(IORING_OP_RECV, sqe, sockfd, buf, (__u32) len, 0);
780810 sqe->msg_flags = (__u32) flags;
781811}
782812783783-static inline void io_uring_prep_recv_multishot(struct io_uring_sqe *sqe,
813813+IOURINGINLINE void io_uring_prep_recv_multishot(struct io_uring_sqe *sqe,
784814 int sockfd, void *buf,
785815 size_t len, int flags)
786816{
···788818 sqe->ioprio |= IORING_RECV_MULTISHOT;
789819}
790820791791-static inline struct io_uring_recvmsg_out *
821821+IOURINGINLINE struct io_uring_recvmsg_out *
792822io_uring_recvmsg_validate(void *buf, int buf_len, struct msghdr *msgh)
793823{
794824 unsigned long header = msgh->msg_controllen + msgh->msg_namelen +
···798828 return (struct io_uring_recvmsg_out *)buf;
799829}
800830801801-static inline void *io_uring_recvmsg_name(struct io_uring_recvmsg_out *o)
831831+IOURINGINLINE void *io_uring_recvmsg_name(struct io_uring_recvmsg_out *o)
802832{
803833 return (void *) &o[1];
804834}
805835806806-static inline struct cmsghdr *
836836+IOURINGINLINE struct cmsghdr *
807837io_uring_recvmsg_cmsg_firsthdr(struct io_uring_recvmsg_out *o,
808838 struct msghdr *msgh)
809839{
···814844 msgh->msg_namelen);
815845}
816846817817-static inline struct cmsghdr *
847847+IOURINGINLINE struct cmsghdr *
818848io_uring_recvmsg_cmsg_nexthdr(struct io_uring_recvmsg_out *o, struct msghdr *msgh,
819849 struct cmsghdr *cmsg)
820850{
···835865 return cmsg;
836866}
837867838838-static inline void *io_uring_recvmsg_payload(struct io_uring_recvmsg_out *o,
868868+IOURINGINLINE void *io_uring_recvmsg_payload(struct io_uring_recvmsg_out *o,
839869 struct msghdr *msgh)
840870{
841871 return (void *)((unsigned char *)io_uring_recvmsg_name(o) +
842872 msgh->msg_namelen + msgh->msg_controllen);
843873}
844874845845-static inline unsigned int
875875+IOURINGINLINE unsigned int
846876io_uring_recvmsg_payload_length(struct io_uring_recvmsg_out *o,
847877 int buf_len, struct msghdr *msgh)
848878{
···853883 return (unsigned int) (payload_end - payload_start);
854884}
855885856856-static inline void io_uring_prep_openat2(struct io_uring_sqe *sqe, int dfd,
886886+IOURINGINLINE void io_uring_prep_openat2(struct io_uring_sqe *sqe, int dfd,
857887 const char *path, struct open_how *how)
858888{
859889 io_uring_prep_rw(IORING_OP_OPENAT2, sqe, dfd, path, sizeof(*how),
···861891}
862892863893/* open directly into the fixed file table */
864864-static inline void io_uring_prep_openat2_direct(struct io_uring_sqe *sqe,
894894+IOURINGINLINE void io_uring_prep_openat2_direct(struct io_uring_sqe *sqe,
865895 int dfd, const char *path,
866896 struct open_how *how,
867897 unsigned file_index)
868898{
869899 io_uring_prep_openat2(sqe, dfd, path, how);
900900+ /* offset by 1 for allocation */
901901+ if (file_index == IORING_FILE_INDEX_ALLOC)
902902+ file_index--;
870903 __io_uring_set_target_fixed_file(sqe, file_index);
871904}
872905873906struct epoll_event;
874874-static inline void io_uring_prep_epoll_ctl(struct io_uring_sqe *sqe, int epfd,
907907+IOURINGINLINE void io_uring_prep_epoll_ctl(struct io_uring_sqe *sqe, int epfd,
875908 int fd, int op,
876909 struct epoll_event *ev)
877910{
···879912 (__u32) op, (__u32) fd);
880913}
881914882882-static inline void io_uring_prep_provide_buffers(struct io_uring_sqe *sqe,
915915+IOURINGINLINE void io_uring_prep_provide_buffers(struct io_uring_sqe *sqe,
883916 void *addr, int len, int nr,
884917 int bgid, int bid)
885918{
···888921 sqe->buf_group = (__u16) bgid;
889922}
890923891891-static inline void io_uring_prep_remove_buffers(struct io_uring_sqe *sqe,
924924+IOURINGINLINE void io_uring_prep_remove_buffers(struct io_uring_sqe *sqe,
892925 int nr, int bgid)
893926{
894927 io_uring_prep_rw(IORING_OP_REMOVE_BUFFERS, sqe, nr, NULL, 0, 0);
895928 sqe->buf_group = (__u16) bgid;
896929}
897930898898-static inline void io_uring_prep_shutdown(struct io_uring_sqe *sqe, int fd,
931931+IOURINGINLINE void io_uring_prep_shutdown(struct io_uring_sqe *sqe, int fd,
899932 int how)
900933{
901934 io_uring_prep_rw(IORING_OP_SHUTDOWN, sqe, fd, NULL, (__u32) how, 0);
902935}
903936904904-static inline void io_uring_prep_unlinkat(struct io_uring_sqe *sqe, int dfd,
937937+IOURINGINLINE void io_uring_prep_unlinkat(struct io_uring_sqe *sqe, int dfd,
905938 const char *path, int flags)
906939{
907940 io_uring_prep_rw(IORING_OP_UNLINKAT, sqe, dfd, path, 0, 0);
908941 sqe->unlink_flags = (__u32) flags;
909942}
910943911911-static inline void io_uring_prep_unlink(struct io_uring_sqe *sqe,
944944+IOURINGINLINE void io_uring_prep_unlink(struct io_uring_sqe *sqe,
912945 const char *path, int flags)
913946{
914947 io_uring_prep_unlinkat(sqe, AT_FDCWD, path, flags);
915948}
916949917917-static inline void io_uring_prep_renameat(struct io_uring_sqe *sqe, int olddfd,
950950+IOURINGINLINE void io_uring_prep_renameat(struct io_uring_sqe *sqe, int olddfd,
918951 const char *oldpath, int newdfd,
919952 const char *newpath, unsigned int flags)
920953{
···924957 sqe->rename_flags = (__u32) flags;
925958}
926959927927-static inline void io_uring_prep_rename(struct io_uring_sqe *sqe,
928928- const char *oldpath, const char *newpath)
960960+IOURINGINLINE void io_uring_prep_rename(struct io_uring_sqe *sqe,
961961+ const char *oldpath,
962962+ const char *newpath)
929963{
930964 io_uring_prep_renameat(sqe, AT_FDCWD, oldpath, AT_FDCWD, newpath, 0);
931965}
932966933933-static inline void io_uring_prep_sync_file_range(struct io_uring_sqe *sqe,
967967+IOURINGINLINE void io_uring_prep_sync_file_range(struct io_uring_sqe *sqe,
934968 int fd, unsigned len,
935969 __u64 offset, int flags)
936970{
···938972 sqe->sync_range_flags = (__u32) flags;
939973}
940974941941-static inline void io_uring_prep_mkdirat(struct io_uring_sqe *sqe, int dfd,
975975+IOURINGINLINE void io_uring_prep_mkdirat(struct io_uring_sqe *sqe, int dfd,
942976 const char *path, mode_t mode)
943977{
944978 io_uring_prep_rw(IORING_OP_MKDIRAT, sqe, dfd, path, mode, 0);
945979}
946980947947-static inline void io_uring_prep_mkdir(struct io_uring_sqe *sqe,
981981+IOURINGINLINE void io_uring_prep_mkdir(struct io_uring_sqe *sqe,
948982 const char *path, mode_t mode)
949983{
950984 io_uring_prep_mkdirat(sqe, AT_FDCWD, path, mode);
951985}
952986953953-static inline void io_uring_prep_symlinkat(struct io_uring_sqe *sqe,
987987+IOURINGINLINE void io_uring_prep_symlinkat(struct io_uring_sqe *sqe,
954988 const char *target, int newdirfd,
955989 const char *linkpath)
956990{
···958992 (uint64_t) (uintptr_t) linkpath);
959993}
960994961961-static inline void io_uring_prep_symlink(struct io_uring_sqe *sqe,
962962- const char *target, const char *linkpath)
995995+IOURINGINLINE void io_uring_prep_symlink(struct io_uring_sqe *sqe,
996996+ const char *target,
997997+ const char *linkpath)
963998{
964999 io_uring_prep_symlinkat(sqe, target, AT_FDCWD, linkpath);
9651000}
9661001967967-static inline void io_uring_prep_linkat(struct io_uring_sqe *sqe, int olddfd,
10021002+IOURINGINLINE void io_uring_prep_linkat(struct io_uring_sqe *sqe, int olddfd,
9681003 const char *oldpath, int newdfd,
9691004 const char *newpath, int flags)
9701005{
···9731008 sqe->hardlink_flags = (__u32) flags;
9741009}
9751010976976-static inline void io_uring_prep_link(struct io_uring_sqe *sqe,
977977- const char *oldpath, const char *newpath, int flags)
10111011+IOURINGINLINE void io_uring_prep_link(struct io_uring_sqe *sqe,
10121012+ const char *oldpath, const char *newpath,
10131013+ int flags)
9781014{
9791015 io_uring_prep_linkat(sqe, AT_FDCWD, oldpath, AT_FDCWD, newpath, flags);
9801016}
9811017982982-static inline void io_uring_prep_msg_ring(struct io_uring_sqe *sqe, int fd,
10181018+IOURINGINLINE void io_uring_prep_msg_ring_cqe_flags(struct io_uring_sqe *sqe,
10191019+ int fd, unsigned int len, __u64 data,
10201020+ unsigned int flags, unsigned int cqe_flags)
10211021+{
10221022+ io_uring_prep_rw(IORING_OP_MSG_RING, sqe, fd, NULL, len, data);
10231023+ sqe->msg_ring_flags = IORING_MSG_RING_FLAGS_PASS | flags;
10241024+ sqe->file_index = cqe_flags;
10251025+}
10261026+10271027+IOURINGINLINE void io_uring_prep_msg_ring(struct io_uring_sqe *sqe, int fd,
9831028 unsigned int len, __u64 data,
9841029 unsigned int flags)
9851030{
9861031 io_uring_prep_rw(IORING_OP_MSG_RING, sqe, fd, NULL, len, data);
987987- sqe->rw_flags = flags;
10321032+ sqe->msg_ring_flags = flags;
10331033+}
10341034+10351035+IOURINGINLINE void io_uring_prep_msg_ring_fd(struct io_uring_sqe *sqe, int fd,
10361036+ int source_fd, int target_fd,
10371037+ __u64 data, unsigned int flags)
10381038+{
10391039+ io_uring_prep_rw(IORING_OP_MSG_RING, sqe, fd,
10401040+ (void *) (uintptr_t) IORING_MSG_SEND_FD, 0, data);
10411041+ sqe->addr3 = source_fd;
10421042+ /* offset by 1 for allocation */
10431043+ if ((unsigned int) target_fd == IORING_FILE_INDEX_ALLOC)
10441044+ target_fd--;
10451045+ __io_uring_set_target_fixed_file(sqe, target_fd);
10461046+ sqe->msg_ring_flags = flags;
10471047+}
10481048+10491049+IOURINGINLINE void io_uring_prep_msg_ring_fd_alloc(struct io_uring_sqe *sqe,
10501050+ int fd, int source_fd,
10511051+ __u64 data, unsigned int flags)
10521052+{
10531053+ io_uring_prep_msg_ring_fd(sqe, fd, source_fd, IORING_FILE_INDEX_ALLOC,
10541054+ data, flags);
9881055}
9891056990990-static inline void io_uring_prep_getxattr(struct io_uring_sqe *sqe,
991991- const char *name,
992992- char *value,
993993- const char *path,
994994- unsigned int len)
10571057+IOURINGINLINE void io_uring_prep_getxattr(struct io_uring_sqe *sqe,
10581058+ const char *name, char *value,
10591059+ const char *path, unsigned int len)
9951060{
9961061 io_uring_prep_rw(IORING_OP_GETXATTR, sqe, 0, name, len,
9971062 (__u64) (uintptr_t) value);
···9991064 sqe->xattr_flags = 0;
10001065}
1001106610021002-static inline void io_uring_prep_setxattr(struct io_uring_sqe *sqe,
10031003- const char *name,
10041004- const char *value,
10051005- const char *path,
10061006- int flags,
10671067+IOURINGINLINE void io_uring_prep_setxattr(struct io_uring_sqe *sqe,
10681068+ const char *name, const char *value,
10691069+ const char *path, int flags,
10071070 unsigned int len)
10081071{
10091072 io_uring_prep_rw(IORING_OP_SETXATTR, sqe, 0, name, len,
···10121075 sqe->xattr_flags = flags;
10131076}
1014107710151015-static inline void io_uring_prep_fgetxattr(struct io_uring_sqe *sqe,
10161016- int fd,
10171017- const char *name,
10181018- char *value,
10191019- unsigned int len)
10781078+IOURINGINLINE void io_uring_prep_fgetxattr(struct io_uring_sqe *sqe,
10791079+ int fd, const char *name,
10801080+ char *value, unsigned int len)
10201081{
10211082 io_uring_prep_rw(IORING_OP_FGETXATTR, sqe, fd, name, len,
10221083 (__u64) (uintptr_t) value);
10231084 sqe->xattr_flags = 0;
10241085}
1025108610261026-static inline void io_uring_prep_fsetxattr(struct io_uring_sqe *sqe,
10271027- int fd,
10281028- const char *name,
10291029- const char *value,
10301030- int flags,
10311031- unsigned int len)
10871087+IOURINGINLINE void io_uring_prep_fsetxattr(struct io_uring_sqe *sqe, int fd,
10881088+ const char *name, const char *value,
10891089+ int flags, unsigned int len)
10321090{
10331091 io_uring_prep_rw(IORING_OP_FSETXATTR, sqe, fd, name, len,
10341092 (__u64) (uintptr_t) value);
10351093 sqe->xattr_flags = flags;
10361094}
1037109510381038-static inline void io_uring_prep_socket(struct io_uring_sqe *sqe, int domain,
10961096+IOURINGINLINE void io_uring_prep_socket(struct io_uring_sqe *sqe, int domain,
10391097 int type, int protocol,
10401098 unsigned int flags)
10411099{
···10431101 sqe->rw_flags = flags;
10441102}
1045110310461046-static inline void io_uring_prep_socket_direct(struct io_uring_sqe *sqe,
11041104+IOURINGINLINE void io_uring_prep_socket_direct(struct io_uring_sqe *sqe,
10471105 int domain, int type,
10481106 int protocol,
10491107 unsigned file_index,
···10511109{
10521110 io_uring_prep_rw(IORING_OP_SOCKET, sqe, domain, NULL, protocol, type);
10531111 sqe->rw_flags = flags;
11121112+ /* offset by 1 for allocation */
11131113+ if (file_index == IORING_FILE_INDEX_ALLOC)
11141114+ file_index--;
10541115 __io_uring_set_target_fixed_file(sqe, file_index);
10551116}
1056111710571057-static inline void io_uring_prep_socket_direct_alloc(struct io_uring_sqe *sqe,
10581058- int domain, int type, int protocol,
10591059- unsigned int flags)
11181118+IOURINGINLINE void io_uring_prep_socket_direct_alloc(struct io_uring_sqe *sqe,
11191119+ int domain, int type,
11201120+ int protocol,
11211121+ unsigned int flags)
10601122{
10611123 io_uring_prep_rw(IORING_OP_SOCKET, sqe, domain, NULL, protocol, type);
10621124 sqe->rw_flags = flags;
···10671129 * Returns number of unconsumed (if SQPOLL) or unsubmitted entries exist in
10681130 * the SQ ring
10691131 */
10701070-static inline unsigned io_uring_sq_ready(const struct io_uring *ring)
11321132+IOURINGINLINE unsigned io_uring_sq_ready(const struct io_uring *ring)
10711133{
10721134 unsigned khead = *ring->sq.khead;
10731135···10861148/*
10871149 * Returns how much space is left in the SQ ring.
10881150 */
10891089-static inline unsigned io_uring_sq_space_left(const struct io_uring *ring)
11511151+IOURINGINLINE unsigned io_uring_sq_space_left(const struct io_uring *ring)
10901152{
10911153 return ring->sq.ring_entries - io_uring_sq_ready(ring);
10921154}
···10981160 * action is taken. Note: may return -EINVAL if the kernel doesn't support
10991161 * this feature.
11001162 */
11011101-static inline int io_uring_sqring_wait(struct io_uring *ring)
11631163+IOURINGINLINE int io_uring_sqring_wait(struct io_uring *ring)
11021164{
11031165 if (!(ring->flags & IORING_SETUP_SQPOLL))
11041166 return 0;
···11111173/*
11121174 * Returns how many unconsumed entries are ready in the CQ ring
11131175 */
11141114-static inline unsigned io_uring_cq_ready(const struct io_uring *ring)
11761176+IOURINGINLINE unsigned io_uring_cq_ready(const struct io_uring *ring)
11151177{
11161178 return io_uring_smp_load_acquire(ring->cq.ktail) - *ring->cq.khead;
11171179}
···11201182 * Returns true if there are overflow entries waiting to be flushed onto
11211183 * the CQ ring
11221184 */
11231123-static inline bool io_uring_cq_has_overflow(const struct io_uring *ring)
11851185+IOURINGINLINE bool io_uring_cq_has_overflow(const struct io_uring *ring)
11241186{
11251187 return IO_URING_READ_ONCE(*ring->sq.kflags) & IORING_SQ_CQ_OVERFLOW;
11261188}
···11281190/*
11291191 * Returns true if the eventfd notification is currently enabled
11301192 */
11311131-static inline bool io_uring_cq_eventfd_enabled(const struct io_uring *ring)
11931193+IOURINGINLINE bool io_uring_cq_eventfd_enabled(const struct io_uring *ring)
11321194{
11331195 if (!ring->cq.kflags)
11341196 return true;
···11401202 * Toggle eventfd notification on or off, if an eventfd is registered with
11411203 * the ring.
11421204 */
11431143-static inline int io_uring_cq_eventfd_toggle(struct io_uring *ring,
12051205+IOURINGINLINE int io_uring_cq_eventfd_toggle(struct io_uring *ring,
11441206 bool enabled)
11451207{
11461208 uint32_t flags;
···11681230 * readily available. Returns 0 with cqe_ptr filled in on success, -errno on
11691231 * failure.
11701232 */
11711171-static inline int io_uring_wait_cqe_nr(struct io_uring *ring,
12331233+IOURINGINLINE int io_uring_wait_cqe_nr(struct io_uring *ring,
11721234 struct io_uring_cqe **cqe_ptr,
11731235 unsigned wait_nr)
11741236{
···11801242 * "official" versions of this, io_uring_peek_cqe(), io_uring_wait_cqe(),
11811243 * or io_uring_wait_cqes*().
11821244 */
11831183-static inline int __io_uring_peek_cqe(struct io_uring *ring,
12451245+IOURINGINLINE int __io_uring_peek_cqe(struct io_uring *ring,
11841246 struct io_uring_cqe **cqe_ptr,
11851247 unsigned *nr_available)
11861248{
···12261288 * Return an IO completion, if one is readily available. Returns 0 with
12271289 * cqe_ptr filled in on success, -errno on failure.
12281290 */
12291229-static inline int io_uring_peek_cqe(struct io_uring *ring,
12911291+IOURINGINLINE int io_uring_peek_cqe(struct io_uring *ring,
12301292 struct io_uring_cqe **cqe_ptr)
12311293{
12321294 if (!__io_uring_peek_cqe(ring, cqe_ptr, NULL) && *cqe_ptr)
···12391301 * Return an IO completion, waiting for it if necessary. Returns 0 with
12401302 * cqe_ptr filled in on success, -errno on failure.
12411303 */
12421242-static inline int io_uring_wait_cqe(struct io_uring *ring,
13041304+IOURINGINLINE int io_uring_wait_cqe(struct io_uring *ring,
12431305 struct io_uring_cqe **cqe_ptr)
12441306{
12451307 if (!__io_uring_peek_cqe(ring, cqe_ptr, NULL) && *cqe_ptr)
···12551317 *
12561318 * Returns a vacant sqe, or NULL if we're full.
12571319 */
12581258-static inline struct io_uring_sqe *_io_uring_get_sqe(struct io_uring *ring)
13201320+IOURINGINLINE struct io_uring_sqe *_io_uring_get_sqe(struct io_uring *ring)
12591321{
12601322 struct io_uring_sq *sq = &ring->sq;
12611323 unsigned int head, next = sq->sqe_tail + 1;
···12821344/*
12831345 * Return the appropriate mask for a buffer ring of size 'ring_entries'
12841346 */
12851285-static inline int io_uring_buf_ring_mask(__u32 ring_entries)
13471347+IOURINGINLINE int io_uring_buf_ring_mask(__u32 ring_entries)
12861348{
12871349 return ring_entries - 1;
12881350}
1289135112901290-static inline void io_uring_buf_ring_init(struct io_uring_buf_ring *br)
13521352+IOURINGINLINE void io_uring_buf_ring_init(struct io_uring_buf_ring *br)
12911353{
12921354 br->tail = 0;
12931355}
···12951357/*
12961358 * Assign 'buf' with the addr/len/buffer ID supplied
12971359 */
12981298-static inline void io_uring_buf_ring_add(struct io_uring_buf_ring *br,
13601360+IOURINGINLINE void io_uring_buf_ring_add(struct io_uring_buf_ring *br,
12991361 void *addr, unsigned int len,
13001362 unsigned short bid, int mask,
13011363 int buf_offset)
···13121374 * io_uring_buf_ring_add() has been called 'count' times to fill in new
13131375 * buffers.
13141376 */
13151315-static inline void io_uring_buf_ring_advance(struct io_uring_buf_ring *br,
13771377+IOURINGINLINE void io_uring_buf_ring_advance(struct io_uring_buf_ring *br,
13161378 int count)
13171379{
13181380 unsigned short new_tail = br->tail + count;
···13201382 io_uring_smp_store_release(&br->tail, new_tail);
13211383}
1322138413851385+IOURINGINLINE void __io_uring_buf_ring_cq_advance(struct io_uring *ring,
13861386+ struct io_uring_buf_ring *br,
13871387+ int cq_count, int buf_count)
13881388+{
13891389+ br->tail += buf_count;
13901390+ io_uring_cq_advance(ring, cq_count);
13911391+}
13921392+13231393/*
13241394 * Make 'count' new buffers visible to the kernel while at the same time
13251395 * advancing the CQ ring seen entries. This can be used when the application
···13271397 * avoiding an extra atomic when needing to increment both the CQ ring and
13281398 * the ring buffer index at the same time.
13291399 */
13301330-static inline void io_uring_buf_ring_cq_advance(struct io_uring *ring,
14001400+IOURINGINLINE void io_uring_buf_ring_cq_advance(struct io_uring *ring,
13311401 struct io_uring_buf_ring *br,
13321402 int count)
13331403{
13341334- br->tail += count;
13351335- io_uring_cq_advance(ring, count);
14041404+ __io_uring_buf_ring_cq_advance(ring, br, count, count);
13361405}
1337140613381407#ifndef LIBURING_INTERNAL
13391339-static inline struct io_uring_sqe *io_uring_get_sqe(struct io_uring *ring)
14081408+IOURINGINLINE struct io_uring_sqe *io_uring_get_sqe(struct io_uring *ring)
13401409{
13411410 return _io_uring_get_sqe(ring);
13421411}
···13471416ssize_t io_uring_mlock_size(unsigned entries, unsigned flags);
13481417ssize_t io_uring_mlock_size_params(unsigned entries, struct io_uring_params *p);
1349141814191419+/*
14201420+ * Versioning information for liburing.
14211421+ *
14221422+ * Use IO_URING_CHECK_VERSION() for compile time checks including from
14231423+ * preprocessor directives.
14241424+ *
14251425+ * Use io_uring_check_version() for runtime checks of the version of
14261426+ * liburing that was loaded by the dynamic linker.
14271427+ */
14281428+int io_uring_major_version(void);
14291429+int io_uring_minor_version(void);
14301430+bool io_uring_check_version(int major, int minor);
14311431+14321432+#define IO_URING_CHECK_VERSION(major,minor) \
14331433+ (major > IO_URING_VERSION_MAJOR || \
14341434+ (major == IO_URING_VERSION_MAJOR && \
14351435+ minor >= IO_URING_VERSION_MINOR))
14361436+13501437#ifdef __cplusplus
13511438}
14391439+#endif
14401440+14411441+#ifdef IOURINGINLINE
14421442+#undef IOURINGINLINE
13521443#endif
1353144413541445#endif
+49-21
vendor/liburing/src/include/liburing/io_uring.h
···1212#include <linux/types.h>
1313/*
1414 * this file is shared with liburing and that has to autodetect
1515- * if linux/time_types.h is available
1515+ * if linux/time_types.h is available or not, it can
1616+ * define UAPI_LINUX_IO_URING_H_SKIP_LINUX_TIME_TYPES_H
1717+ * if linux/time_types.h is not available
1618 */
1717-#ifdef __KERNEL__
1818-#define HAVE_LINUX_TIME_TYPES_H 1
1919-#endif
2020-#ifdef HAVE_LINUX_TIME_TYPES_H
1919+#ifndef UAPI_LINUX_IO_URING_H_SKIP_LINUX_TIME_TYPES_H
2120#include <linux/time_types.h>
2221#endif
2322···231230232231/*
233232 * sqe->uring_cmd_flags
234234- * IORING_URING_CMD_FIXED use registered buffer; pass thig flag
233233+ * IORING_URING_CMD_FIXED use registered buffer; pass this flag
235234 * along with setting sqe->buf_index.
236235 */
237236#define IORING_URING_CMD_FIXED (1U << 0)
···251250#define IORING_TIMEOUT_REALTIME (1U << 3)
252251#define IORING_LINK_TIMEOUT_UPDATE (1U << 4)
253252#define IORING_TIMEOUT_ETIME_SUCCESS (1U << 5)
253253+#define IORING_TIMEOUT_MULTISHOT (1U << 6)
254254#define IORING_TIMEOUT_CLOCK_MASK (IORING_TIMEOUT_BOOTTIME | IORING_TIMEOUT_REALTIME)
255255#define IORING_TIMEOUT_UPDATE_MASK (IORING_TIMEOUT_UPDATE | IORING_LINK_TIMEOUT_UPDATE)
256256/*
···305305 *
306306 * IORING_RECVSEND_FIXED_BUF Use registered buffers, the index is stored in
307307 * the buf_index field.
308308+ *
309309+ * IORING_SEND_ZC_REPORT_USAGE
310310+ * If set, SEND[MSG]_ZC should report
311311+ * the zerocopy usage in cqe.res
312312+ * for the IORING_CQE_F_NOTIF cqe.
313313+ * 0 is reported if zerocopy was actually possible.
314314+ * IORING_NOTIF_USAGE_ZC_COPIED if data was copied
315315+ * (at least partially).
308316 */
309317#define IORING_RECVSEND_POLL_FIRST (1U << 0)
310318#define IORING_RECV_MULTISHOT (1U << 1)
311319#define IORING_RECVSEND_FIXED_BUF (1U << 2)
320320+#define IORING_SEND_ZC_REPORT_USAGE (1U << 3)
321321+322322+/*
323323+ * cqe.res for IORING_CQE_F_NOTIF if
324324+ * IORING_SEND_ZC_REPORT_USAGE was requested
325325+ *
326326+ * It should be treated as a flag, all other
327327+ * bits of cqe.res should be treated as reserved!
328328+ */
329329+#define IORING_NOTIF_USAGE_ZC_COPIED (1U << 31)
312330313331/*
314332 * accept flags stored in sqe->ioprio
···330348 * applicable for IORING_MSG_DATA, obviously.
331349 */
332350#define IORING_MSG_RING_CQE_SKIP (1U << 0)
351351+/* Pass through the flags from sqe->file_index to cqe->flags */
352352+#define IORING_MSG_RING_FLAGS_PASS (1U << 1)
333353334354/*
335355 * IO completion data structure (Completion Queue Entry)
···370390#define IORING_OFF_SQ_RING 0ULL
371391#define IORING_OFF_CQ_RING 0x8000000ULL
372392#define IORING_OFF_SQES 0x10000000ULL
393393+#define IORING_OFF_PBUF_RING 0x80000000ULL
394394+#define IORING_OFF_PBUF_SHIFT 16
395395+#define IORING_OFF_MMAP_MASK 0xf8000000ULL
373396374397/*
375398 * Filled with the offset for mmap(2)
···453476#define IORING_FEAT_RSRC_TAGS (1U << 10)
454477#define IORING_FEAT_CQE_SKIP (1U << 11)
455478#define IORING_FEAT_LINKED_FILE (1U << 12)
479479+#define IORING_FEAT_REG_REG_RING (1U << 13)
456480457481/*
458482 * io_uring_register(2) opcodes and arguments
···500524 IORING_REGISTER_FILE_ALLOC_RANGE = 25,
501525502526 /* this goes last */
503503- IORING_REGISTER_LAST
527527+ IORING_REGISTER_LAST,
528528+529529+ /* flag added to the opcode to use a registered ring fd */
530530+ IORING_REGISTER_USE_REGISTERED_RING = 1U << 31
504531};
505532506533/* io-wq worker categories */
···545572 __u32 resv2;
546573};
547574548548-struct io_uring_notification_slot {
549549- __u64 tag;
550550- __u64 resv[3];
551551-};
552552-553553-struct io_uring_notification_register {
554554- __u32 nr_slots;
555555- __u32 resv;
556556- __u64 resv2;
557557- __u64 data;
558558- __u64 resv3;
559559-};
560560-561575/* Skip updating fd indexes set to this value in the fd table */
562576#define IORING_REGISTER_FILES_SKIP (-2)
563577···612626 };
613627};
614628629629+/*
630630+ * Flags for IORING_REGISTER_PBUF_RING.
631631+ *
632632+ * IOU_PBUF_RING_MMAP: If set, kernel will allocate the memory for the ring.
633633+ * The application must not set a ring_addr in struct
634634+ * io_uring_buf_reg, instead it must subsequently call
635635+ * mmap(2) with the offset set as:
636636+ * IORING_OFF_PBUF_RING | (bgid << IORING_OFF_PBUF_SHIFT)
637637+ * to get a virtual mapping for the ring.
638638+ */
639639+enum {
640640+ IOU_PBUF_RING_MMAP = 1,
641641+};
642642+615643/* argument for IORING_(UN)REGISTER_PBUF_RING */
616644struct io_uring_buf_reg {
617645 __u64 ring_addr;
618646 __u32 ring_entries;
619647 __u16 bgid;
620620- __u16 pad;
648648+ __u16 flags;
621649 __u64 resv[3];
622650};
623651
···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/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+ * Test that we don't recursively generate completion events if an io_uring
44+ * fd is added to an epoll context, and the ring itself polls for events on
55+ * the epollfd. Older kernels will stop on overflow, newer kernels will
66+ * detect this earlier and abort correctly.
77+ */
88+#include <stdio.h>
99+#include <unistd.h>
1010+#include <stdlib.h>
1111+#include <sys/epoll.h>
1212+#include <sys/types.h>
1313+#include <poll.h>
1414+#include "liburing.h"
1515+#include "helpers.h"
1616+1717+int main(int argc, char *argv[])
1818+{
1919+ struct io_uring ring;
2020+ struct io_uring_sqe *sqe;
2121+ struct io_uring_cqe *cqe;
2222+ struct epoll_event ev = { };
2323+ int epollfd, ret, i;
2424+2525+ if (argc > 1)
2626+ return T_EXIT_SKIP;
2727+2828+ ret = io_uring_queue_init(8, &ring, 0);
2929+ if (ret) {
3030+ fprintf(stderr, "Ring init failed: %d\n", ret);
3131+ return T_EXIT_FAIL;
3232+ }
3333+3434+ epollfd = epoll_create1(0);
3535+ if (epollfd < 0) {
3636+ perror("epoll_create");
3737+ return T_EXIT_FAIL;
3838+ }
3939+4040+ ev.events = EPOLLIN;
4141+ ev.data.fd = ring.ring_fd;
4242+ ret = epoll_ctl(epollfd, EPOLL_CTL_ADD, ring.ring_fd, &ev);
4343+ if (ret < 0) {
4444+ perror("epoll_ctl");
4545+ return T_EXIT_FAIL;
4646+ }
4747+4848+ sqe = io_uring_get_sqe(&ring);
4949+ io_uring_prep_poll_multishot(sqe, epollfd, POLLIN);
5050+ sqe->user_data = 1;
5151+ io_uring_submit(&ring);
5252+5353+ sqe = io_uring_get_sqe(&ring);
5454+ sqe->user_data = 2;
5555+ io_uring_prep_nop(sqe);
5656+ io_uring_submit(&ring);
5757+5858+ for (i = 0; i < 2; i++) {
5959+ ret = io_uring_wait_cqe(&ring, &cqe);
6060+ if (ret) {
6161+ fprintf(stderr, "wait_cqe ret = %d\n", ret);
6262+ break;
6363+ }
6464+ io_uring_cqe_seen(&ring, cqe);
6565+ }
6666+6767+ ret = io_uring_peek_cqe(&ring, &cqe);
6868+ if (!ret) {
6969+ fprintf(stderr, "Generated too many events\n");
7070+ return T_EXIT_FAIL;
7171+ }
7272+7373+ return T_EXIT_PASS;
7474+}
+1-1
vendor/liburing/test/eventfd-ring.c
···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/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/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/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);
+192
vendor/liburing/test/msg-ring-flags.c
···11+/* SPDX-License-Identifier: MIT */
22+/*
33+ * Description: test ring messaging with flags command
44+ *
55+ */
66+#include <errno.h>
77+#include <stdio.h>
88+#include <unistd.h>
99+#include <stdlib.h>
1010+#include <string.h>
1111+#include <fcntl.h>
1212+#include <pthread.h>
1313+1414+#include "liburing.h"
1515+#include "helpers.h"
1616+1717+#define CUSTOM_FLAG 0x42
1818+#define USER_DATA 0x5aa5
1919+#define LEN 0x20
2020+#define ID 0x1
2121+2222+struct data {
2323+ pthread_barrier_t barrier;
2424+ int fd;
2525+};
2626+2727+static int recv_msg(struct io_uring *ring)
2828+{
2929+ struct io_uring_cqe *cqe;
3030+ int ret;
3131+3232+ ret = io_uring_wait_cqe(ring, &cqe);
3333+ if (ret) {
3434+ fprintf(stderr, "wait cqe %d\n", ret);
3535+ return T_EXIT_FAIL;
3636+ }
3737+ if (cqe->user_data != USER_DATA) {
3838+ fprintf(stderr, "user_data %llx\n", (long long) cqe->user_data);
3939+ return T_EXIT_FAIL;
4040+ }
4141+ if (cqe->res != LEN) {
4242+ fprintf(stderr, "len %x\n", cqe->res);
4343+ return T_EXIT_FAIL;
4444+ }
4545+ if (cqe->flags != CUSTOM_FLAG) {
4646+ fprintf(stderr, "flags %x\n", cqe->flags);
4747+ return T_EXIT_FAIL;
4848+ }
4949+5050+ return T_EXIT_PASS;
5151+}
5252+5353+static int send_msg(struct io_uring *ring, int target_fd)
5454+{
5555+ struct io_uring_cqe *cqe;
5656+ struct io_uring_sqe *sqe;
5757+ int ret;
5858+5959+ sqe = io_uring_get_sqe(ring);
6060+ if (!sqe) {
6161+ fprintf(stderr, "get sqe failed\n");
6262+ return T_EXIT_FAIL;
6363+ }
6464+6565+ io_uring_prep_msg_ring_cqe_flags(sqe, target_fd, LEN, USER_DATA,
6666+ 0, CUSTOM_FLAG);
6767+ sqe->user_data = ID;
6868+6969+ ret = io_uring_submit(ring);
7070+ if (ret <= 0) {
7171+ if (ret == -EINVAL)
7272+ return T_EXIT_SKIP;
7373+7474+ fprintf(stderr, "sqe submit failed: %d\n", ret);
7575+ return T_EXIT_FAIL;
7676+ }
7777+7878+ ret = io_uring_wait_cqe(ring, &cqe);
7979+ if (ret < 0) {
8080+ fprintf(stderr, "wait completion %d\n", ret);
8181+ return T_EXIT_FAIL;
8282+ }
8383+ if (cqe->res != 0) {
8484+ if (cqe->res == -EINVAL)
8585+ return T_EXIT_SKIP;
8686+ fprintf(stderr, "cqe res %d\n", cqe->res);
8787+ return T_EXIT_FAIL;
8888+ }
8989+ if (cqe->user_data != ID) {
9090+ fprintf(stderr, "user_data %llx\n", (long long) cqe->user_data);
9191+ return T_EXIT_FAIL;
9292+ }
9393+9494+ io_uring_cqe_seen(ring, cqe);
9595+ return T_EXIT_PASS;
9696+}
9797+9898+static void *thread_fn(void *data)
9999+{
100100+ struct data *d = data;
101101+ struct io_uring ring;
102102+ int ret;
103103+104104+ ret = io_uring_queue_init(2, &ring, IORING_SETUP_DEFER_TASKRUN | IORING_SETUP_SINGLE_ISSUER);
105105+ if (ret) {
106106+ fprintf(stderr, "ring init failed %d\n", ret);
107107+ pthread_barrier_wait(&d->barrier);
108108+ return NULL;
109109+ }
110110+111111+ d->fd = ring.ring_fd;
112112+ pthread_barrier_wait(&d->barrier);
113113+114114+ if (recv_msg(&ring))
115115+ return (void *) 1;
116116+117117+ return NULL;
118118+}
119119+120120+int main(int argc, char *argv[])
121121+{
122122+ struct io_uring ring, ring2;
123123+ pthread_t thread;
124124+ struct data d;
125125+ void *ret2;
126126+ int ret, i;
127127+128128+ if (argc > 1)
129129+ return T_EXIT_SKIP;
130130+131131+ ret = io_uring_queue_init(2, &ring, 0);
132132+ if (ret) {
133133+ fprintf(stderr, "io_uring_queue_init failed for ring1: %d\n", ret);
134134+ return T_EXIT_FAIL;
135135+ }
136136+137137+ ret = io_uring_queue_init(2, &ring2, 0);
138138+ if (ret) {
139139+ fprintf(stderr, "io_uring_queue_init failed for ring2: %d\n", ret);
140140+ return T_EXIT_FAIL;
141141+ }
142142+143143+ ret = send_msg(&ring, ring2.ring_fd);
144144+ if (ret) {
145145+ if (ret != T_EXIT_SKIP)
146146+ fprintf(stderr, "send_msg failed: %d\n", ret);
147147+ return ret;
148148+ }
149149+150150+ ret = recv_msg(&ring2);
151151+ if (ret) {
152152+ fprintf(stderr, "recv_msg failed: %d\n", ret);
153153+ return ret;
154154+ }
155155+156156+ for (i = 0; i < 8; i++) {
157157+ ret = send_msg(&ring, ring2.ring_fd);
158158+ if (ret) {
159159+ if (ret != T_EXIT_SKIP)
160160+ fprintf(stderr, "send_msg failed: %d\n", ret);
161161+ return ret;
162162+ }
163163+ }
164164+165165+ for (i = 0; i < 8; i++) {
166166+ ret = recv_msg(&ring2);
167167+ if (ret) {
168168+ fprintf(stderr, "recv_msg failed: %d\n", ret);
169169+ return ret;
170170+ }
171171+ }
172172+173173+ pthread_barrier_init(&d.barrier, NULL, 2);
174174+ d.fd = -1;
175175+ pthread_create(&thread, NULL, thread_fn, &d);
176176+ pthread_barrier_wait(&d.barrier);
177177+ if (d.fd == -1)
178178+ return T_EXIT_FAIL;
179179+180180+ ret = send_msg(&ring, d.fd);
181181+ if (ret) {
182182+ fprintf(stderr, "send msg failed: %d\n", ret);
183183+ return ret;
184184+ }
185185+ pthread_join(thread, &ret2);
186186+ if (ret2) {
187187+ fprintf(stderr, "Remote test failed\n");
188188+ return T_EXIT_FAIL;
189189+ }
190190+191191+ return T_EXIT_PASS;
192192+}
+159
vendor/liburing/test/msg-ring-overflow.c
···11+/* SPDX-License-Identifier: MIT */
22+/*
33+ * Description: test ring messaging command
44+ *
55+ */
66+#include <errno.h>
77+#include <stdio.h>
88+#include <unistd.h>
99+#include <stdlib.h>
1010+#include <string.h>
1111+#include <fcntl.h>
1212+1313+#include "liburing.h"
1414+#include "helpers.h"
1515+1616+static int no_msg;
1717+1818+static int test(struct io_uring *ring, unsigned dst_flags)
1919+{
2020+ struct io_uring_params p = { };
2121+ struct io_uring_cqe *cqe;
2222+ struct io_uring_sqe *sqe;
2323+ struct io_uring dst;
2424+ int ret, i, err_ret = T_EXIT_FAIL;
2525+2626+ p.flags = dst_flags | IORING_SETUP_CQSIZE;
2727+ p.cq_entries = 4;
2828+ ret = io_uring_queue_init_params(4, &dst, &p);
2929+ if (ret) {
3030+ fprintf(stderr, "Destination ring create failed %d\n", ret);
3131+ return T_EXIT_FAIL;
3232+ }
3333+3434+ for (i = 0; i < 8; i++) {
3535+ sqe = io_uring_get_sqe(ring);
3636+ if (!sqe) {
3737+ fprintf(stderr, "get sqe failed\n");
3838+ goto err;
3939+ }
4040+4141+ io_uring_prep_msg_ring(sqe, dst.ring_fd, 0x10, 0x1234, 0);
4242+ sqe->user_data = i + 1;
4343+ }
4444+4545+ ret = io_uring_submit(ring);
4646+ if (ret != 8) {
4747+ /*
4848+ * Likely an old kernel that doesn't support the opcode,
4949+ * just skip the test.
5050+ */
5151+ if (ret == 1) {
5252+ err_ret = T_EXIT_SKIP;
5353+ no_msg = 1;
5454+ goto err;
5555+ }
5656+ fprintf(stderr, "sqe submit failed: %d\n", ret);
5757+ goto err;
5858+ }
5959+6060+ for (i = 0; i < 8; i++) {
6161+ ret = io_uring_wait_cqe(ring, &cqe);
6262+ if (ret < 0) {
6363+ fprintf(stderr, "wait completion %d\n", ret);
6464+ goto err;
6565+ }
6666+ switch (cqe->user_data) {
6767+ case 1 ... 8:
6868+ if (cqe->res == -EINVAL || cqe->res == -EOPNOTSUPP) {
6969+ no_msg = 1;
7070+ goto out;
7171+ }
7272+ if (cqe->res != 0) {
7373+ fprintf(stderr, "cqe res %d\n", cqe->res);
7474+ goto err;
7575+ }
7676+ break;
7777+ case 0x1234:
7878+ if (cqe->res != 0x10) {
7979+ fprintf(stderr, "invalid len %x\n", cqe->res);
8080+ goto err;
8181+ }
8282+ break;
8383+ default:
8484+ fprintf(stderr, "Invalid user_data\n");
8585+ goto err;
8686+ }
8787+ io_uring_cqe_seen(ring, cqe);
8888+ }
8989+9090+ for (i = 0; i < 8; i++) {
9191+ ret = io_uring_wait_cqe(&dst, &cqe);
9292+ if (ret < 0) {
9393+ fprintf(stderr, "wait completion %d\n", ret);
9494+ goto err;
9595+ }
9696+ switch (cqe->user_data) {
9797+ case 0x1234:
9898+ if (cqe->res != 0x10) {
9999+ fprintf(stderr, "invalid len %x\n", cqe->res);
100100+ goto err;
101101+ }
102102+ break;
103103+ default:
104104+ fprintf(stderr, "Invalid user_data\n");
105105+ goto err;
106106+ }
107107+ io_uring_cqe_seen(&dst, cqe);
108108+ }
109109+110110+out:
111111+ io_uring_queue_exit(&dst);
112112+ return no_msg ? T_EXIT_SKIP : T_EXIT_PASS;
113113+err:
114114+ io_uring_queue_exit(&dst);
115115+ return err_ret;
116116+}
117117+118118+int main(int argc, char *argv[])
119119+{
120120+ struct io_uring src;
121121+ int ret;
122122+123123+ if (argc > 1)
124124+ return T_EXIT_SKIP;
125125+126126+ ret = io_uring_queue_init(8, &src, 0);
127127+ if (ret) {
128128+ fprintf(stderr, "ring setup failed: %d\n", ret);
129129+ return T_EXIT_FAIL;
130130+ }
131131+132132+ ret = test(&src, 0);
133133+ if (ret && !no_msg) {
134134+ fprintf(stderr, "test failed\n");
135135+ return ret;
136136+ }
137137+ if (no_msg)
138138+ return T_EXIT_SKIP;
139139+140140+ ret = test(&src, IORING_SETUP_IOPOLL);
141141+ if (ret) {
142142+ fprintf(stderr, "test IOPOLL failed\n");
143143+ return ret;
144144+ }
145145+146146+ ret = test(&src, IORING_SETUP_DEFER_TASKRUN | IORING_SETUP_SINGLE_ISSUER);
147147+ if (ret) {
148148+ fprintf(stderr, "test defer failed\n");
149149+ return ret;
150150+ }
151151+152152+ ret = test(&src, IORING_SETUP_DEFER_TASKRUN | IORING_SETUP_SINGLE_ISSUER | IORING_SETUP_IOPOLL);
153153+ if (ret) {
154154+ fprintf(stderr, "test defer IOPOLL failed\n");
155155+ return ret;
156156+ }
157157+158158+ return T_EXIT_PASS;
159159+}
···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>
+7-9
vendor/liburing/test/single-issuer.c
···55#include <stdlib.h>
66#include <string.h>
77#include <fcntl.h>
88-#include <error.h>
98#include <sys/types.h>
109#include <sys/wait.h>
1110···5655 return ret;
57565857 if (ret != 1)
5959- error(1, ret, "submit %i", ret);
5858+ t_error(1, ret, "submit %i", ret);
6059 ret = io_uring_wait_cqe(ring, &cqe);
6160 if (ret)
6262- error(1, ret, "wait fail %i", ret);
6161+ t_error(1, ret, "wait fail %i", ret);
63626463 if (cqe->res || cqe->user_data != 42)
6565- error(1, ret, "invalid cqe");
6464+ t_error(1, ret, "invalid cqe");
66656766 io_uring_cqe_seen(ring, cqe);
6867 return 0;
···78777978 ret = io_uring_queue_init(8, &ring, IORING_SETUP_SINGLE_ISSUER);
8079 if (ret == -EINVAL) {
8181- fprintf(stderr, "SETUP_SINGLE_ISSUER is not supported, skip\n");
8280 return T_EXIT_SKIP;
8381 } else if (ret) {
8482 fprintf(stderr, "io_uring_queue_init() failed %i\n", ret);
···106104 ret = io_uring_queue_init(8, &ring, IORING_SETUP_SINGLE_ISSUER |
107105 IORING_SETUP_R_DISABLED);
108106 if (ret)
109109- error(1, ret, "ring init (2) %i", ret);
107107+ t_error(1, ret, "ring init (2) %i", ret);
110108111109 if (!fork_t()) {
112110 io_uring_enable_rings(&ring);
···122120 ret = io_uring_queue_init(8, &ring, IORING_SETUP_SINGLE_ISSUER |
123121 IORING_SETUP_R_DISABLED);
124122 if (ret)
125125- error(1, ret, "ring init (3) %i", ret);
123123+ t_error(1, ret, "ring init (3) %i", ret);
126124127125 io_uring_enable_rings(&ring);
128126 if (!fork_t()) {
···137135 /* test that anyone can submit to a SQPOLL|SINGLE_ISSUER ring */
138136 ret = io_uring_queue_init(8, &ring, IORING_SETUP_SINGLE_ISSUER|IORING_SETUP_SQPOLL);
139137 if (ret)
140140- error(1, ret, "ring init (4) %i", ret);
138138+ t_error(1, ret, "ring init (4) %i", ret);
141139142140 ret = try_submit(&ring);
143141 if (ret) {
···157155 /* test that IORING_ENTER_REGISTERED_RING doesn't break anything */
158156 ret = io_uring_queue_init(8, &ring, IORING_SETUP_SINGLE_ISSUER);
159157 if (ret)
160160- error(1, ret, "ring init (5) %i", ret);
158158+ t_error(1, ret, "ring init (5) %i", ret);
161159162160 if (!fork_t()) {
163161 ret = try_submit(&ring);
+3-4
vendor/liburing/test/skip-cqe.c
···88#include <assert.h>
991010#include "liburing.h"
1111+#include "helpers.h"
11121213#define LINK_SIZE 6
1314#define TIMEOUT_USER_DATA (-1)
···323324 return 1;
324325 }
325326326326- if (!(ring.features & IORING_FEAT_CQE_SKIP)) {
327327- printf("IOSQE_CQE_SKIP_SUCCESS is not supported, skip\n");
328328- return 0;
329329- }
327327+ if (!(ring.features & IORING_FEAT_CQE_SKIP))
328328+ return T_EXIT_SKIP;
330329331330 for (i = 0; i < 4; i++) {
332331 bool skip_last = i & 1;
···1212#define TIMEOUT_MSEC 200
1313#define TIMEOUT_SEC 10
14141515-int thread_ret0, thread_ret1;
1616-int cnt = 0;
1717-pthread_mutex_t mutex;
1515+static int thread_ret0, thread_ret1;
1616+static int cnt = 0;
1717+static pthread_mutex_t mutex;
18181919static void msec_to_ts(struct __kernel_timespec *ts, unsigned int msec)
2020{
···111111 return 0;
112112}
113113114114-int __reap_thread_fn(void *data) {
114114+static int __reap_thread_fn(void *data)
115115+{
115116 struct io_uring *ring = (struct io_uring *)data;
116117 struct io_uring_cqe *cqe;
117118 struct __kernel_timespec ts;
···123124 return io_uring_wait_cqe_timeout(ring, &cqe, &ts);
124125}
125126126126-void *reap_thread_fn0(void *data) {
127127+static void *reap_thread_fn0(void *data)
128128+{
127129 thread_ret0 = __reap_thread_fn(data);
128130 return NULL;
129131}
130132131131-void *reap_thread_fn1(void *data) {
133133+static void *reap_thread_fn1(void *data)
134134+{
132135 thread_ret1 = __reap_thread_fn(data);
133136 return NULL;
134137}
···137140 * This is to test issuing a sqe in main thread and reaping it in two child-thread
138141 * at the same time. To see if timeout feature works or not.
139142 */
140140-int test_multi_threads_timeout() {
143143+static int test_multi_threads_timeout(void)
144144+{
141145 struct io_uring ring;
142146 int ret;
143147 bool both_wait = false;
-204
vendor/liburing/test/timeout-overflow.c
···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/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/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/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+}