···11+liburing-2.3 release
22+33+- Support non-libc build for aarch64.
44+- Add io_uring_{enter,enter2,register,setup} syscall functions.
55+- Add sync cancel interface, io_uring_register_sync_cancel().
66+- Fix return value of io_uring_submit_and_wait_timeout() to match the
77+ man page.
88+- Improvements to the regression tests
99+- Add support and test case for passthrough IO
1010+- Add recv and recvmsg multishot helpers and support
1111+- Add documentation and support for IORING_SETUP_DEFER_TASKRUN
1212+- Fix potential missing kernel entry with IORING_SETUP_IOPOLL
1313+- Add support and documentation for zero-copy network transmit
1414+- Various optimizations
1515+- Many cleanups
1616+- Many man page additions and updates
1717+118liburing-2.2 release
219320- Support non-libc builds.
···623- Add support for multishot accept.
724- io_uring_register_files() will set RLIMIT_NOFILE if necessary.
825- Add support for registered ring fds, io_uring_register_ring_fd(),
99- reducingthe overhead of an io_uring_enter() system call.
2626+ reducing the overhead of an io_uring_enter() system call.
1027- Add support for the message ring opcode.
1128- Add support for newer request cancelation features.
1229- Add support for IORING_SETUP_COOP_TASKRUN, which can help reduce the
+12-12
vendor/liburing/configure
···368368print_config "has_ucontext" "$has_ucontext"
369369370370##########################################
371371-# check for memfd_create(2)
372372-has_memfd_create="no"
371371+# Check NVME_URING_CMD support
372372+nvme_uring_cmd="no"
373373cat > $TMPC << EOF
374374-#include <sys/mman.h>
375375-int main(int argc, char **argv)
374374+#include <linux/nvme_ioctl.h>
375375+int main(void)
376376{
377377- int memfd = memfd_create("test", 0);
378378- return 0;
377377+ struct nvme_uring_cmd *cmd;
378378+379379+ return sizeof(struct nvme_uring_cmd);
379380}
380381EOF
381381-if compile_prog "-Werror=implicit-function-declaration" "" "has_memfd_create"; then
382382- has_memfd_create="yes"
382382+if compile_prog "" "" "nvme uring cmd"; then
383383+ nvme_uring_cmd="yes"
383384fi
384384-print_config "has_memfd_create" "$has_memfd_create"
385385-385385+print_config "NVMe uring command support" "$nvme_uring_cmd"
386386387387#############################################################################
388388if test "$liburing_nolibc" = "yes"; then
···419419if test "$array_bounds" = "yes"; then
420420 output_sym "CONFIG_HAVE_ARRAY_BOUNDS"
421421fi
422422-if test "$has_memfd_create" = "yes"; then
423423- output_sym "CONFIG_HAVE_MEMFD_CREATE"
422422+if test "$nvme_uring_cmd" = "yes"; then
423423+ output_sym "CONFIG_HAVE_NVME_URING"
424424fi
425425426426echo "CC=$cc" >> $config_host_mak
···11Name: liburing
22-Version: 2.2
22+Version: 2.3
33Release: 1%{?dist}
44Summary: Linux-native io_uring I/O access library
55License: (GPLv2 with exceptions and LGPLv2+) or MIT
+29-3
vendor/liburing/man/io_uring.7
···22.\" SPDX-License-Identifier: LGPL-2.0-or-later
33.\"
4455-.TH IO_URING 7 2020-07-26 "Linux" "Linux Programmer's Manual"
55+.TH io_uring 7 2020-07-26 "Linux" "Linux Programmer's Manual"
66.SH NAME
77io_uring \- Asynchronous I/O facility
88.SH SYNOPSIS
···405405is the result from the system call that was performed as part of the
406406submission;
407407its return value.
408408+408409The
409410.I flags
410410-field could carry request-specific metadata in the future,
411411-but is currently unused.
411411+field carries request-specific information. As of the 6.0 kernel, the following
412412+flags are defined:
413413+414414+.TP
415415+.B IORING_CQE_F_BUFFER
416416+If set, the upper 16 bits of the flags field carries the buffer ID that was
417417+chosen for this request. The request must have been issued with
418418+.B IOSQE_BUFFER_SELECT
419419+set, and used with a request type that supports buffer selection. Additionally,
420420+buffers must have been provided upfront either via the
421421+.B IORING_OP_PROVIDE_BUFFERS
422422+or the
423423+.B IORING_REGISTER_PBUF_RING
424424+methods.
425425+.TP
426426+.B IORING_CQE_F_MORE
427427+If set, the application should expect more completions from the request. This
428428+is used for requests that can generate multiple completions, such as multi-shot
429429+requests, receive, or accept.
430430+.TP
431431+.B IORING_CQE_F_SOCK_NONEMPTY
432432+If set, upon receiving the data from the socket in the current request, the
433433+socket still had data left on completion of this request.
434434+.TP
435435+.B IORING_CQE_F_NOTIF
436436+Set for notification CQEs, as seen with the zero-copy networking send and
437437+receive support.
412438.PP
413439The general sequence to read completion events off the completion queue is
414440as follows:
···11+.\" Copyright (C) 2022 Dylan Yudaken <dylany@fb.com>
22+.\"
33+.\" SPDX-License-Identifier: LGPL-2.0-or-later
44+.\"
55+.TH io_uring_cq_has_overflow 3 "September 5, 2022" "liburing-2.3" "liburing Manual"
66+.SH NAME
77+io_uring_cq_has_overflow \- returns if there are overflow entries waiting to move to the CQ ring
88+.SH SYNOPSIS
99+.nf
1010+.B #include <liburing.h>
1111+.PP
1212+.BI "bool io_uring_cq_has_overflow(const struct io_uring *" ring ");"
1313+.fi
1414+.SH DESCRIPTION
1515+.PP
1616+The
1717+.BR io_uring_cq_has_overflow (3)
1818+function informs the application if CQ entries have overflowed and are waiting to be flushed to
1919+the CQ ring. For example using
2020+.BR io_uring_get_events (3)
2121+.
2222+.SH RETURN VALUE
2323+True if there are CQ entries waiting to be flushed to the CQ ring.
2424+.SH SEE ALSO
2525+.BR io_uring_get_events (3)
+2-2
vendor/liburing/man/io_uring_cq_ready.3
···22.\"
33.\" SPDX-License-Identifier: LGPL-2.0-or-later
44.\"
55-.TH io_uring_cq_ready "January 25, 2022" "liburing-2.1" "liburing Manual"
55+.TH io_uring_cq_ready 3 "January 25, 2022" "liburing-2.1" "liburing Manual"
66.SH NAME
77io_uring_cq_ready \- returns number of unconsumed ready entries in the CQ ring
88.SH SYNOPSIS
···1515.PP
1616The
1717.BR io_uring_cq_ready (3)
1818-function retuns the number of unconsumed entries that are ready belonging to the
1818+function returns the number of unconsumed entries that are ready belonging to the
1919.I ring
2020param.
2121
+231-23
vendor/liburing/man/io_uring_enter.2
···33.\"
44.\" SPDX-License-Identifier: LGPL-2.0-or-later
55.\"
66-.TH IO_URING_ENTER 2 2019-01-22 "Linux" "Linux Programmer's Manual"
66+.TH io_uring_enter 2 2019-01-22 "Linux" "Linux Programmer's Manual"
77.SH NAME
88io_uring_enter \- initiate and/or complete asynchronous I/O
99.SH SYNOPSIS
1010.nf
1111-.BR "#include <linux/io_uring.h>"
1111+.BR "#include <liburing.h>"
1212.PP
1313.BI "int io_uring_enter(unsigned int " fd ", unsigned int " to_submit ,
1414.BI " unsigned int " min_complete ", unsigned int " flags ,
1515.BI " sigset_t *" sig );
1616+.PP
1717+.BI "int io_uring_enter2(unsigned int " fd ", unsigned int " to_submit ,
1818+.BI " unsigned int " min_complete ", unsigned int " flags ,
1919+.BI " sigset_t *" sig ", size_t " sz );
1620.fi
1721.PP
1822.SH DESCRIPTION
1923.PP
2020-.BR io_uring_enter ()
2424+.BR io_uring_enter (2)
2125is used to initiate and complete I/O using the shared submission and
2226completion queues setup by a call to
2327.BR io_uring_setup (2).
2428A single call can both submit new I/O and wait for completions of I/O
2529initiated by this call or previous calls to
2626-.BR io_uring_enter ().
3030+.BR io_uring_enter (2).
27312832.I fd
2933is the file descriptor returned by
···3438is a bitmask of the following values:
3539.TP
3640.B IORING_ENTER_GETEVENTS
3737-If this flag is set, then the system call will wait for the specificied
4141+If this flag is set, then the system call will wait for the specified
3842number of events in
3943.I min_complete
4044before returning. This flag can be set along with
···6165the following:
62666367.nf
6464-.BI "int io_uring_enter(unsigned int " fd ", unsigned int " to_submit ,
6565-.BI " unsigned int " min_complete ", unsigned int " flags ,
6666-.BI " const void *" arg ", size_t " argsz );
6868+.BI "int io_uring_enter2(unsigned int " fd ", unsigned int " to_submit ,
6969+.BI " unsigned int " min_complete ", unsigned int " flags ,
7070+.BI " const void *" arg ", size_t " argsz );
6771.fi
68726969-which is behaves just like the original definition by default. However, if
7373+which behaves just like the original definition by default. However, if
7074.B IORING_ENTER_EXT_ARG
7175is set, then instead of a
7276.I sigset_t
···137141if
138142.I sig
139143is not NULL,
140140-.BR io_uring_enter ()
144144+.BR io_uring_enter (2)
141145first replaces the current signal mask by the one pointed to by
142146.IR sig ,
143147then waits for events to become available in the completion queue, and
144148then restores the original signal mask. The following
145145-.BR io_uring_enter ()
149149+.BR io_uring_enter (2)
146150call:
147151.PP
148152.in +4n
···249253.BR pwritev2 (2).
250254If the file is not seekable,
251255.I off
252252-must be set to zero.
256256+must be set to zero or -1.
253257254258.TP
255259.B IORING_OP_READ_FIXED
···390394.BR sendmsg (2)
391395for the general description of the related system call. Available since 5.3.
392396397397+This command also supports the following modifiers in
398398+.I ioprio:
399399+400400+.PP
401401+.in +12
402402+.B IORING_RECVSEND_POLL_FIRST
403403+If set, io_uring will assume the socket is currently full and attempting to
404404+send data will be unsuccessful. For this case, io_uring will arm internal
405405+poll and trigger a send of the data when there is enough space available.
406406+This initial send attempt can be wasteful for the case where the socket
407407+is expected to be full, setting this flag will bypass the initial send
408408+attempt and go straight to arming poll. If poll does indicate that data can
409409+be sent, the operation will proceed.
410410+.EE
411411+.in
412412+.PP
413413+393414.TP
394415.B IORING_OP_RECVMSG
395416Works just like IORING_OP_SENDMSG, except for
396417.BR recvmsg(2)
397418instead. See the description of IORING_OP_SENDMSG. Available since 5.3.
398419420420+This command also supports the following modifiers in
421421+.I ioprio:
422422+423423+.PP
424424+.in +12
425425+.B IORING_RECVSEND_POLL_FIRST
426426+If set, io_uring will assume the socket is currently empty and attempting to
427427+receive data will be unsuccessful. For this case, io_uring will arm internal
428428+poll and trigger a receive of the data when the socket has data to be read.
429429+This initial receive attempt can be wasteful for the case where the socket
430430+is expected to be empty, setting this flag will bypass the initial receive
431431+attempt and go straight to arming poll. If poll does indicate that data is
432432+ready to be received, the operation will proceed.
433433+.EE
434434+.in
435435+.PP
436436+399437.TP
400438.B IORING_OP_SEND
401439Issue the equivalent of a
···412450.BR send(2)
413451for the general description of the related system call. Available since 5.6.
414452453453+This command also supports the following modifiers in
454454+.I ioprio:
455455+456456+.PP
457457+.in +12
458458+.B IORING_RECVSEND_POLL_FIRST
459459+If set, io_uring will assume the socket is currently full and attempting to
460460+send data will be unsuccessful. For this case, io_uring will arm internal
461461+poll and trigger a send of the data when there is enough space available.
462462+This initial send attempt can be wasteful for the case where the socket
463463+is expected to be full, setting this flag will bypass the initial send
464464+attempt and go straight to arming poll. If poll does indicate that data can
465465+be sent, the operation will proceed.
466466+.EE
467467+.in
468468+.PP
469469+415470.TP
416471.B IORING_OP_RECV
417472Works just like IORING_OP_SEND, except for
418473.BR recv(2)
419474instead. See the description of IORING_OP_SEND. Available since 5.6.
475475+476476+This command also supports the following modifiers in
477477+.I ioprio:
478478+479479+.PP
480480+.in +12
481481+.B IORING_RECVSEND_POLL_FIRST
482482+If set, io_uring will assume the socket is currently empty and attempting to
483483+receive data will be unsuccessful. For this case, io_uring will arm internal
484484+poll and trigger a receive of the data when the socket has data to be read.
485485+This initial receive attempt can be wasteful for the case where the socket
486486+is expected to be empty, setting this flag will bypass the initial receive
487487+attempt and go straight to arming poll. If poll does indicate that data is
488488+ready to be received, the operation will proceed.
489489+.EE
490490+.in
491491+.PP
420492421493.TP
422494.B IORING_OP_TIMEOUT
···460532461533.B IORING_TIMEOUT_REALTIME
462534If set, then the clocksource used is
463463-.I CLOCK_BOOTTIME
535535+.I CLOCK_REALTIME
464536instead of
465537.I CLOCK_MONOTONIC.
466538.EE
···785857.I fd
786858does not refer to a seekable file,
787859.I off
788788-must be set to zero. If
860860+must be set to zero or -1. If
789861.I offs
790862is set to
791863.B -1
···10521124field matching the
10531125.I off
10541126value being passed in. This request type can be used to either just wake or
10551055-interrupt anyone waiting for completions on the target ring, ot it can be used
11271127+interrupt anyone waiting for completions on the target ring, or it can be used
10561128to pass messages via the two fields. Available since 5.18.
1057112911301130+.TP
11311131+.B IORING_OP_SOCKET
11321132+Issue the equivalent of a
11331133+.BR socket(2)
11341134+system call.
11351135+.I fd
11361136+must contain the communication domain,
11371137+.I off
11381138+must contain the communication type,
11391139+.I len
11401140+must contain the protocol, and
11411141+.I rw_flags
11421142+is currently unused and must be set to zero. See also
11431143+.BR socket(2)
11441144+for the general description of the related system call. Available since 5.19.
11451145+11461146+If the
11471147+.I file_index
11481148+field is set to a positive number, the file won't be installed into the
11491149+normal file table as usual but will be placed into the fixed file table at index
11501150+.I file_index - 1.
11511151+In this case, instead of returning a file descriptor, the result will contain
11521152+either 0 on success or an error. If the index points to a valid empty slot, the
11531153+installation is guaranteed to not fail. If there is already a file in the slot,
11541154+it will be replaced, similar to
11551155+.B IORING_OP_FILES_UPDATE.
11561156+Please note that only io_uring has access to such files and no other syscall
11571157+can use them. See
11581158+.B IOSQE_FIXED_FILE
11591159+and
11601160+.B IORING_REGISTER_FILES.
11611161+11621162+Available since 5.19.
11631163+11641164+.TP
11651165+.B IORING_OP_SEND_ZC
11661166+Issue the zerocopy equivalent of a
11671167+.BR send(2)
11681168+system call. Similar to IORING_OP_SEND, but tries to avoid making intermediate
11691169+copies of data. Zerocopy execution is not guaranteed and may fall back to
11701170+copying. The request may also fail with
11711171+.B -EOPNOTSUPP ,
11721172+when a protocol doesn't support zerocopy, in which case users are recommended
11731173+to use copying sends instead.
11741174+11751175+The
11761176+.I flags
11771177+field of the first
11781178+.I "struct io_uring_cqe"
11791179+may likely contain
11801180+.B IORING_CQE_F_MORE ,
11811181+which means that there will be a second completion event / notification for
11821182+the request, with the
11831183+.I user_data
11841184+field set to the same value. The user must not modify the data buffer until the
11851185+notification is posted. The first cqe follows the usual rules and so its
11861186+.I res
11871187+field will contain the number of bytes sent or a negative error code. The
11881188+notification's
11891189+.I res
11901190+field will be set to zero and the
11911191+.I flags
11921192+field will contain
11931193+.B IORING_CQE_F_NOTIF .
11941194+The two step model is needed because the kernel may hold on to buffers for a
11951195+long time, e.g. waiting for a TCP ACK, and having a separate cqe for request
11961196+completions allows userspace to push more data without extra delays. Note,
11971197+notifications are only responsible for controlling the lifetime of the buffers,
11981198+and as such don't mean anything about whether the data has atually been sent
11991199+out or received by the other end. Even errored requests may generate a
12001200+notification, and the user must check for
12011201+.B IORING_CQE_F_MORE
12021202+rather than relying on the result.
12031203+12041204+.I fd
12051205+must be set to the socket file descriptor,
12061206+.I addr
12071207+must contain a pointer to the buffer,
12081208+.I len
12091209+denotes the length of the buffer to send, and
12101210+.I msg_flags
12111211+holds the flags associated with the system call. When
12121212+.I addr2
12131213+is non-zero it points to the address of the target with
12141214+.I addr_len
12151215+specifying its size, turning the request into a
12161216+.BR sendto(2)
12171217+system call equivalent.
12181218+12191219+Available since 6.0.
12201220+12211221+This command also supports the following modifiers in
12221222+.I ioprio:
12231223+12241224+.PP
12251225+.in +12
12261226+.B IORING_RECVSEND_POLL_FIRST
12271227+If set, io_uring will assume the socket is currently full and attempting to
12281228+send data will be unsuccessful. For this case, io_uring will arm internal
12291229+poll and trigger a send of the data when there is enough space available.
12301230+This initial send attempt can be wasteful for the case where the socket
12311231+is expected to be full, setting this flag will bypass the initial send
12321232+attempt and go straight to arming poll. If poll does indicate that data can
12331233+be sent, the operation will proceed.
12341234+12351235+.B IORING_RECVSEND_FIXED_BUF
12361236+If set, instructs io_uring to use a pre-mapped buffer. The
12371237+.I buf_index
12381238+field should contain an index into an array of fixed buffers. See
12391239+.BR io_uring_register (2)
12401240+for details on how to setup a context for fixed buffer I/O.
12411241+.EE
12421242+.in
12431243+.PP
12441244+10581245.PP
10591246The
10601247.I flags
···1143133011441331The semantics are chosen to accommodate several use cases. First, when all but
11451332the last request of a normal link without linked timeouts are marked with the
11461146-flag, only one CQE per lin is posted. Additionally, it enables supression of
13331333+flag, only one CQE per lin is posted. Additionally, it enables suppression of
11471334CQEs in cases where the side effects of a successfully executed operation is
11481335enough for userspace to know the state of the system. One such example would
11491336be writing to a synchronisation file.
···12821469io_uring-specific opcodes.
12831470.PP
12841471.SH RETURN VALUE
12851285-.BR io_uring_enter ()
14721472+.BR io_uring_enter (2)
12861473returns the number of I/Os successfully consumed. This can be zero
12871474if
12881475.I to_submit
···12991486rather than through the system call itself.
1300148713011488Errors that occur not on behalf of a submission queue entry are returned via the
13021302-system call directly. On such an error,
13031303-.B -1
13041304-is returned and
14891489+system call directly. On such an error, a negative error code is returned. The
14901490+caller should not rely on
13051491.I errno
13061306-is set appropriately.
14921492+variable.
13071493.PP
13081494.SH ERRORS
13091495These are the errors returned by
13101310-.BR io_uring_enter ()
14961496+.BR io_uring_enter (2)
13111497system call.
13121498.TP
13131499.B EAGAIN
···13261512.BR io_uring_register (2)
13271513for details on how to enable the ring.
13281514.TP
15151515+.B EBADR
15161516+At least one CQE was dropped even with the
15171517+.B IORING_FEAT_NODROP
15181518+feature, and there are no otherwise available CQEs. This clears the error state
15191519+and so with no other changes the next call to
15201520+.BR io_uring_setup (2)
15211521+will not have this error. This error should be extremely rare and indicates the
15221522+machine is running critically low on memory and. It may be reasonable for the
15231523+application to terminate running unless it is able to safely handle any CQE
15241524+being lost.
15251525+.TP
13291526.B EBUSY
13301330-The application is attempting to overcommit the number of requests it can have
15271527+If the
15281528+.B IORING_FEAT_NODROP
15291529+feature flag is set, then
15301530+.B EBUSY
15311531+will be returned if there were overflow entries,
15321532+.B IORING_ENTER_GETEVENTS
15331533+flag is set and not all of the overflow entries were able to be flushed to
15341534+the CQ ring.
15351535+15361536+Without
15371537+.B IORING_FEAT_NODROP
15381538+the application is attempting to overcommit the number of requests it can have
13311539pending. The application should wait for some completions and try again. May
13321540occur if the application tries to queue more requests than we have room for in
13331541the CQ ring, or if the application attempts to wait for more events without
···11+.\" Copyright (C) 2022 Dylan Yudaken
22+.\"
33+.\" SPDX-License-Identifier: LGPL-2.0-or-later
44+.\"
55+.TH io_uring_get_events 3 "September 5, 2022" "liburing-2.3" "liburing Manual"
66+.SH NAME
77+io_uring_get_events \- Flush outstanding requests to CQE ring
88+.SH SYNOPSIS
99+.nf
1010+.B #include <liburing.h>
1111+.PP
1212+.BI "int io_uring_get_events(struct io_uring *" ring ");"
1313+.fi
1414+.SH DESCRIPTION
1515+.PP
1616+The
1717+.BR io_uring_get_events (3)
1818+function runs outstanding work and flushes completion events to the CQE ring.
1919+2020+There can be events needing to be flushed if the ring was full and had overflowed.
2121+Alternatively if the ring was setup with the
2222+.BR IORING_SETUP_DEFER_TASKRUN
2323+flag then this will process outstanding tasks, possibly resulting in more CQEs.
2424+2525+.SH RETURN VALUE
2626+On success
2727+.BR io_uring_get_events (3)
2828+returns 0. On failure it returns
2929+.BR -errno .
3030+.SH SEE ALSO
3131+.BR io_uring_get_sqe (3),
3232+.BR io_uring_submit_and_get_events (3),
3333+.BR io_uring_cq_has_overflow (3)
···3232and submitted via
3333.BR io_uring_submit (3).
34343535+Note that neither
3636+.BR io_uring_get_sqe
3737+nor the prep functions set (or clear) the
3838+.B user_data
3939+field of the SQE. If the caller expects
4040+.BR io_uring_cqe_get_data (3)
4141+or
4242+.BR io_uring_cqe_get_data64 (3)
4343+to return valid data when reaping IO completions, either
4444+.BR io_uring_sqe_set_data (3)
4545+or
4646+.BR io_uring_sqe_set_data64 (3)
4747+.B MUST
4848+have been called before submitting the request.
4949+3550.SH RETURN VALUE
3651.BR io_uring_get_sqe (3)
3752returns a pointer to the next submission queue event on success and NULL on
3853failure. If NULL is returned, the SQ ring is currently full and entries must
3954be submitted for processing before new ones can get allocated.
4055.SH SEE ALSO
4141-.BR io_uring_submit (3)
5656+.BR io_uring_submit (3),
5757+.BR io_uring_sqe_set_data (3)
···3939.PP
4040The
4141.BR io_uring_prep_accept (3)
4242-function prepares an accept request. The submission queue entry
4242+function and its three variants prepare an accept request similar to
4343+.BR accept4 (2).
4444+The submission queue entry
4345.I sqe
4446is setup to use the file descriptor
4547.I sockfd
···5052and using modifier flags in
5153.IR flags .
52545353-For a direct descriptor accept request, the offset is specified by the
5454-.I file_index
5555-argument. Direct descriptors are io_uring private file descriptors. They
5555+The three variants allow combining the direct file table and multishot features.
5656+5757+Direct descriptors are io_uring private file descriptors. They
5658avoid some of the overhead associated with thread shared file tables and
5757-can be used in any io_uring request that takes a file descriptor. To do so,
5959+can be used in any io_uring request that takes a file descriptor.
6060+The two direct variants here create such direct descriptors.
6161+Subsequent to their creation, they can be used by setting
5862.B IOSQE_FIXED_FILE
5959-must be set in the SQE
6363+in the SQE
6064.I flags
6161-member, and the SQE
6565+member, and setting the SQE
6266.I fd
6363-field should use the direct descriptor value rather than the regular file
6767+field to the direct descriptor value rather than the regular file
6468descriptor. Direct descriptors are managed like registered files.
65696666-If the direct variant is used, the application must first have registered
6767-a file table using
7070+To use an accept direct variant, the application must first have registered
7171+a file table of a desired size using
6872.BR io_uring_register_files (3)
6969-of the appropriate size. Once registered, a direct accept request may use any
7070-entry in that table, as long as it is within the size of the registered table.
7171-If a specified entry already contains a file, the file will first be removed
7272-from the table and closed. It's consistent with the behavior of updating an
7373+or
7474+.BR io_uring_register_files_sparse (3).
7575+Once registered,
7676+.BR io_uring_prep_accept_direct (3)
7777+allows an entry in that table to be specifically selected through the
7878+.I file_index
7979+argument.
8080+If the specified entry already contains a file, the file will first be removed
8181+from the table and closed, consistent with the behavior of updating an
7382existing file with
7483.BR io_uring_register_files_update (3).
8484+.I file_index
8585+can also be set to
8686+.B IORING_FILE_INDEX_ALLOC
8787+for this variant and
8888+an unused table index will be dynamically chosen and returned.
8989+Likewise,
9090+.B io_uring_prep_multishot_accept_direct
9191+will have an unused table index dynamically chosen and returned for each connection accepted.
9292+If both forms of direct selection will be employed, specific and dynamic, see
9393+.BR io_uring_register_file_alloc_range (3)
9494+for setting up the table so dynamically chosen entries are made against
9595+a different range than that targetted by specific requests.
9696+7597Note that old kernels don't check the SQE
7698.I file_index
7777-field, which is not a problem for liburing helpers, but users of the raw
7878-io_uring interface need to zero SQEs to avoid unexpected behavior. This also
7979-means that applications should check for availability of
8080-.B IORING_OP_ACCEPT_DIRECT
8181-before using it, they cannot rely on a
9999+field meaning
100100+applications cannot rely on a
82101.B -EINVAL
83102CQE
84103.I res
8585-return.
104104+being returned when the kernel is too old because older kernels
105105+may not recognize they are being asked to use a direct table slot.
861068787-For a direct descriptor accept request, the
8888-.I file_index
8989-argument can be set to
9090-.BR IORING_FILE_INDEX_ALLOC ,
9191-In this case a free entry in io_uring file table will
9292-be used automatically and the file index will be returned as CQE
9393-.IR res .
107107+When a direct descriptor accept request asks for a table slot to be
108108+dynamically chosen but there are no free entries,
94109.B -ENFILE
9595-is otherwise returned if there is no free entries in the io_uring file table.
110110+is returned as the CQE
111111+.IR res .
961129797-The multishot version accept and accept_direct allow an application to issue
113113+The multishot variants allow an application to issue
98114a single accept request, which will repeatedly trigger a CQE when a connection
99115request comes in. Like other multishot type requests, the application should
100116look at the CQE
···102118and see if
103119.B IORING_CQE_F_MORE
104120is set on completion as an indication of whether or not the accept request
105105-will generate further CQEs. The multishot variants are available since 5.19.
121121+will generate further CQEs. Note that for the multishot variants, setting
122122+.B addr
123123+and
124124+.B addrlen
125125+may not make a lot of sense, as the same value would be used for every
126126+accepted connection. This means that the data written to
127127+.B addr
128128+may be overwritten by a new connection before the application has had time
129129+to process a past connection. If the application knows that a new connection
130130+cannot come in before a previous one has been processed, it may be used as
131131+expected. The multishot variants are available since 5.19.
106132107107-For multishot with direct descriptors,
108108-.B IORING_FILE_INDEX_ALLOC
109109-must be used as the file descriptor. This tells io_uring to allocate a free
110110-direct descriptor from our table, rather than the application passing one in.
111111-Failure to do so will result in the accept request being terminated with
112112-.BR -EINVAL .
113113-The allocated descriptor will be returned in the CQE
114114-.I res
115115-field, like a non-direct accept request.
116116-117117-These functions prepare an async
133133+See the man page
118134.BR accept4 (2)
119119-request. See that man page for details.
135135+for details of the accept function itself.
120136121137.SH RETURN VALUE
122138None
123139.SH ERRORS
124140The CQE
125141.I res
126126-field will contain the result of the operation. For singleshot accept, the
127127-non-direct accept returns the installed file descriptor as its value, the
128128-direct accept returns
142142+field will contain the result of the operation.
143143+144144+.BR io_uring_prep_accept (3)
145145+generates the installed file descriptor as its result.
146146+147147+.BR io_uring_prep_accept_direct (3)
148148+and
149149+.I file_index
150150+set to a specific direct descriptor
151151+generates
129152.B 0
130130-on success. The caller must know which direct descriptor was picked for this
131131-request. For multishot accept, the non-direct accept returns the installed
132132-file descriptor as its value, the direct accept returns the file index used on
133133-success. See the related man page for details on possible values for the
134134-non-direct accept. Note that where synchronous system calls will return
153153+on success.
154154+The caller must remember which direct descriptor was picked for this request.
155155+156156+.BR io_uring_prep_accept_direct (3)
157157+and
158158+.I file_index
159159+set to
160160+.B IORING_FILE_INDEX_ALLOC
161161+generates the dynamically chosen direct descriptor.
162162+163163+.BR io_uring_prep_multishot_accept (3)
164164+generates the installed file descriptor in each result.
165165+166166+.BR io_uring_prep_multishot_accept_direct (3),
167167+generates the dynamically chosen direct descriptor in each result.
168168+169169+Note that where synchronous system calls will return
135170.B -1
136171on failure and set
137172.I errno
138173to the actual error value, io_uring never uses
139174.IR errno .
140140-Instead it returns the negated
175175+Instead it generates the negated
141176.I errno
142177directly in the CQE
143178.I res
···155190.SH SEE ALSO
156191.BR io_uring_get_sqe (3),
157192.BR io_uring_submit (3),
193193+.BR io_uring_register_files (3),
194194+.BR io_uring_register_files_sparse (3),
195195+.BR io_uring_register_file_alloc_range (3),
158196.BR io_uring_register (2),
159197.BR accept4 (2)
+28
vendor/liburing/man/io_uring_prep_nop.3
···11+.\" Copyright (C) 2022 Samuel Williams
22+.\"
33+.\" SPDX-License-Identifier: LGPL-2.0-or-later
44+.\"
55+.TH io_uring_prep_nop 3 "October 20, 2022" "liburing-2.2" "liburing Manual"
66+.SH NAME
77+io_uring_prep_nop \- prepare a nop request
88+.SH SYNOPSIS
99+.nf
1010+.B #include <liburing.h>
1111+.PP
1212+.BI "void io_uring_prep_nop(struct io_uring_sqe *" sqe ");"
1313+.fi
1414+.SH DESCRIPTION
1515+.PP
1616+The
1717+.BR io_uring_prep_nop (3)
1818+function prepares nop (no operation) request. The submission queue entry
1919+.I sqe
2020+does not require any additional setup.
2121+2222+.SH RETURN VALUE
2323+None
2424+.SH ERRORS
2525+None
2626+.SH SEE ALSO
2727+.BR io_uring_get_sqe (3),
2828+.BR io_uring_submit (3),
+1-1
vendor/liburing/man/io_uring_prep_read.3
···4040to the file is serialized. It is not encouraged to use this feature, if it's
4141possible to provide the desired IO offset from the application or library.
42424343-On files that are not capable of seeking, the offset is ignored.
4343+On files that are not capable of seeking, the offset must be 0 or -1.
44444545After the read has been prepared it can be submitted with one of the submit
4646functions.
+1-1
vendor/liburing/man/io_uring_prep_read_fixed.3
···4242.I buf
4343and
4444.I nbytes
4545-arguments must fall within a region specificed by
4545+arguments must fall within a region specified by
4646.I buf_index
4747in the previously registered buffer. The buffer need not be aligned with
4848the start of the registered buffer.
+1-1
vendor/liburing/man/io_uring_prep_readv.3
···4141to the file is serialized. It is not encouraged to use this feature, if it's
4242possible to provide the desired IO offset from the application or library.
43434444-On files that are not capable of seeking, the offset is ignored.
4444+On files that are not capable of seeking, the offset must be 0 or -1.
45454646After the write has been prepared it can be submitted with one of the submit
4747functions.
+1-1
vendor/liburing/man/io_uring_prep_readv2.3
···6767to the file is serialized. It is not encouraged to use this feature, if it's
6868possible to provide the desired IO offset from the application or library.
69697070-On files that are not capable of seeking, the offset is ignored.
7070+On files that are not capable of seeking, the offset must be 0 or -1.
71717272After the write has been prepared, it can be submitted with one of the submit
7373functions.
+23-1
vendor/liburing/man/io_uring_prep_recv.3
···1414.BI " void *" buf ","
1515.BI " size_t " len ","
1616.BI " int " flags ");"
1717+.PP
1818+.BI "void io_uring_prep_recv_multishot(struct io_uring_sqe *" sqe ","
1919+.BI " int " sockfd ","
2020+.BI " void *" buf ","
2121+.BI " size_t " len ","
2222+.BI " int " flags ");"
1723.fi
1824.SH DESCRIPTION
1925.PP
···3642request. See that man page for details on the arguments specified to this
3743prep helper.
38444545+The 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
4848+.B IOSQE_BUFFER_SELECT
4949+flag to be set and no
5050+.B MSG_WAITALL
5151+flag to be set.
5252+Therefore 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.
5454+If a posted CQE does not have the
5555+.B IORING_CQE_F_MORE
5656+flag set then the multishot receive will be done and the application should issue a
5757+new request.
5858+Multishot variants are available since kernel 6.0.
5959+6060+3961After calling this function, additional io_uring internal modifier flags
4062may be set in the SQE
4141-.I off
6363+.I ioprio
4264field. The following flags are supported:
4365.TP
4466.B IORING_RECVSEND_POLL_FIRST
···1515.BI " int " fd ","
1616.BI " struct msghdr *" msg ","
1717.BI " unsigned " flags ");"
1818+.PP
1919+.BI "void io_uring_prep_recvmsg_multishot(struct io_uring_sqe *" sqe ","
2020+.BI " int " fd ","
2121+.BI " struct msghdr *" msg ","
2222+.BI " unsigned " flags ");"
1823.fi
1924.SH DESCRIPTION
2025.PP
···3742request. See that man page for details on the arguments specified to this
3843prep helper.
39444545+The multishot version allows the application to issue a single receive request,
4646+which repeatedly posts a CQE when data is available. It requires the
4747+.B IOSQE_BUFFER_SELECT
4848+flag to be set and no
4949+.B MSG_WAITALL
5050+flag to be set.
5151+Therefore 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.
5353+If a posted CQE does not have the
5454+.B IORING_CQE_F_MORE
5555+flag set then the multishot receive will be done and the application should issue a
5656+new request.
5757+5858+Unlike
5959+.BR recvmsg (2)
6060+, multishot recvmsg will prepend a
6161+.I struct io_uring_recvmsg_out
6262+which describes the layout of the rest of the buffer in combination with the initial
6363+.I struct msghdr
6464+submitted with the request. See
6565+.B io_uring_recvmsg_out (3)
6666+for more information on accessing the data.
6767+6868+Multishot variants are available since kernel 6.0.
6969+4070After calling this function, additional io_uring internal modifier flags
4171may be set in the SQE
4242-.I off
7272+.I ioprio
4373field. The following flags are supported:
4474.TP
4575.B IORING_RECVSEND_POLL_FIRST
···2626to start sending the data from
2727.I buf
2828of size
2929-.I size
3030-and with modifier flags
2929+.I len
3030+bytes and with modifier flags
3131.IR flags .
32323333This function prepares an async
+64
vendor/liburing/man/io_uring_prep_send_zc.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_prep_send_zc 3 "September 6, 2022" "liburing-2.3" "liburing Manual"
66+.SH NAME
77+io_uring_prep_send_zc \- prepare a zerocopy send request
88+.SH SYNOPSIS
99+.nf
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 ");"
1818+.fi
1919+.SH DESCRIPTION
2020+.PP
2121+The
2222+.BR io_uring_prep_send_zc (3)
2323+function prepares a zerocopy send request. The submission queue entry
2424+.I sqe
2525+is setup to use the file descriptor
2626+.I sockfd
2727+to start sending the data from
2828+.I buf
2929+of size
3030+.I len
3131+bytes with send modifier flags
3232+.IR flags
3333+and zerocopy modifier flags
3434+.IR zc_flags .
3535+3636+This function prepares an async zerocopy
3737+.BR send (2)
3838+request. See that man page for details. For details on the zerocopy nature
3939+of it, see
4040+.BR io_uring_enter (2) .
4141+4242+.SH RETURN VALUE
4343+None
4444+.SH ERRORS
4545+The CQE
4646+.I res
4747+field will contain the result of the operation. See the related man page for
4848+details on possible values. Note that where synchronous system calls will return
4949+.B -1
5050+on failure and set
5151+.I errno
5252+to the actual error value, io_uring never uses
5353+.IR errno .
5454+Instead it returns the negated
5555+.I errno
5656+directly in the CQE
5757+.I res
5858+field.
5959+.SH SEE ALSO
6060+.BR io_uring_get_sqe (3),
6161+.BR io_uring_submit (3),
6262+.BR io_uring_prep_send (3),
6363+.BR io_uring_enter (2),
6464+.BR send (2)
+25-4
vendor/liburing/man/io_uring_prep_socket.3
···2222.BI " int " protocol ","
2323.BI " unsigned int " file_index ","
2424.BI " unsigned int " flags ");"
2525+.PP
2626+.BI "void io_uring_prep_socket_direct_alloc(struct io_uring_sqe *" sqe ","
2727+.BI " int " domain ","
2828+.BI " int " type ","
2929+.BI " int " protocol ","
3030+.BI " unsigned int " flags ");"
2531.fi
2632.SH DESCRIPTION
2733.PP
···41474248The
4349.BR io_uring_prep_socket_direct (3)
4444-works just like
5050+helper works just like
4551.BR io_uring_prep_socket (3),
4652except it maps the socket to a direct descriptor rather than return a normal
4753file descriptor. The
4854.I file_index
4949-argument should be set to the slot that should be used for this socket, or
5555+argument should be set to the slot that should be used for this socket.
5656+5757+The
5858+.BR io_uring_prep_socket_direct_alloc (3)
5959+helper works just like
6060+.BR io_uring_prep_socket_alloc (3),
6161+except it allocates a new direct descriptor rather than pass a free slot in. It
6262+is equivalent to using
6363+.BR io_uring_prep_socket_direct (3)
6464+with
5065.B IORING_FILE_INDEX_ALLOC
5151-if io_uring should allocate a free one.
6666+as the
6767+.I
6868+file_index .
6969+Upon completion, the
7070+.I res
7171+field of the CQE will return the direct slot that was allocated for the
7272+socket.
52735353-If the direct variant is used, the application must first have registered
7474+If the direct variants are used, the application must first have registered
5475a file table using
5576.BR io_uring_register_files (3)
5677of the appropriate size. Once registered, a direct socket request may use any
···4040to the file is serialized. It is not encouraged to use this feature if it's
4141possible to provide the desired IO offset from the application or library.
42424343-On files that are not capable of seeking, the offset is ignored.
4343+On files that are not capable of seeking, the offset must be 0 or -1.
44444545After the write has been prepared, it can be submitted with one of the submit
4646functions.
+1-1
vendor/liburing/man/io_uring_prep_write_fixed.3
···4242.I buf
4343and
4444.I nbytes
4545-arguments must fall within a region specificed by
4545+arguments must fall within a region specified by
4646.I buf_index
4747in the previously registered buffer. The buffer need not be aligned with
4848the start of the registered buffer.
+1-1
vendor/liburing/man/io_uring_prep_writev.3
···4141to the file is serialized. It is not encouraged to use this feature if it's
4242possible to provide the desired IO offset from the application or library.
43434444-On files that are not capable of seeking, the offset is ignored.
4444+On files that are not capable of seeking, the offset must be 0 or -1.
45454646After the write has been prepared it can be submitted with one of the submit
4747functions.
+1-1
vendor/liburing/man/io_uring_prep_writev2.3
···6767to the file is serialized. It is not encouraged to use this feature if it's
6868possible to provide the desired IO offset from the application or library.
69697070-On files that are not capable of seeking, the offset is ignored.
7070+On files that are not capable of seeking, the offset must be 0 or -1.
71717272After the write has been prepared, it can be submitted with one of the submit
7373functions.
···11+.\" Copyright (C), 2022 Dylan Yudaken <dylany@fb.com>
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"
66+.SH NAME
77+io_uring_recvmsg_out - access data from multishot recvmsg
88+.SH SYNOPSIS
99+.nf
1010+.B #include <liburing.h>
1111+.PP
1212+.BI "struct io_uring_recvmsg_out *io_uring_recvmsg_validate(void *" buf ","
1313+.BI " int " buf_len ","
1414+.BI " struct msghdr *" msgh ");"
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 ","
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 ","
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 ","
2828+.BI " struct msghdr *" msgh ");"
2929+.PP
3030+.fi
3131+3232+.SH DESCRIPTION
3333+3434+These functions are used to access data in the payload delivered by
3535+.BR io_uring_prep_recv_multishot (3)
3636+.
3737+.PP
3838+.BR io_uring_recvmsg_validate (3)
3939+will validate a buffer delivered by
4040+.BR io_uring_prep_recv_multishot (3)
4141+and extract the
4242+.I io_uring_recvmsg_out
4343+if it is valid, returning a pointer to it or else NULL.
4444+.PP
4545+The structure is defined as follows:
4646+.PP
4747+.in +4n
4848+.EX
4949+5050+struct io_uring_recvmsg_out {
5151+ __u32 namelen; /* Name byte count as would have been populated
5252+ * by recvmsg(2) */
5353+ __u32 controllen; /* Control byte count */
5454+ __u32 payloadlen; /* Payload byte count as would have been returned
5555+ * by recvmsg(2) */
5656+ __u32 flags; /* Flags result as would have been populated
5757+ * by recvmsg(2) */
5858+};
5959+6060+.IP * 3
6161+.BR io_uring_recvmsg_name (3)
6262+returns a pointer to the name in the buffer.
6363+.IP *
6464+.BR io_uring_recvmsg_cmsg_firsthdr (3)
6565+returns a pointer to the first cmsg in the buffer, or NULL.
6666+.IP *
6767+.BR io_uring_recvmsg_cmsg_nexthdr (3)
6868+returns a pointer to the next cmsg in the buffer, or NULL.
6969+.IP *
7070+.BR io_uring_recvmsg_payload (3)
7171+returns a pointer to the payload in the buffer.
7272+.IP *
7373+.BR io_uring_recvmsg_payload_length (3)
7474+Calculates the usable payload length in bytes.
7575+7676+7777+.SH "SEE ALSO"
7878+.BR io_uring_prep_recv_multishot (3)
···33.\"
44.\" SPDX-License-Identifier: LGPL-2.0-or-later
55.\"
66-.TH IO_URING_REGISTER 2 2019-01-17 "Linux" "Linux Programmer's Manual"
66+.TH io_uring_register 2 2019-01-17 "Linux" "Linux Programmer's Manual"
77.SH NAME
88io_uring_register \- register files or user buffers for asynchronous I/O
99.SH SYNOPSIS
1010.nf
1111-.BR "#include <linux/io_uring.h>"
1111+.BR "#include <liburing.h>"
1212.PP
1313.BI "int io_uring_register(unsigned int " fd ", unsigned int " opcode ,
1414.BI " void *" arg ", unsigned int " nr_args );
···1818.PP
19192020The
2121-.BR io_uring_register ()
2121+.BR io_uring_register (2)
2222system call registers resources (e.g. user buffers, files, eventfd,
2323personality, restrictions) for use in an
2424.BR io_uring (7)
···8585An application can increase or decrease the size or number of
8686registered buffers by first unregistering the existing buffers, and
8787then issuing a new call to
8888-.BR io_uring_register ()
8888+.BR io_uring_register (2)
8989with the new buffers.
90909191Note that before 5.13 registering buffers would wait for the ring to idle.
···428428entries.
429429430430With an entry it is possible to allow an
431431-.BR io_uring_register ()
431431+.BR io_uring_register (2)
432432.I opcode,
433433or specify which
434434.I opcode
···440440to be specified (these flags must be set on each submission queue entry).
441441442442All the restrictions must be submitted with a single
443443-.BR io_uring_register ()
443443+.BR io_uring_register (2)
444444call and they are handled as an allowlist (opcodes and flags not registered,
445445are not allowed).
446446···546546is used rather than a real file descriptor.
547547548548Each thread or process using a ring must register the file descriptor directly
549549-by issuing this request.o
549549+by issuing this request.
550550551551The maximum number of supported registered ring descriptors is currently
552552limited to
···579579580580Available since 5.18.
581581582582+.TP
583583+.B IORING_REGISTER_PBUF_RING
584584+Registers a shared buffer ring to be used with provided buffers. This is a
585585+newer alternative to using
586586+.B IORING_OP_PROVIDE_BUFFERS
587587+which is more efficient, to be used with request types that support the
588588+.B IOSQE_BUFFER_SELECT
589589+flag.
590590+591591+The
592592+.I arg
593593+argument must be filled in with the appropriate information. It looks as
594594+follows:
595595+.PP
596596+.in +12n
597597+.EX
598598+struct io_uring_buf_reg {
599599+ __u64 ring_addr;
600600+ __u32 ring_entries;
601601+ __u16 bgid;
602602+ __u16 pad;
603603+ __u64 resv[3];
604604+};
605605+.EE
606606+.in
607607+.PP
608608+.in +8n
609609+The
610610+.I ring_addr
611611+field must contain the address to the memory allocated to fit this ring.
612612+The memory must be page aligned and hence allocated appropriately using eg
613613+.BR posix_memalign (3)
614614+or similar. The size of the ring is the product of
615615+.I ring_entries
616616+and the size of
617617+.IR "struct io_uring_buf" .
618618+.I ring_entries
619619+is the desired size of the ring, and must be a power-of-2 in size. The maximum
620620+size allowed is 2^15 (32768).
621621+.I bgid
622622+is the buffer group ID associated with this ring. SQEs that select a buffer
623623+has a buffer group associated with them in their
624624+.I buf_group
625625+field, and the associated CQE will have
626626+.B IORING_CQE_F_BUFFER
627627+set in their
628628+.I flags
629629+member, which will also contain the specific ID of the buffer selected. The rest
630630+of the fields are reserved and must be cleared to zero.
631631+632632+The
633633+.I flags
634634+argument is currently unused and must be set to zero.
635635+636636+.i nr_args
637637+must be set to 1.
638638+639639+Also see
640640+.BR io_uring_register_buf_ring (3)
641641+for more details. Available since 5.19.
642642+643643+.TP
644644+.B IORING_UNREGISTER_PBUF_RING
645645+Unregister a previously registered provided buffer ring.
646646+.I arg
647647+must be set to the address of a struct io_uring_buf_reg, with just the
648648+.I bgid
649649+field set to the buffer group ID of the previously registered provided buffer
650650+group.
651651+.I nr_args
652652+must be set to 1. Also see
653653+.B IORING_REGISTER_PBUF_RING .
654654+655655+Available since 5.19.
656656+657657+.TP
658658+.B IORING_REGISTER_SYNC_CANCEL
659659+Performs a synchronous cancelation request, which works in a similar fashion to
660660+.B IORING_OP_ASYNC_CANCEL
661661+except it completes inline. This can be useful for scenarios where cancelations
662662+should happen synchronously, rather than needing to issue an SQE and wait for
663663+completion of that specific CQE.
664664+665665+.I arg
666666+must be set to a pointer to a struct io_uring_sync_cancel_reg structure, with
667667+the details filled in for what request(s) to target for cancelation. See
668668+.BR io_uring_register_sync_cancel (3)
669669+for details on that. The return values are the same, except they are passed
670670+back synchronously rather than through the CQE
671671+.I res
672672+field.
673673+.I nr_args
674674+must be set to 1.
675675+676676+Available since 6.0.
677677+678678+.TP
679679+.B IORING_REGISTER_FILE_ALLOC_RANGE
680680+sets the allowable range for fixed file index allocations within the
681681+kernel. When requests that can instantiate a new fixed file are used with
682682+.B IORING_FILE_INDEX_ALLOC ,
683683+the application is asking the kernel to allocate a new fixed file descriptor
684684+rather than pass in a specific value for one. By default, the kernel will
685685+pick any available fixed file descriptor within the range available.
686686+This effectively allows the application to set aside a range just for dynamic
687687+allocations, with the remainder being used for specific values.
688688+689689+.I nr_args
690690+must be set to 1 and
691691+.I arg
692692+must be set to a pointer to a struct io_uring_file_index_range:
693693+.PP
694694+.in +12n
695695+.EX
696696+struct io_uring_file_index_range {
697697+ __u32 off;
698698+ __u32 len;
699699+ __u64 resv;
700700+};
701701+.EE
702702+.in
703703+.PP
704704+.in +8n
705705+with
706706+.I off
707707+being set to the starting value for the range, and
708708+.I len
709709+being set to the number of descriptors. The reserved
710710+.I resv
711711+field must be cleared to zero.
712712+713713+The application must have registered a file table first.
714714+715715+Available since 6.0.
716716+582717.SH RETURN VALUE
583718584719On success,
585585-.BR io_uring_register ()
586586-returns 0. On error,
587587-.B -1
588588-is returned, and
720720+.BR io_uring_register (2)
721721+returns either 0 or a positive value, depending on the
722722+.I opcode
723723+used. On error, a negative error value is returned. The caller should not rely
724724+on the
589725.I errno
590590-is set accordingly.
726726+variable.
591727592728.SH ERRORS
593729.TP
+3-2
vendor/liburing/man/io_uring_register_buf_ring.3
···5555and the size of
5656.IR "struct io_uring_buf" .
5757.I ring_entries
5858-is the desired size of the ring, and must be a power-of-2 in size.
5858+is the desired size of the ring, and must be a power-of-2 in size. The maximum
5959+size allowed is 2^15 (32768).
5960.I bgid
6061is the buffer group ID associated with this ring. SQEs that select a buffer
6162has a buffer group associated with them in their
···6465.B IORING_CQE_F_BUFFER
6566set in their
6667.I flags
6767-member, which will also contain the specific ID of the buffer seleted. The rest
6868+member, which will also contain the specific ID of the buffer selected. The rest
6869of the fields are reserved and must be cleared to zero.
69707071The
···11+.\" Copyright (C) 2022 Jens Axboe <axboe@kernel.dk>
22+.\"
33+.\" SPDX-License-Identifier: LGPL-2.0-or-later
44+.\"
55+.TH io_uring_register_file_alloc_range 3 "Oct 21, 2022" "liburing-2.3" "liburing Manual"
66+.SH NAME
77+io_uring_register_file_alloc_range \- set range for fixed file allocations
88+.SH SYNOPSIS
99+.nf
1010+.B #include <liburing.h>
1111+.PP
1212+.BI "int io_uring_register_file_alloc_range(struct io_uring *" ring ",
1313+.BI " unsigned " off ","
1414+.BI " unsigned " len ");"
1515+.BI "
1616+.fi
1717+.SH DESCRIPTION
1818+.PP
1919+The
2020+.BR io_uring_register_file_alloc_range (3)
2121+function sets the allowable range for fixed file index allocations within the
2222+kernel. When requests that can instantiate a new fixed file are used with
2323+.B IORING_FILE_INDEX_ALLOC ,
2424+the application is asking the kernel to allocate a new fixed file descriptor
2525+rather than pass in a specific value for one. By default, the kernel will
2626+pick any available fixed file descriptor within the range available. Calling
2727+this function with
2828+.I off
2929+set to the starting offset and
3030+.I len
3131+set to the number of descriptors, the application can limit the allocated
3232+descriptors to that particular range. This effectively allows the application
3333+to set aside a range just for dynamic allocations, with the remainder being
3434+used for specific values.
3535+3636+The application must have registered a fixed file table upfront, eg through
3737+.BR io_uring_register_files (3)
3838+or
3939+.BR io_uring_register_files_sparse (3) .
4040+4141+Available since 6.0.
4242+4343+.SH RETURN VALUE
4444+On success
4545+.BR io_uring_register_buf_ring (3)
4646+returns 0. On failure it returns
4747+.BR -errno .
4848+.SH SEE ALSO
4949+.BR io_uring_register_files (3)
5050+.BR io_uring_prep_accept_direct (3)
5151+.BR io_uring_prep_openat_direct (3)
5252+.BR io_uring_prep_socket_direct (3)
+7
vendor/liburing/man/io_uring_register_files.3
···3838Registering a file table is a prerequisite for using any request that uses
3939direct descriptors.
40404141+Registered files have less overhead per operation than normal files. This
4242+is due to the kernel grabbing a reference count on a file when an operation
4343+begins, and dropping it when it's done. When the process file table is
4444+shared, for example if the process has ever created any threads, then this
4545+cost goes up even more. Using registered files reduces the overhead of
4646+file reference management across requests that operate on a file.
4747+4148.SH RETURN VALUE
4249On success
4350.BR io_uring_register_files (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_register_sync_cancel 3 "September 21, 2022" "liburing-2.3" "liburing Manual"
66+.SH NAME
77+io_uring_register_sync_cancel \- issue a synchronous cancelation request
88+.SH SYNOPSIS
99+.nf
1010+.B #include <liburing.h>
1111+.PP
1212+.BI "int io_uring_register_sync_cancel(struct io_uring *" ring ",
1313+.BI " struct io_uring_sync_cancel_reg *" reg ");
1414+.PP
1515+.SH DESCRIPTION
1616+.PP
1717+The
1818+.BR io_uring_register_sync_cancel (3)
1919+function performs a synchronous cancelation request based on the parameters
2020+specified in
2121+.I reg .
2222+2323+The
2424+.I reg
2525+argument must be filled in with the appropriate information for the
2626+cancelation request. It looks as follows:
2727+.PP
2828+.in +4n
2929+.EX
3030+struct io_uring_sync_cancel_reg {
3131+ __u64 addr;
3232+ __s32 fd;
3333+ __u32 flags;
3434+ struct __kernel_timespec timeout;
3535+ __u64 pad[4];
3636+};
3737+.EE
3838+.in
3939+.PP
4040+4141+The arguments largely mirror what the async prep functions support, see
4242+.BR io_uring_prep_cancel (3)
4343+for details. Similarly, the return value is the same. The exception is the
4444+.I timeout
4545+argument, which can be used to limit the time that the kernel will wait for
4646+cancelations to be successful. If the
4747+.I tv_sec
4848+and
4949+.I tv_nsec
5050+values are set to anything but
5151+.B -1UL ,
5252+then they indicate a relative timeout upon which cancelations should be
5353+completed by.
5454+5555+The
5656+.I pad
5757+values must be zero filled.
5858+5959+.SH RETURN VALUE
6060+See
6161+.BR io_uring_prep_cancel (3)
6262+for details on the return value. If
6363+.I timeout
6464+is set to indicate a timeout, then
6565+.B -ETIME
6666+will be returned if exceeded. If an unknown value is set in the request,
6767+or if the pad values are not cleared to zero, then
6868+.I -EINVAL
6969+is returned.
7070+.SH SEE ALSO
7171+.BR io_uring_prep_cancel (3)
+56-12
vendor/liburing/man/io_uring_setup.2
···44.\"
55.\" SPDX-License-Identifier: LGPL-2.0-or-later
66.\"
77-.TH IO_URING_SETUP 2 2019-01-29 "Linux" "Linux Programmer's Manual"
77+.TH io_uring_setup 2 2019-01-29 "Linux" "Linux Programmer's Manual"
88.SH NAME
99io_uring_setup \- setup a context for performing asynchronous I/O
1010.SH SYNOPSIS
1111.nf
1212-.BR "#include <linux/io_uring.h>"
1212+.BR "#include <liburing.h>"
1313.PP
1414.BI "int io_uring_setup(u32 " entries ", struct io_uring_params *" p );
1515.fi
1616-.PP
1616+.PPAA
1717.SH DESCRIPTION
1818.PP
1919-The io_uring_setup() system call sets up a submission queue (SQ) and
2020-completion queue (CQ) with at least
1919+The
2020+.BR io_uring_setup (2)
2121+system call sets up a submission queue (SQ) and completion queue (CQ) with at
2222+least
2123.I entries
2224entries, and returns a file descriptor which can be used to perform
2325subsequent operations on the io_uring instance. The submission and
···234236passthrough command for NVMe passthrough needs this. Available since 5.19.
235237.TP
236238.B IORING_SETUP_CQE32
237237-If set, io_uring will use 32-byte CQEs rather than the normal 32-byte sized
239239+If set, io_uring will use 32-byte CQEs rather than the normal 16-byte sized
238240variant. This is a requirement for using certain request types, as of 5.19
239241only the
240242.B IORING_OP_URING_CMD
241243passthrough command for NVMe passthrough needs this. Available since 5.19.
244244+.TP
245245+.B IORING_SETUP_SINGLE_ISSUER
246246+A hint to the kernel that only a single task (or thread) will submit requests, which is
247247+used for internal optimisations. The submission task is either the task that created the
248248+ring, or if
249249+.B IORING_SETUP_R_DISABLED
250250+is specified then it is the task that enables the ring through
251251+.BR io_uring_register (2) .
252252+The kernel enforces this rule, failing requests with
253253+.B -EEXIST
254254+if the restriction is violated.
255255+Note that when
256256+.B IORING_SETUP_SQPOLL
257257+is set it is considered that the polling task is doing all submissions
258258+on behalf of the userspace and so it always complies with the rule disregarding
259259+how many userspace tasks do
260260+.BR io_uring_enter(2).
261261+Available since 6.0.
262262+.TP
263263+.B IORING_SETUP_DEFER_TASKRUN
264264+By default, io_uring will process all outstanding work at the end of any system
265265+call or thread interrupt. This can delay the application from making other progress.
266266+Setting this flag will hint to io_uring that it should defer work until an
267267+.BR io_uring_enter(2)
268268+call with the
269269+.B IORING_ENTER_GETEVENTS
270270+flag set. This allows the application to request work to run just before it wants to
271271+process completions.
272272+This flag requires the
273273+.BR IORING_SETUP_SINGLE_ISSUER
274274+flag to be set, and also enforces that the call to
275275+.BR io_uring_enter(2)
276276+is called from the same thread that submitted requests.
277277+Note that if this flag is set then it is the application's responsibility to periodically
278278+trigger work (for example via any of the CQE waiting functions) or else completions may
279279+not be delivered.
280280+Available since 6.1.
242281.PP
243282If no flags are specified, the io_uring instance is setup for
244283interrupt driven I/O. I/O may be submitted using
···261300calls down from three to two. Available since kernel 5.4.
262301.TP
263302.B IORING_FEAT_NODROP
264264-If this flag is set, io_uring supports never dropping completion events.
303303+If this flag is set, io_uring supports almost never dropping completion events.
265304If a completion event occurs and the CQ ring is full, the kernel stores
266305the event internally until such a time that the CQ ring has room for more
267306entries. If this overflow condition is entered, attempting to submit more
···269308.B -EBUSY
270309error value, if it can't flush the overflown events to the CQ ring. If this
271310happens, the application must reap events from the CQ ring and attempt the
272272-submit again. Available since kernel 5.5.
311311+submit again. If the kernel has no free memory to store the event internally
312312+it will be visible by an increase in the overflow value on the cqring.
313313+Available since kernel 5.5. Additionally
314314+.BR io_uring_enter (2)
315315+will return
316316+.B -EBADR
317317+the next time it would otherwise sleep waiting for completions (since kernel 5.19).
318318+273319.TP
274320.B IORING_FEAT_SUBMIT_STABLE
275321If this flag is set, applications can be certain that any data for
···548594.BR io_uring_enter (2)
549595system calls.
550596551551-On error,
552552-.B -1
553553-is returned and
597597+On error, a negative error code is returned. The caller should not rely on
554598.I errno
555555-is set appropriately.
599599+variable.
556600.PP
557601.SH ERRORS
558602.TP
+2-2
vendor/liburing/man/io_uring_sq_ready.3
···22.\"
33.\" SPDX-License-Identifier: LGPL-2.0-or-later
44.\"
55-.TH io_uring_sq_ready "January 25, 2022" "liburing-2.1" "liburing Manual"
55+.TH io_uring_sq_ready 3 "January 25, 2022" "liburing-2.1" "liburing Manual"
66.SH NAME
77io_uring_sq_ready \- number of unconsumed or unsubmitted entries in the SQ ring
88.SH SYNOPSIS
···1515.PP
1616The
1717.BR io_uring_sq_ready (3)
1818-function retuns the number of unconsumed (if SQPOLL) or unsubmitted entries
1818+function returns the number of unconsumed (if SQPOLL) or unsubmitted entries
1919that exist in the SQ ring belonging to the
2020.I ring
2121param.
+2-2
vendor/liburing/man/io_uring_sq_space_left.3
···22.\"
33.\" SPDX-License-Identifier: LGPL-2.0-or-later
44.\"
55-.TH io_uring_sq_space-left "January 25, 2022" "liburing-2.1" "liburing Manual"
55+.TH io_uring_sq_space-left 3 "January 25, 2022" "liburing-2.1" "liburing Manual"
66.SH NAME
77io_uring_sq_space_left \- free space in the SQ ring
88.SH SYNOPSIS
···1515.PP
1616The
1717.BR io_uring_sq_space_left (3)
1818-function retuns how much space is left in the SQ ring belonging to the
1818+function returns how much space is left in the SQ ring belonging to the
1919.I ring
2020param.
2121
+4-3
vendor/liburing/man/io_uring_sqe_set_flags.3
···22.\"
33.\" SPDX-License-Identifier: LGPL-2.0-or-later
44.\"
55-.TH io_uring_sqe_set_flags "January 25, 2022" "liburing-2.1" "liburing Manual"
55+.TH io_uring_sqe_set_flags 3 "January 25, 2022" "liburing-2.1" "liburing Manual"
66.SH NAME
77io_uring_sqe_set_flags \- set flags for submission queue entry
88.SH SYNOPSIS
···3737always (or most of the time) block, the application can ask for an sqe to be
3838issued async from the start. Note that this flag immediately causes the SQE
3939to be offloaded to an async helper thread with no initial non-blocking attempt.
4040-This may be less efficient and should not be used sporadically.
4040+This may be less efficient and should not be used liberally or without
4141+understanding the performance and efficiency tradeoffs.
4142.TP
4243.B IOSQE_IO_LINK
4344When this flag is specified, the SQE forms a link with the next SQE in the
···6566.B IOSQE_CQE_SKIP_SUCCESS
6667Request that no CQE be generated for this request, if it completes successfully.
6768This can be useful in cases where the application doesn't need to know when
6868-a specific request completed, if it completed succesfully.
6969+a specific request completed, if it completed successfully.
6970.TP
7071.B IOSQE_BUFFER_SELECT
7172If set, and if the request types supports it, select an IO buffer from the
+1-1
vendor/liburing/man/io_uring_sqring_wait.3
···22.\"
33.\" SPDX-License-Identifier: LGPL-2.0-or-later
44.\"
55-.TH io_uring_sqring_wait "January 25, 2022" "liburing-2.1" "liburing Manual"
55+.TH io_uring_sqring_wait 3 "January 25, 2022" "liburing-2.1" "liburing Manual"
66.SH NAME
77io_uring_sqring_wait \- wait for free space in the SQ ring
88.SH SYNOPSIS
···11+.\" Copyright (C), 2022 dylany
22+.\" You may distribute this file under the terms of the GNU Free
33+.\" Documentation License.
44+.TH io_uring_submit_and_get_events 3 "September 5, 2022" "liburing-2.3" "liburing Manual"
55+.SH NAME
66+io_uring_submit_and_get_events \- submit requests to the submission queue and flush completions
77+.SH SYNOPSIS
88+.nf
99+.B #include <liburing.h>
1010+.PP
1111+.BI "int io_uring_submit_and_get_events(struct io_uring *" ring ");"
1212+.fi
1313+1414+.SH DESCRIPTION
1515+The
1616+.BR io_uring_submit_and_get_events (3)
1717+function submits the next events to the submission queue as with
1818+.BR io_uring_submit (3) .
1919+After submission it will flush CQEs as with
2020+.BR io_uring_get_events (3) .
2121+2222+The benefit of this function is that it does both with only one system call.
2323+2424+.SH RETURN VALUE
2525+On success
2626+.BR io_uring_submit_and_get_events (3)
2727+returns the number of submitted submission queue entries. On failure it returns
2828+.BR -errno .
2929+.SH SEE ALSO
3030+.BR io_uring_submit (3),
3131+.BR io_uring_get_events (3)
+1-1
vendor/liburing/man/io_uring_submit_and_wait.3
···1616.PP
1717The
1818.BR io_uring_submit_and_wait (3)
1919-function submits the next events to the submission queue belonging to the
1919+function submits the next requests from the submission queue belonging to the
2020.I ring
2121and waits for
2222.I wait_nr
···2020.PP
2121The
2222.BR io_uring_submit_and_wait_timeout (3)
2323-function submits the next events to the submission queue belonging to the
2323+function submits the next requests from the submission queue belonging to the
2424.I ring
2525and waits for
2626.I wait_nr
2727-completion events or until the timeout
2727+completion events, or until the timeout
2828.I ts
2929expires. The completion events are stored in the
3030.I cqe_ptr
···4343.BR io_uring_submit_and_wait_timeout (3)
4444returns the number of submitted submission queue entries. On failure it returns
4545.BR -errno .
4646+Note that in earlier versions of the liburing library, the return value was 0
4747+on success.
4648The most common failure case is not receiving a completion within the specified
4749timeout,
4850.B -ETIME
+1-1
vendor/liburing/man/io_uring_wait_cqe.3
···3131.SH RETURN VALUE
3232On success
3333.BR io_uring_wait_cqe (3)
3434-returns 0 and the cqe_ptr parm is filled in. On failure it returns
3434+returns 0 and the cqe_ptr param is filled in. On failure it returns
3535.BR -errno .
3636The return value indicates the result of waiting for a CQE, and it has no
3737relation to the CQE result itself.
+1-1
vendor/liburing/man/io_uring_wait_cqe_nr.3
···3434.SH RETURN VALUE
3535On success
3636.BR io_uring_wait_cqe_nr (3)
3737-returns 0 and the cqe_ptr parm is filled in. On failure it returns
3737+returns 0 and the cqe_ptr param is filled in. On failure it returns
3838.BR -errno .
3939The return value indicates the result of waiting for a CQE, and it has no
4040relation to the CQE result itself.
+1-1
vendor/liburing/man/io_uring_wait_cqe_timeout.3
···4343.SH RETURN VALUE
4444On success
4545.BR io_uring_wait_cqes (3)
4646-returns 0 and the cqe_ptr parm is filled in. On failure it returns
4646+returns 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.
+1-1
vendor/liburing/man/io_uring_wait_cqes.3
···4848.SH RETURN VALUE
4949On success
5050.BR io_uring_wait_cqes (3)
5151-returns 0 and the cqe_ptr parm is filled in. On failure it returns
5151+returns 0 and the cqe_ptr param is filled in. On failure it returns
5252.BR -errno .
5353.SH SEE ALSO
5454.BR io_uring_submit (3),
···11+/* SPDX-License-Identifier: MIT */
22+33+#ifndef LIBURING_ARCH_AARCH64_LIB_H
44+#define LIBURING_ARCH_AARCH64_LIB_H
55+66+#include <elf.h>
77+#include <sys/auxv.h>
88+#include "../../syscall.h"
99+1010+static inline long __get_page_size(void)
1111+{
1212+ Elf64_Off buf[2];
1313+ long ret = 4096;
1414+ int fd;
1515+1616+ fd = __sys_open("/proc/self/auxv", O_RDONLY, 0);
1717+ if (fd < 0)
1818+ return ret;
1919+2020+ while (1) {
2121+ ssize_t x;
2222+2323+ x = __sys_read(fd, buf, sizeof(buf));
2424+ if (x < sizeof(buf))
2525+ break;
2626+2727+ if (buf[0] == AT_PAGESZ) {
2828+ ret = buf[1];
2929+ break;
3030+ }
3131+ }
3232+3333+ __sys_close(fd);
3434+ return ret;
3535+}
3636+3737+static inline long get_page_size(void)
3838+{
3939+ static long cache_val;
4040+4141+ if (cache_val)
4242+ return cache_val;
4343+4444+ cache_val = __get_page_size();
4545+ return cache_val;
4646+}
4747+4848+#endif /* #ifndef LIBURING_ARCH_AARCH64_LIB_H */
-4
vendor/liburing/src/arch/aarch64/syscall.h
···11/* SPDX-License-Identifier: MIT */
2233-#ifndef __INTERNAL__LIBURING_SYSCALL_H
44- #error "This file should be included from src/syscall.h (liburing)"
55-#endif
66-73#ifndef LIBURING_ARCH_AARCH64_SYSCALL_H
84#define LIBURING_ARCH_AARCH64_SYSCALL_H
95
-4
vendor/liburing/src/arch/generic/lib.h
···11/* SPDX-License-Identifier: MIT */
2233-#ifndef __INTERNAL__LIBURING_LIB_H
44- #error "This file should be included from src/lib.h (liburing)"
55-#endif
66-73#ifndef LIBURING_ARCH_GENERIC_LIB_H
84#define LIBURING_ARCH_GENERIC_LIB_H
95
+29-16
vendor/liburing/src/arch/generic/syscall.h
···11/* SPDX-License-Identifier: MIT */
2233-#ifndef __INTERNAL__LIBURING_SYSCALL_H
44- #error "This file should be included from src/syscall.h (liburing)"
55-#endif
66-73#ifndef LIBURING_ARCH_GENERIC_SYSCALL_H
84#define LIBURING_ARCH_GENERIC_SYSCALL_H
951010-static inline int ____sys_io_uring_register(int fd, unsigned opcode,
1111- const void *arg, unsigned nr_args)
66+#include <fcntl.h>
77+88+static inline int __sys_io_uring_register(unsigned int fd, unsigned int opcode,
99+ const void *arg, unsigned int nr_args)
1210{
1311 int ret;
1412 ret = syscall(__NR_io_uring_register, fd, opcode, arg, nr_args);
1513 return (ret < 0) ? -errno : ret;
1614}
17151818-static inline int ____sys_io_uring_setup(unsigned entries,
1919- struct io_uring_params *p)
1616+static inline int __sys_io_uring_setup(unsigned int entries,
1717+ struct io_uring_params *p)
2018{
2119 int ret;
2220 ret = syscall(__NR_io_uring_setup, entries, p);
2321 return (ret < 0) ? -errno : ret;
2422}
25232626-static inline int ____sys_io_uring_enter2(int fd, unsigned to_submit,
2727- unsigned min_complete, unsigned flags,
2828- sigset_t *sig, int sz)
2424+static inline int __sys_io_uring_enter2(unsigned int fd, unsigned int to_submit,
2525+ unsigned int min_complete,
2626+ unsigned int flags, sigset_t *sig,
2727+ size_t sz)
2928{
3029 int ret;
3130 ret = syscall(__NR_io_uring_enter, fd, to_submit, min_complete, flags,
···3332 return (ret < 0) ? -errno : ret;
3433}
35343636-static inline int ____sys_io_uring_enter(int fd, unsigned to_submit,
3737- unsigned min_complete, unsigned flags,
3838- sigset_t *sig)
3535+static inline int __sys_io_uring_enter(unsigned int fd, unsigned int to_submit,
3636+ unsigned int min_complete,
3737+ unsigned int flags, sigset_t *sig)
3938{
4040- return ____sys_io_uring_enter2(fd, to_submit, min_complete, flags, sig,
4141- _NSIG / 8);
3939+ return __sys_io_uring_enter2(fd, to_submit, min_complete, flags, sig,
4040+ _NSIG / 8);
4141+}
4242+4343+static inline int __sys_open(const char *pathname, int flags, mode_t mode)
4444+{
4545+ int ret;
4646+ ret = open(pathname, flags, mode);
4747+ return (ret < 0) ? -errno : ret;
4848+}
4949+5050+static inline ssize_t __sys_read(int fd, void *buffer, size_t size)
5151+{
5252+ ssize_t ret;
5353+ ret = read(fd, buffer, size);
5454+ return (ret < 0) ? -errno : ret;
4255}
43564457static inline void *__sys_mmap(void *addr, size_t length, int prot, int flags,
+33-13
vendor/liburing/src/arch/syscall-defs.h
···33#ifndef LIBURING_ARCH_SYSCALL_DEFS_H
44#define LIBURING_ARCH_SYSCALL_DEFS_H
5566+#include <fcntl.h>
77+88+static inline int __sys_open(const char *pathname, int flags, mode_t mode)
99+{
1010+ /*
1111+ * Some architectures don't have __NR_open, but __NR_openat.
1212+ */
1313+#ifdef __NR_open
1414+ return (int) __do_syscall3(__NR_open, pathname, flags, mode);
1515+#else
1616+ return (int) __do_syscall4(__NR_openat, AT_FDCWD, pathname, flags, mode);
1717+#endif
1818+}
1919+2020+static inline ssize_t __sys_read(int fd, void *buffer, size_t size)
2121+{
2222+ return (ssize_t) __do_syscall3(__NR_read, fd, buffer, size);
2323+}
2424+625static inline void *__sys_mmap(void *addr, size_t length, int prot, int flags,
726 int fd, off_t offset)
827{
928 int nr;
10291111-#if defined(__i386__)
3030+#if defined(__NR_mmap2)
1231 nr = __NR_mmap2;
1332 offset >>= 12;
1433#else
···4261 return (int) __do_syscall1(__NR_close, fd);
4362}
44634545-static inline int ____sys_io_uring_register(int fd, unsigned opcode,
4646- const void *arg, unsigned nr_args)
6464+static inline int __sys_io_uring_register(unsigned int fd, unsigned int opcode,
6565+ const void *arg, unsigned int nr_args)
4766{
4867 return (int) __do_syscall4(__NR_io_uring_register, fd, opcode, arg,
4968 nr_args);
5069}
51705252-static inline int ____sys_io_uring_setup(unsigned entries,
5353- struct io_uring_params *p)
7171+static inline int __sys_io_uring_setup(unsigned int entries,
7272+ struct io_uring_params *p)
5473{
5574 return (int) __do_syscall2(__NR_io_uring_setup, entries, p);
5675}
57765858-static inline int ____sys_io_uring_enter2(int fd, unsigned to_submit,
5959- unsigned min_complete, unsigned flags,
6060- sigset_t *sig, int sz)
7777+static inline int __sys_io_uring_enter2(unsigned int fd, unsigned int to_submit,
7878+ unsigned int min_complete,
7979+ unsigned int flags, sigset_t *sig,
8080+ size_t sz)
6181{
6282 return (int) __do_syscall6(__NR_io_uring_enter, fd, to_submit,
6383 min_complete, flags, sig, sz);
6484}
65856666-static inline int ____sys_io_uring_enter(int fd, unsigned to_submit,
6767- unsigned min_complete, unsigned flags,
6868- sigset_t *sig)
8686+static inline int __sys_io_uring_enter(unsigned int fd, unsigned int to_submit,
8787+ unsigned int min_complete,
8888+ unsigned int flags, sigset_t *sig)
6989{
7070- return ____sys_io_uring_enter2(fd, to_submit, min_complete, flags, sig,
7171- _NSIG / 8);
9090+ return __sys_io_uring_enter2(fd, to_submit, min_complete, flags, sig,
9191+ _NSIG / 8);
7292}
73937494#endif
-4
vendor/liburing/src/arch/x86/lib.h
···11/* SPDX-License-Identifier: MIT */
2233-#ifndef __INTERNAL__LIBURING_LIB_H
44- #error "This file should be included from src/lib.h (liburing)"
55-#endif
66-73#ifndef LIBURING_ARCH_X86_LIB_H
84#define LIBURING_ARCH_X86_LIB_H
95
-4
vendor/liburing/src/arch/x86/syscall.h
···11/* SPDX-License-Identifier: MIT */
2233-#ifndef __INTERNAL__LIBURING_SYSCALL_H
44- #error "This file should be included from src/syscall.h (liburing)"
55-#endif
66-73#ifndef LIBURING_ARCH_X86_SYSCALL_H
84#define LIBURING_ARCH_X86_SYSCALL_H
95
···11+// SPDX-License-Identifier: MIT
22+33+#include <errno.h>
44+#include <stdio.h>
55+#include <stdlib.h>
66+#include <string.h>
77+#include <unistd.h>
88+#include <arpa/inet.h>
99+#include <sys/types.h>
1010+#include <sys/socket.h>
1111+#include <pthread.h>
1212+1313+#include "liburing.h"
1414+#include "helpers.h"
1515+1616+#define ENORECVMULTISHOT 9999
1717+1818+enum early_error_t {
1919+ ERROR_NONE = 0,
2020+ ERROR_NOT_ENOUGH_BUFFERS,
2121+ ERROR_EARLY_CLOSE_SENDER,
2222+ ERROR_EARLY_CLOSE_RECEIVER,
2323+ ERROR_EARLY_OVERFLOW,
2424+ ERROR_EARLY_LAST
2525+};
2626+2727+struct args {
2828+ bool stream;
2929+ bool wait_each;
3030+ bool recvmsg;
3131+ enum early_error_t early_error;
3232+ bool defer;
3333+};
3434+3535+static int check_sockaddr(struct sockaddr_in *in)
3636+{
3737+ struct in_addr expected;
3838+3939+ inet_pton(AF_INET, "127.0.0.1", &expected);
4040+ if (in->sin_family != AF_INET) {
4141+ fprintf(stderr, "bad family %d\n", (int)htons(in->sin_family));
4242+ return -1;
4343+ }
4444+ if (memcmp(&expected, &in->sin_addr, sizeof(in->sin_addr))) {
4545+ char buff[256];
4646+ const char *addr = inet_ntop(AF_INET, &in->sin_addr, buff, sizeof(buff));
4747+4848+ fprintf(stderr, "unexpected address %s\n", addr ? addr : "INVALID");
4949+ return -1;
5050+ }
5151+ return 0;
5252+}
5353+5454+static int test(struct args *args)
5555+{
5656+ int const N = 8;
5757+ int const N_BUFFS = N * 64;
5858+ int const N_CQE_OVERFLOW = 4;
5959+ int const min_cqes = 2;
6060+ int const NAME_LEN = sizeof(struct sockaddr_storage);
6161+ int const CONTROL_LEN = CMSG_ALIGN(sizeof(struct sockaddr_storage))
6262+ + sizeof(struct cmsghdr);
6363+ struct io_uring ring;
6464+ struct io_uring_cqe *cqe;
6565+ struct io_uring_sqe *sqe;
6666+ int fds[2], ret, i, j;
6767+ int total_sent_bytes = 0, total_recv_bytes = 0, total_dropped_bytes = 0;
6868+ int send_buff[256];
6969+ int *sent_buffs[N_BUFFS];
7070+ int *recv_buffs[N_BUFFS];
7171+ int *at;
7272+ struct io_uring_cqe recv_cqe[N_BUFFS];
7373+ int recv_cqes = 0;
7474+ bool early_error = false;
7575+ bool early_error_started = false;
7676+ struct __kernel_timespec timeout = {
7777+ .tv_sec = 1,
7878+ };
7979+ struct msghdr msg;
8080+ struct io_uring_params params = { };
8181+ int n_sqe = 32;
8282+8383+ memset(recv_buffs, 0, sizeof(recv_buffs));
8484+8585+ if (args->defer)
8686+ params.flags |= IORING_SETUP_SINGLE_ISSUER |
8787+ IORING_SETUP_DEFER_TASKRUN;
8888+8989+ if (args->early_error == ERROR_EARLY_OVERFLOW) {
9090+ params.flags |= IORING_SETUP_CQSIZE;
9191+ params.cq_entries = N_CQE_OVERFLOW;
9292+ n_sqe = N_CQE_OVERFLOW;
9393+ }
9494+9595+ ret = io_uring_queue_init_params(n_sqe, &ring, ¶ms);
9696+ if (ret) {
9797+ fprintf(stderr, "queue init failed: %d\n", ret);
9898+ return ret;
9999+ }
100100+101101+ ret = t_create_socket_pair(fds, args->stream);
102102+ if (ret) {
103103+ fprintf(stderr, "t_create_socket_pair failed: %d\n", ret);
104104+ return ret;
105105+ }
106106+107107+ if (!args->stream) {
108108+ bool val = true;
109109+110110+ /* force some cmsgs to come back to us */
111111+ ret = setsockopt(fds[0], IPPROTO_IP, IP_RECVORIGDSTADDR, &val,
112112+ sizeof(val));
113113+ if (ret) {
114114+ fprintf(stderr, "setsockopt failed %d\n", errno);
115115+ goto cleanup;
116116+ }
117117+ }
118118+119119+ for (i = 0; i < ARRAY_SIZE(send_buff); i++)
120120+ send_buff[i] = i;
121121+122122+ for (i = 0; i < ARRAY_SIZE(recv_buffs); i++) {
123123+ /* prepare some different sized buffers */
124124+ int buffer_size = (i % 2 == 0 && (args->stream || args->recvmsg)) ? 1 : N;
125125+126126+ buffer_size *= sizeof(int);
127127+ if (args->recvmsg) {
128128+ buffer_size +=
129129+ sizeof(struct io_uring_recvmsg_out) +
130130+ NAME_LEN +
131131+ CONTROL_LEN;
132132+ }
133133+134134+ recv_buffs[i] = malloc(buffer_size);
135135+136136+ if (i > 2 && args->early_error == ERROR_NOT_ENOUGH_BUFFERS)
137137+ continue;
138138+139139+ sqe = io_uring_get_sqe(&ring);
140140+ io_uring_prep_provide_buffers(sqe, recv_buffs[i],
141141+ buffer_size, 1, 7, i);
142142+ io_uring_sqe_set_data64(sqe, 0x999);
143143+ memset(recv_buffs[i], 0xcc, buffer_size);
144144+ if (io_uring_submit_and_wait_timeout(&ring, &cqe, 1, &timeout, NULL) < 0) {
145145+ fprintf(stderr, "provide buffers failed: %d\n", ret);
146146+ ret = -1;
147147+ goto cleanup;
148148+ }
149149+ io_uring_cqe_seen(&ring, cqe);
150150+ }
151151+152152+ sqe = io_uring_get_sqe(&ring);
153153+ if (args->recvmsg) {
154154+ unsigned int flags = 0;
155155+156156+ if (!args->stream)
157157+ flags |= MSG_TRUNC;
158158+159159+ memset(&msg, 0, sizeof(msg));
160160+ msg.msg_namelen = NAME_LEN;
161161+ msg.msg_controllen = CONTROL_LEN;
162162+ io_uring_prep_recvmsg_multishot(sqe, fds[0], &msg, flags);
163163+ } else {
164164+ io_uring_prep_recv_multishot(sqe, fds[0], NULL, 0, 0);
165165+ }
166166+ sqe->flags |= IOSQE_BUFFER_SELECT;
167167+ sqe->buf_group = 7;
168168+ io_uring_sqe_set_data64(sqe, 1234);
169169+ io_uring_submit(&ring);
170170+171171+ at = &send_buff[0];
172172+ total_sent_bytes = 0;
173173+ for (i = 0; i < N; i++) {
174174+ int to_send = sizeof(*at) * (i+1);
175175+176176+ total_sent_bytes += to_send;
177177+ sent_buffs[i] = at;
178178+ if (send(fds[1], at, to_send, 0) != to_send) {
179179+ if (early_error_started)
180180+ break;
181181+ fprintf(stderr, "send failed %d\n", errno);
182182+ ret = -1;
183183+ goto cleanup;
184184+ }
185185+186186+ if (i == 2) {
187187+ if (args->early_error == ERROR_EARLY_CLOSE_RECEIVER) {
188188+ /* allow previous sends to complete */
189189+ usleep(1000);
190190+ io_uring_get_events(&ring);
191191+192192+ sqe = io_uring_get_sqe(&ring);
193193+ io_uring_prep_recv(sqe, fds[0], NULL, 0, 0);
194194+ io_uring_prep_cancel64(sqe, 1234, 0);
195195+ io_uring_sqe_set_data64(sqe, 0x888);
196196+ sqe->flags |= IOSQE_CQE_SKIP_SUCCESS;
197197+ io_uring_submit(&ring);
198198+ early_error_started = true;
199199+200200+ /* allow the cancel to complete */
201201+ usleep(1000);
202202+ io_uring_get_events(&ring);
203203+ }
204204+ if (args->early_error == ERROR_EARLY_CLOSE_SENDER) {
205205+ early_error_started = true;
206206+ shutdown(fds[1], SHUT_RDWR);
207207+ close(fds[1]);
208208+ }
209209+ }
210210+ at += (i+1);
211211+212212+ if (args->wait_each) {
213213+ ret = io_uring_wait_cqes(&ring, &cqe, 1, &timeout, NULL);
214214+ if (ret) {
215215+ fprintf(stderr, "wait_each failed: %d\n", ret);
216216+ ret = -1;
217217+ goto cleanup;
218218+ }
219219+ while (io_uring_peek_cqe(&ring, &cqe) == 0) {
220220+ recv_cqe[recv_cqes++] = *cqe;
221221+ if (cqe->flags & IORING_CQE_F_MORE) {
222222+ io_uring_cqe_seen(&ring, cqe);
223223+ } else {
224224+ early_error = true;
225225+ io_uring_cqe_seen(&ring, cqe);
226226+ }
227227+ }
228228+ if (early_error)
229229+ break;
230230+ }
231231+ }
232232+233233+ close(fds[1]);
234234+235235+ /* allow sends to finish */
236236+ usleep(1000);
237237+238238+ if ((args->stream && !early_error) || recv_cqes < min_cqes) {
239239+ ret = io_uring_wait_cqes(&ring, &cqe, 1, &timeout, NULL);
240240+ if (ret && ret != -ETIME) {
241241+ fprintf(stderr, "wait final failed: %d\n", ret);
242242+ ret = -1;
243243+ goto cleanup;
244244+ }
245245+ }
246246+247247+ while (io_uring_peek_cqe(&ring, &cqe) == 0) {
248248+ recv_cqe[recv_cqes++] = *cqe;
249249+ io_uring_cqe_seen(&ring, cqe);
250250+ }
251251+252252+ ret = -1;
253253+ at = &send_buff[0];
254254+ if (recv_cqes < min_cqes) {
255255+ if (recv_cqes > 0 && recv_cqe[0].res == -EINVAL) {
256256+ return -ENORECVMULTISHOT;
257257+ }
258258+ /* some kernels apparently don't check ->ioprio, skip */
259259+ ret = -ENORECVMULTISHOT;
260260+ goto cleanup;
261261+ }
262262+ for (i = 0; i < recv_cqes; i++) {
263263+ cqe = &recv_cqe[i];
264264+265265+ bool const is_last = i == recv_cqes - 1;
266266+267267+ bool const should_be_last =
268268+ (cqe->res <= 0) ||
269269+ (args->stream && is_last) ||
270270+ (args->early_error == ERROR_EARLY_OVERFLOW &&
271271+ !args->wait_each && i == N_CQE_OVERFLOW);
272272+ int *this_recv;
273273+ int orig_payload_size = cqe->res;
274274+275275+276276+ if (should_be_last) {
277277+ int used_res = cqe->res;
278278+279279+ if (!is_last) {
280280+ fprintf(stderr, "not last cqe had error %d\n", i);
281281+ goto cleanup;
282282+ }
283283+284284+ switch (args->early_error) {
285285+ case ERROR_NOT_ENOUGH_BUFFERS:
286286+ if (cqe->res != -ENOBUFS) {
287287+ fprintf(stderr,
288288+ "ERROR_NOT_ENOUGH_BUFFERS: res %d\n", cqe->res);
289289+ goto cleanup;
290290+ }
291291+ break;
292292+ case ERROR_EARLY_OVERFLOW:
293293+ if (cqe->res < 0) {
294294+ fprintf(stderr,
295295+ "ERROR_EARLY_OVERFLOW: res %d\n", cqe->res);
296296+ goto cleanup;
297297+ }
298298+ break;
299299+ case ERROR_EARLY_CLOSE_RECEIVER:
300300+ if (cqe->res != -ECANCELED) {
301301+ fprintf(stderr,
302302+ "ERROR_EARLY_CLOSE_RECEIVER: res %d\n", cqe->res);
303303+ goto cleanup;
304304+ }
305305+ break;
306306+ case ERROR_NONE:
307307+ case ERROR_EARLY_CLOSE_SENDER:
308308+ if (args->recvmsg && (cqe->flags & IORING_CQE_F_BUFFER)) {
309309+ void *buff = recv_buffs[cqe->flags >> 16];
310310+ struct io_uring_recvmsg_out *o =
311311+ io_uring_recvmsg_validate(buff, cqe->res, &msg);
312312+313313+ if (!o) {
314314+ fprintf(stderr, "invalid buff\n");
315315+ goto cleanup;
316316+ }
317317+ if (o->payloadlen != 0) {
318318+ fprintf(stderr, "expected 0 payloadlen, got %u\n",
319319+ o->payloadlen);
320320+ goto cleanup;
321321+ }
322322+ used_res = 0;
323323+ } else if (cqe->res != 0) {
324324+ fprintf(stderr, "early error: res %d\n", cqe->res);
325325+ goto cleanup;
326326+ }
327327+ break;
328328+ case ERROR_EARLY_LAST:
329329+ fprintf(stderr, "bad error_early\n");
330330+ goto cleanup;
331331+ };
332332+333333+ if (cqe->res <= 0 && cqe->flags & IORING_CQE_F_BUFFER) {
334334+ fprintf(stderr, "final BUFFER flag set\n");
335335+ goto cleanup;
336336+ }
337337+338338+ if (cqe->flags & IORING_CQE_F_MORE) {
339339+ fprintf(stderr, "final MORE flag set\n");
340340+ goto cleanup;
341341+ }
342342+343343+ if (used_res <= 0)
344344+ continue;
345345+ } else {
346346+ if (!(cqe->flags & IORING_CQE_F_MORE)) {
347347+ fprintf(stderr, "MORE flag not set\n");
348348+ goto cleanup;
349349+ }
350350+ }
351351+352352+ if (!(cqe->flags & IORING_CQE_F_BUFFER)) {
353353+ fprintf(stderr, "BUFFER flag not set\n");
354354+ goto cleanup;
355355+ }
356356+357357+ this_recv = recv_buffs[cqe->flags >> 16];
358358+359359+ if (args->recvmsg) {
360360+ struct io_uring_recvmsg_out *o = io_uring_recvmsg_validate(
361361+ this_recv, cqe->res, &msg);
362362+363363+ if (!o) {
364364+ fprintf(stderr, "bad recvmsg\n");
365365+ goto cleanup;
366366+ }
367367+ orig_payload_size = o->payloadlen;
368368+369369+ if (!args->stream) {
370370+ orig_payload_size = o->payloadlen;
371371+372372+ struct cmsghdr *cmsg;
373373+374374+ if (o->namelen < sizeof(struct sockaddr_in)) {
375375+ fprintf(stderr, "bad addr len %d",
376376+ o->namelen);
377377+ goto cleanup;
378378+ }
379379+ if (check_sockaddr((struct sockaddr_in *)io_uring_recvmsg_name(o)))
380380+ goto cleanup;
381381+382382+ cmsg = io_uring_recvmsg_cmsg_firsthdr(o, &msg);
383383+ if (!cmsg ||
384384+ cmsg->cmsg_level != IPPROTO_IP ||
385385+ cmsg->cmsg_type != IP_RECVORIGDSTADDR) {
386386+ fprintf(stderr, "bad cmsg");
387387+ goto cleanup;
388388+ }
389389+ if (check_sockaddr((struct sockaddr_in *)CMSG_DATA(cmsg)))
390390+ goto cleanup;
391391+ cmsg = io_uring_recvmsg_cmsg_nexthdr(o, &msg, cmsg);
392392+ if (cmsg) {
393393+ fprintf(stderr, "unexpected extra cmsg\n");
394394+ goto cleanup;
395395+ }
396396+397397+ }
398398+399399+ this_recv = (int *)io_uring_recvmsg_payload(o, &msg);
400400+ cqe->res = io_uring_recvmsg_payload_length(o, cqe->res, &msg);
401401+ if (o->payloadlen != cqe->res) {
402402+ if (!(o->flags & MSG_TRUNC)) {
403403+ fprintf(stderr, "expected truncated flag\n");
404404+ goto cleanup;
405405+ }
406406+ total_dropped_bytes += (o->payloadlen - cqe->res);
407407+ }
408408+ }
409409+410410+ total_recv_bytes += cqe->res;
411411+412412+ if (cqe->res % 4 != 0) {
413413+ /*
414414+ * doesn't seem to happen in practice, would need some
415415+ * work to remove this requirement
416416+ */
417417+ fprintf(stderr, "unexpectedly aligned buffer cqe->res=%d\n", cqe->res);
418418+ goto cleanup;
419419+ }
420420+421421+ /*
422422+ * for tcp: check buffer arrived in order
423423+ * for udp: based on size validate data based on size
424424+ */
425425+ if (!args->stream) {
426426+ int sent_idx = orig_payload_size / sizeof(*at) - 1;
427427+428428+ if (sent_idx < 0 || sent_idx > N) {
429429+ fprintf(stderr, "Bad sent idx: %d\n", sent_idx);
430430+ goto cleanup;
431431+ }
432432+ at = sent_buffs[sent_idx];
433433+ }
434434+ for (j = 0; j < cqe->res / 4; j++) {
435435+ int sent = *at++;
436436+ int recv = *this_recv++;
437437+438438+ if (sent != recv) {
439439+ fprintf(stderr, "recv=%d sent=%d\n", recv, sent);
440440+ goto cleanup;
441441+ }
442442+ }
443443+ }
444444+445445+ if (args->early_error == ERROR_NONE &&
446446+ total_recv_bytes + total_dropped_bytes < total_sent_bytes) {
447447+ fprintf(stderr,
448448+ "missing recv: recv=%d dropped=%d sent=%d\n",
449449+ total_recv_bytes, total_sent_bytes, total_dropped_bytes);
450450+ goto cleanup;
451451+ }
452452+453453+ ret = 0;
454454+cleanup:
455455+ for (i = 0; i < ARRAY_SIZE(recv_buffs); i++)
456456+ free(recv_buffs[i]);
457457+ close(fds[0]);
458458+ close(fds[1]);
459459+ io_uring_queue_exit(&ring);
460460+461461+ return ret;
462462+}
463463+464464+int main(int argc, char *argv[])
465465+{
466466+ int ret;
467467+ int loop;
468468+ int early_error = 0;
469469+ bool has_defer;
470470+471471+ if (argc > 1)
472472+ return T_EXIT_SKIP;
473473+474474+ has_defer = t_probe_defer_taskrun();
475475+476476+ for (loop = 0; loop < 16; loop++) {
477477+ struct args a = {
478478+ .stream = loop & 0x01,
479479+ .wait_each = loop & 0x2,
480480+ .recvmsg = loop & 0x04,
481481+ .defer = loop & 0x08,
482482+ };
483483+ if (a.defer && !has_defer)
484484+ continue;
485485+ for (early_error = 0; early_error < ERROR_EARLY_LAST; early_error++) {
486486+ a.early_error = (enum early_error_t)early_error;
487487+ ret = test(&a);
488488+ if (ret) {
489489+ if (ret == -ENORECVMULTISHOT) {
490490+ if (loop == 0)
491491+ return T_EXIT_SKIP;
492492+ fprintf(stderr,
493493+ "ENORECVMULTISHOT received but loop>0\n");
494494+ }
495495+ fprintf(stderr,
496496+ "test stream=%d wait_each=%d recvmsg=%d early_error=%d "
497497+ " defer=%d failed\n",
498498+ a.stream, a.wait_each, a.recvmsg, a.early_error, a.defer);
499499+ return T_EXIT_FAIL;
500500+ }
501501+ }
502502+ }
503503+504504+ return T_EXIT_PASS;
505505+}
+13
vendor/liburing/test/ring-leak.c
···135135 return 0;
136136}
137137138138+static void trigger_unix_gc(void)
139139+{
140140+ int fd;
141141+142142+ fd = socket(AF_UNIX, SOCK_DGRAM, 0);
143143+ if (fd < 0)
144144+ perror("socket dgram");
145145+ else
146146+ close(fd);
147147+}
148148+138149static int test_scm_cycles(bool update)
139150{
140151 char buffer[128];
···192203193204 /* should unregister files and close the write fd */
194205 io_uring_queue_exit(&ring);
206206+207207+ trigger_unix_gc();
195208196209 /*
197210 * We're trying to wait for the ring to "really" exit, that will be
+12-7
vendor/liburing/test/ringbuf-read.c
···156156 ret = write(fd, buf, BUF_SIZE);
157157 if (ret != BUF_SIZE) {
158158 fprintf(stderr, "bad file prep write\n");
159159+ close(fd);
159160 goto err;
160161 }
161162 }
···164165 ret = test(fname, 1, 0);
165166 if (ret) {
166167 fprintf(stderr, "dio test failed\n");
167167- return ret;
168168+ goto err;
168169 }
169170 if (no_buf_ring)
170170- return 0;
171171+ goto pass;
171172172173 ret = test(fname, 0, 0);
173174 if (ret) {
174175 fprintf(stderr, "buffered test failed\n");
175175- return ret;
176176+ goto err;
176177 }
177178178179 ret = test(fname, 1, 1);
179180 if (ret) {
180181 fprintf(stderr, "dio async test failed\n");
181181- return ret;
182182+ goto err;
182183 }
183184184185 ret = test(fname, 0, 1);
185186 if (ret) {
186187 fprintf(stderr, "buffered async test failed\n");
187187- return ret;
188188+ goto err;
188189 }
189190190190- return 0;
191191+pass:
192192+ ret = T_EXIT_PASS;
193193+ goto out;
191194err:
195195+ ret = T_EXIT_FAIL;
196196+out:
192197 if (do_unlink)
193198 unlink(fname);
194194- return 1;
199199+ return ret;
195200}
+24-12
vendor/liburing/test/rsrc_tags.c
···4040 const void *arg, const __u64 *tags)
4141{
4242 struct io_uring_rsrc_register reg;
4343- int ret, reg_type;
4343+ int reg_type;
44444545 memset(®, 0, sizeof(reg));
4646 reg.nr = nr;
···5151 if (type != TEST_IORING_RSRC_FILE)
5252 reg_type = IORING_REGISTER_BUFFERS2;
53535454- ret = __sys_io_uring_register(ring->ring_fd, reg_type,
5555- ®, sizeof(reg));
5656- return ret ? -errno : 0;
5454+ return __sys_io_uring_register(ring->ring_fd, reg_type, ®,
5555+ sizeof(reg));
5756}
58575958/*
···6463 const void *arg, const __u64 *tags)
6564{
6665 struct io_uring_rsrc_update2 up;
6767- int ret, up_type;
6666+ int up_type;
68676968 memset(&up, 0, sizeof(up));
7069 up.offset = off;
···7574 up_type = IORING_REGISTER_FILES_UPDATE2;
7675 if (type != TEST_IORING_RSRC_FILE)
7776 up_type = IORING_REGISTER_BUFFERS_UPDATE;
7878- ret = __sys_io_uring_register(ring->ring_fd, up_type,
7979- &up, sizeof(up));
8080- return ret < 0 ? -errno : ret;
7777+ return __sys_io_uring_register(ring->ring_fd, up_type, &up, sizeof(up));
8178}
82798380static bool has_rsrc_update(void)
···185182 return 1;
186183 }
187184188188- /* test that CQE is not emmited before we're done with a buffer */
185185+ /* test that CQE is not emitted before we're done with a buffer */
189186 sqe = io_uring_get_sqe(&ring);
190187 io_uring_prep_read_fixed(sqe, pipes[0], tmp_buf, 10, 0, 0);
191188 sqe->user_data = 100;
···350347 ret = io_uring_register_files_update(&ring, off, &fd, 1);
351348 assert(ret == 1);
352349 ret = io_uring_wait_cqe(&ring, &cqe);
353353- assert(!ret && cqe->user_data == tags[off]);
350350+ if (ret) {
351351+ fprintf(stderr, "io_uring wait ret=%d\n", ret);
352352+ return 1;
353353+ }
354354+ if (cqe->user_data != tags[off]) {
355355+ fprintf(stderr, "data %lx != %lx\n",
356356+ (unsigned long) cqe->user_data,
357357+ (unsigned long) tags[off]);
358358+ return 1;
359359+ }
354360 io_uring_cqe_seen(&ring, cqe);
355361356362 /* remove removed file, shouldn't emit old tag */
···404410405411int main(int argc, char *argv[])
406412{
407407- int ring_flags[] = {0, IORING_SETUP_IOPOLL, IORING_SETUP_SQPOLL};
413413+ int ring_flags[] = {0, IORING_SETUP_IOPOLL, IORING_SETUP_SQPOLL,
414414+ IORING_SETUP_SINGLE_ISSUER | IORING_SETUP_DEFER_TASKRUN};
408415 int i, ret;
409416410417 if (argc > 1)
···426433 }
427434428435 for (i = 0; i < sizeof(ring_flags) / sizeof(ring_flags[0]); i++) {
429429- ret = test_files(ring_flags[i]);
436436+ int flag = ring_flags[i];
437437+438438+ if (flag & IORING_SETUP_DEFER_TASKRUN && !t_probe_defer_taskrun())
439439+ continue;
440440+441441+ ret = test_files(flag);
430442 if (ret) {
431443 printf("test_tag failed, type %i\n", i);
432444 return ret;
+17-19
vendor/liburing/test/runtests.sh
···11#!/usr/bin/env bash
2233TESTS=("$@")
44-RET=0
54TIMEOUT=60
65DMESG_FILTER="cat"
76TEST_DIR=$(dirname "$0")
88-FAILED=""
99-SKIPPED=""
1010-TIMED_OUT=""
77+FAILED=()
88+SKIPPED=()
99+TIMED_OUT=()
1110TEST_FILES=""
1211declare -A TEST_MAP
1312···9493 # shellcheck disable=SC2181
9594 if [ $? -eq 0 ]; then
9695 echo "Test skipped"
9797- SKIPPED="$SKIPPED <$test_string>"
9696+ SKIPPED+=("<$test_string>")
9897 return
9998 fi
10099···111110 # Check test status
112111 if [ "$status" -eq 124 ]; then
113112 echo "Test $test_name timed out (may not be a failure)"
114114- TIMED_OUT="$TIMED_OUT <$test_string>"
113113+ TIMED_OUT+=("<$test_string>")
114114+ elif [ "$status" -eq 77 ]; then
115115+ echo "Skipped"
116116+ SKIPPED+=("<$test_string>")
115117 elif [ "$status" -ne 0 ]; then
116118 echo "Test $test_name failed with ret $status"
117117- FAILED="$FAILED <$test_string>"
118118- RET=1
119119+ FAILED+=("<$test_string>")
119120 elif ! _check_dmesg "$dmesg_marker" "$test_name"; then
120121 echo "Test $test_name failed dmesg check"
121121- FAILED="$FAILED <$test_string>"
122122- RET=1
122122+ FAILED+=("<$test_string>")
123123 else
124124 if [ -f "output/$out_name" ]; then
125125 T_PREV=$(cat "output/$out_name")
···153153 fi
154154done
155155156156-if [ -n "$SKIPPED" ]; then
157157- echo "Tests skipped: $SKIPPED"
156156+if [ "${#TIMED_OUT[*]}" -ne 0 ]; then
157157+ echo "Tests timed out (${#TIMED_OUT[*]}): ${TIMED_OUT[*]}"
158158fi
159159160160-if [ -n "$TIMED_OUT" ]; then
161161- echo "Tests timed out: $TIMED_OUT"
162162-fi
163163-164164-if [ "${RET}" -ne 0 ]; then
165165- echo "Tests failed: $FAILED"
166166- exit $RET
160160+if [ "${#FAILED[*]}" -ne 0 ]; then
161161+ echo "Tests failed (${#FAILED[*]}): ${FAILED[*]}"
162162+ exit 1
163163+elif [ "${#SKIPPED[*]}" -ne 0 ] && [ -n "$TEST_GNU_EXITCODE" ]; then
164164+ exit 77
167165else
168166 echo "All tests passed"
169167 exit 0
+1-1
vendor/liburing/test/rw_merge_test.c
···7979 assert(ret == 1);
80808181 /*
8282- * Read may stuck because of bug there request was be incorrecly
8282+ * Read may stuck because of bug there request was be incorrectly
8383 * merged with <REQ1> request
8484 */
8585 ret = io_uring_wait_cqe_timeout(&ring, &cqe, &ts);