diff options
author | robot-contrib <robot-contrib@yandex-team.com> | 2024-09-15 15:23:16 +0300 |
---|---|---|
committer | robot-contrib <robot-contrib@yandex-team.com> | 2024-09-15 15:34:37 +0300 |
commit | 652e26979af322802fc3f9a6fa7800b574e47ae5 (patch) | |
tree | ea8007b370826a47fdf8051b40fb178afcb4f599 /contrib/libs/liburing | |
parent | dbf2aed3f6d5c2cb919f9ace1b876025989f8ab1 (diff) | |
download | ydb-652e26979af322802fc3f9a6fa7800b574e47ae5.tar.gz |
Update contrib/libs/liburing to 2.7
commit_hash:87f3322875a8a40a773f874c3ee2d0a95ce53dbe
Diffstat (limited to 'contrib/libs/liburing')
212 files changed, 2990 insertions, 273 deletions
diff --git a/contrib/libs/liburing/CHANGELOG b/contrib/libs/liburing/CHANGELOG index 0c902312fa..4eb15f38a4 100644 --- a/contrib/libs/liburing/CHANGELOG +++ b/contrib/libs/liburing/CHANGELOG @@ -1,3 +1,23 @@ +liburing-2.7 release + +- Man page updates +- Sync with kernel 6.10 + - send/recv bundle support + - accept nowait and CQE_F_MORE +- Add and update test cases +- Fix io_uring_queue_init_mem() returning a value that was too small, + potentially causing memory corruption in userspace by overwriting + 64 bytes beyond the returned value. Also add test case for that. +- Add 64-bit length variants of io_uring_prep_{m,f}advise() +- Add BIND/LISTEN support and helpers / man pages +- Add io_uring_enable_rings.3 man page +- Fix bug in io_uring_prep_read_multishot() +- Fixup bundle test cases +- Add fixed-hugepage test case +- Fix io_uring_prep_fixed_fd_install.3 man page +- Note 'len' == 0 requirement in io_uring_prep_send.3 man page +- Fix some test cases for skipping on older kernels + liburing-2.6 release - Add getsockopt and setsockopt socket commands diff --git a/contrib/libs/liburing/src/include/liburing.h b/contrib/libs/liburing/src/include/liburing.h index 7d04aec13a..1092f3b10b 100644 --- a/contrib/libs/liburing/src/include/liburing.h +++ b/contrib/libs/liburing/src/include/liburing.h @@ -375,7 +375,7 @@ IOURINGINLINE void __io_uring_set_target_fixed_file(struct io_uring_sqe *sqe, sqe->file_index = file_index + 1; } -IOURINGINLINE void io_uring_initialize_sqe(struct io_uring_sqe *sqe) +IOURINGINLINE void io_uring_initialize_sqe(struct io_uring_sqe *sqe) { sqe->flags = 0; sqe->ioprio = 0; @@ -669,6 +669,19 @@ IOURINGINLINE void io_uring_prep_connect(struct io_uring_sqe *sqe, int fd, io_uring_prep_rw(IORING_OP_CONNECT, sqe, fd, addr, 0, addrlen); } +IOURINGINLINE void io_uring_prep_bind(struct io_uring_sqe *sqe, int fd, + struct sockaddr *addr, + socklen_t addrlen) +{ + io_uring_prep_rw(IORING_OP_BIND, sqe, fd, addr, 0, addrlen); +} + +IOURINGINLINE void io_uring_prep_listen(struct io_uring_sqe *sqe, int fd, + int backlog) +{ + io_uring_prep_rw(IORING_OP_LISTEN, sqe, fd, 0, backlog, 0); +} + IOURINGINLINE void io_uring_prep_files_update(struct io_uring_sqe *sqe, int *fds, unsigned nr_fds, int offset) @@ -731,6 +744,7 @@ IOURINGINLINE void io_uring_prep_read_multishot(struct io_uring_sqe *sqe, io_uring_prep_rw(IORING_OP_READ_MULTISHOT, sqe, fd, NULL, nbytes, offset); sqe->buf_group = buf_group; + sqe->flags = IOSQE_BUFFER_SELECT; } IOURINGINLINE void io_uring_prep_write(struct io_uring_sqe *sqe, int fd, @@ -751,19 +765,34 @@ IOURINGINLINE void io_uring_prep_statx(struct io_uring_sqe *sqe, int dfd, } IOURINGINLINE void io_uring_prep_fadvise(struct io_uring_sqe *sqe, int fd, - __u64 offset, off_t len, int advice) + __u64 offset, __u32 len, int advice) { io_uring_prep_rw(IORING_OP_FADVISE, sqe, fd, NULL, (__u32) len, offset); sqe->fadvise_advice = (__u32) advice; } IOURINGINLINE void io_uring_prep_madvise(struct io_uring_sqe *sqe, void *addr, - off_t length, int advice) + __u32 length, int advice) { io_uring_prep_rw(IORING_OP_MADVISE, sqe, -1, addr, (__u32) length, 0); sqe->fadvise_advice = (__u32) advice; } +IOURINGINLINE void io_uring_prep_fadvise64(struct io_uring_sqe *sqe, int fd, + __u64 offset, off_t len, int advice) +{ + io_uring_prep_rw(IORING_OP_FADVISE, sqe, fd, NULL, 0, offset); + sqe->addr = len; + sqe->fadvise_advice = (__u32) advice; +} + +IOURINGINLINE void io_uring_prep_madvise64(struct io_uring_sqe *sqe, void *addr, + off_t length, int advice) +{ + io_uring_prep_rw(IORING_OP_MADVISE, sqe, -1, addr, 0, length); + sqe->fadvise_advice = (__u32) advice; +} + IOURINGINLINE void io_uring_prep_send(struct io_uring_sqe *sqe, int sockfd, const void *buf, size_t len, int flags) { @@ -771,6 +800,13 @@ IOURINGINLINE void io_uring_prep_send(struct io_uring_sqe *sqe, int sockfd, sqe->msg_flags = (__u32) flags; } +IOURINGINLINE void io_uring_prep_send_bundle(struct io_uring_sqe *sqe, + int sockfd, size_t len, int flags) +{ + io_uring_prep_send(sqe, sockfd, NULL, len, flags); + sqe->ioprio |= IORING_RECVSEND_BUNDLE; +} + IOURINGINLINE void io_uring_prep_send_set_addr(struct io_uring_sqe *sqe, const struct sockaddr *dest_addr, __u16 addr_len) diff --git a/contrib/libs/liburing/src/include/liburing/io_uring.h b/contrib/libs/liburing/src/include/liburing/io_uring.h index bde11991bf..01c36a83f3 100644 --- a/contrib/libs/liburing/src/include/liburing/io_uring.h +++ b/contrib/libs/liburing/src/include/liburing/io_uring.h @@ -72,6 +72,7 @@ struct io_uring_sqe { __u32 waitid_flags; __u32 futex_flags; __u32 install_fd_flags; + __u32 nop_flags; }; __u64 user_data; /* data to be passed back at completion time */ /* pack this to avoid bogus arm OABI complaints */ @@ -256,6 +257,8 @@ enum io_uring_op { IORING_OP_FUTEX_WAITV, IORING_OP_FIXED_FD_INSTALL, IORING_OP_FTRUNCATE, + IORING_OP_BIND, + IORING_OP_LISTEN, /* this goes last, obviously */ IORING_OP_LAST, @@ -314,7 +317,7 @@ enum io_uring_op { * ASYNC_CANCEL flags. * * IORING_ASYNC_CANCEL_ALL Cancel all requests that match the given key - * IORING_ASYNC_CANCEL_FD Key off 'fd' for cancelation rather than the + * IORING_ASYNC_CANCEL_FD Key off 'fd' for cancelation rather than the * request 'user_data' * IORING_ASYNC_CANCEL_ANY Match any request * IORING_ASYNC_CANCEL_FD_FIXED 'fd' passed in is a fixed descriptor @@ -346,11 +349,20 @@ enum io_uring_op { * 0 is reported if zerocopy was actually possible. * IORING_NOTIF_USAGE_ZC_COPIED if data was copied * (at least partially). + * + * IORING_RECVSEND_BUNDLE Used with IOSQE_BUFFER_SELECT. If set, send wil + * grab as many buffers from the buffer group ID + * given and send them all. The completion result + * will be the number of buffers send, with the + * starting buffer ID in cqe->flags as per usual + * for provided buffer usage. The buffers will be + * contigious from the starting buffer ID. */ #define IORING_RECVSEND_POLL_FIRST (1U << 0) #define IORING_RECV_MULTISHOT (1U << 1) #define IORING_RECVSEND_FIXED_BUF (1U << 2) #define IORING_SEND_ZC_REPORT_USAGE (1U << 3) +#define IORING_RECVSEND_BUNDLE (1U << 4) /* * cqe.res for IORING_CQE_F_NOTIF if @@ -365,6 +377,8 @@ enum io_uring_op { * accept flags stored in sqe->ioprio */ #define IORING_ACCEPT_MULTISHOT (1U << 0) +#define IORING_ACCEPT_DONTWAIT (1U << 1) +#define IORING_ACCEPT_POLL_FIRST (1U << 2) /* * IORING_OP_MSG_RING command types, stored in sqe->addr @@ -392,10 +406,17 @@ enum { #define IORING_FIXED_FD_NO_CLOEXEC (1U << 0) /* + * IORING_OP_NOP flags (sqe->nop_flags) + * + * IORING_NOP_INJECT_RESULT Inject result from sqe->result + */ +#define IORING_NOP_INJECT_RESULT (1U << 0) + +/* * IO completion data structure (Completion Queue Entry) */ struct io_uring_cqe { - __u64 user_data; /* sqe->data submission passed back */ + __u64 user_data; /* sqe->user_data value passed back */ __s32 res; /* result code for this event */ __u32 flags; @@ -517,6 +538,7 @@ struct io_uring_params { #define IORING_FEAT_CQE_SKIP (1U << 11) #define IORING_FEAT_LINKED_FILE (1U << 12) #define IORING_FEAT_REG_REG_RING (1U << 13) +#define IORING_FEAT_RECVSEND_BUNDLE (1U << 14) /* * io_uring_register(2) opcodes and arguments diff --git a/contrib/libs/liburing/src/include/liburing/io_uring_version.h b/contrib/libs/liburing/src/include/liburing/io_uring_version.h index 49d8c7ed72..37aba1d0b4 100644 --- a/contrib/libs/liburing/src/include/liburing/io_uring_version.h +++ b/contrib/libs/liburing/src/include/liburing/io_uring_version.h @@ -3,6 +3,6 @@ #define LIBURING_VERSION_H #define IO_URING_VERSION_MAJOR 2 -#define IO_URING_VERSION_MINOR 6 +#define IO_URING_VERSION_MINOR 7 #endif diff --git a/contrib/libs/liburing/src/setup.c b/contrib/libs/liburing/src/setup.c index 0d33f65aae..aa0fcaaaa5 100644 --- a/contrib/libs/liburing/src/setup.c +++ b/contrib/libs/liburing/src/setup.c @@ -200,6 +200,8 @@ __cold int io_uring_ring_dontfork(struct io_uring *ring) /* FIXME */ static size_t huge_page_size = 2 * 1024 * 1024; +#define KRING_SIZE 64 + /* * Returns negative for error, or number of bytes used in the buffer on success */ @@ -209,7 +211,7 @@ static int io_uring_alloc_huge(unsigned entries, struct io_uring_params *p, { unsigned long page_size = get_page_size(); unsigned sq_entries, cq_entries; - size_t ring_mem, sqes_mem; + size_t ring_mem, sqes_mem, cqes_mem; unsigned long mem_used = 0; void *ptr; int ret; @@ -218,14 +220,18 @@ static int io_uring_alloc_huge(unsigned entries, struct io_uring_params *p, if (ret) return ret; + ring_mem = KRING_SIZE; + sqes_mem = sq_entries * sizeof(struct io_uring_sqe); sqes_mem = (sqes_mem + page_size - 1) & ~(page_size - 1); - ring_mem = cq_entries * sizeof(struct io_uring_cqe); - if (p->flags & IORING_SETUP_CQE32) - ring_mem *= 2; if (!(p->flags & IORING_SETUP_NO_SQARRAY)) - ring_mem += sq_entries * sizeof(unsigned); - mem_used = sqes_mem + ring_mem; + sqes_mem += sq_entries * sizeof(unsigned); + + cqes_mem = cq_entries * sizeof(struct io_uring_cqe); + if (p->flags & IORING_SETUP_CQE32) + cqes_mem *= 2; + ring_mem += sqes_mem + cqes_mem; + mem_used = ring_mem; mem_used = (mem_used + page_size - 1) & ~(page_size - 1); /* @@ -499,8 +505,6 @@ static size_t npages(size_t size, long page_size) return __fls((int) size); } -#define KRING_SIZE 320 - static size_t rings_size(struct io_uring_params *p, unsigned entries, unsigned cq_entries, long page_size) { diff --git a/contrib/libs/liburing/test/232c93d07b74.t/ya.make b/contrib/libs/liburing/test/232c93d07b74.t/ya.make index 9872dbc87f..b1d0260eef 100644 --- a/contrib/libs/liburing/test/232c93d07b74.t/ya.make +++ b/contrib/libs/liburing/test/232c93d07b74.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/35fa71a030ca.t/ya.make b/contrib/libs/liburing/test/35fa71a030ca.t/ya.make index 47127daf43..38988d083d 100644 --- a/contrib/libs/liburing/test/35fa71a030ca.t/ya.make +++ b/contrib/libs/liburing/test/35fa71a030ca.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/500f9fbadef8.t/ya.make b/contrib/libs/liburing/test/500f9fbadef8.t/ya.make index 5812da208b..f4f3bdc390 100644 --- a/contrib/libs/liburing/test/500f9fbadef8.t/ya.make +++ b/contrib/libs/liburing/test/500f9fbadef8.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/7ad0e4b2f83c.t/ya.make b/contrib/libs/liburing/test/7ad0e4b2f83c.t/ya.make index 3ca468c7ca..681c052f9f 100644 --- a/contrib/libs/liburing/test/7ad0e4b2f83c.t/ya.make +++ b/contrib/libs/liburing/test/7ad0e4b2f83c.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/8a9973408177.t/ya.make b/contrib/libs/liburing/test/8a9973408177.t/ya.make index 04e50f0af5..fdab64253a 100644 --- a/contrib/libs/liburing/test/8a9973408177.t/ya.make +++ b/contrib/libs/liburing/test/8a9973408177.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/917257daa0fe.t/ya.make b/contrib/libs/liburing/test/917257daa0fe.t/ya.make index 071894eada..b7cf6b187d 100644 --- a/contrib/libs/liburing/test/917257daa0fe.t/ya.make +++ b/contrib/libs/liburing/test/917257daa0fe.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/a0908ae19763.t/ya.make b/contrib/libs/liburing/test/a0908ae19763.t/ya.make index 8be6e50d55..c6aca489f1 100644 --- a/contrib/libs/liburing/test/a0908ae19763.t/ya.make +++ b/contrib/libs/liburing/test/a0908ae19763.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/a4c0b3decb33.t/ya.make b/contrib/libs/liburing/test/a4c0b3decb33.t/ya.make index c0ef350da3..f73ec56c45 100644 --- a/contrib/libs/liburing/test/a4c0b3decb33.t/ya.make +++ b/contrib/libs/liburing/test/a4c0b3decb33.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/accept-link.t/ya.make b/contrib/libs/liburing/test/accept-link.t/ya.make index ac5f9b5c6d..9a7e139107 100644 --- a/contrib/libs/liburing/test/accept-link.t/ya.make +++ b/contrib/libs/liburing/test/accept-link.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/accept-non-empty.c b/contrib/libs/liburing/test/accept-non-empty.c new file mode 100644 index 0000000000..f85f30ca87 --- /dev/null +++ b/contrib/libs/liburing/test/accept-non-empty.c @@ -0,0 +1,257 @@ +#include "../config-host.h" +/* SPDX-License-Identifier: MIT */ +/* + * Check that kernels that support it will return IORING_CQE_F_SOCK_NONEMPTY + * on accepts requests where more connections are pending. + */ +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <assert.h> + +#include <errno.h> +#include <fcntl.h> +#include <unistd.h> +#include <sys/socket.h> +#include <sys/time.h> +#include <sys/resource.h> +#include <sys/un.h> +#include <netinet/tcp.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <pthread.h> + +#include "liburing.h" +#include "helpers.h" + +static int no_more_accept; + +#define MAX_ACCEPTS 8 + +struct data { + pthread_t thread; + pthread_barrier_t barrier; + pthread_barrier_t conn_barrier; + int connects; +}; + +static int start_accept_listen(int port_off, int extra_flags) +{ + struct sockaddr_in addr; + int32_t val = 1; + int fd, ret; + + fd = socket(AF_INET, SOCK_STREAM | extra_flags, IPPROTO_TCP); + + ret = setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &val, sizeof(val)); + assert(ret != -1); + ret = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)); + assert(ret != -1); + + addr.sin_family = AF_INET; + addr.sin_port = htons(0x1235 + port_off); + addr.sin_addr.s_addr = inet_addr("127.0.0.1"); + + ret = bind(fd, (struct sockaddr *) &addr, sizeof(addr)); + assert(ret != -1); + ret = listen(fd, 20000); + assert(ret != -1); + + return fd; +} + +static int test_maccept(struct data *d, int flags, int fixed) +{ + struct io_uring_params p = { }; + struct io_uring ring; + struct io_uring_cqe *cqe; + struct io_uring_sqe *sqe; + int err = 0, fd, ret, i, *fds; + + p.flags = flags; + ret = io_uring_queue_init_params(8, &ring, &p); + if (ret == -EINVAL) { + return T_EXIT_SKIP; + } else if (ret < 0) { + fprintf(stderr, "ring setup failure: %d\n", ret); + return T_EXIT_FAIL; + } + + if (!(p.features & IORING_FEAT_RECVSEND_BUNDLE)) { + no_more_accept = 1; + return 0; + } + + fds = malloc(MAX_ACCEPTS * sizeof(int)); + memset(fds, -1, MAX_ACCEPTS * sizeof(int)); + + if (fixed) { + io_uring_register_ring_fd(&ring); + + ret = io_uring_register_files(&ring, fds, MAX_ACCEPTS); + if (ret) { + fprintf(stderr, "file reg %d\n", ret); + return -1; + } + } + + fd = start_accept_listen(0, 0); + + pthread_barrier_wait(&d->barrier); + + if (d->connects > 1) + pthread_barrier_wait(&d->conn_barrier); + + for (i = 0; i < d->connects; i++) { + sqe = io_uring_get_sqe(&ring); + if (fixed) + io_uring_prep_accept_direct(sqe, fd, NULL, NULL, 0, i); + else + io_uring_prep_accept(sqe, fd, NULL, NULL, 0); + + ret = io_uring_submit_and_wait(&ring, 1); + assert(ret != -1); + + ret = io_uring_wait_cqe(&ring, &cqe); + assert(!ret); + if (cqe->res < 0) { + fprintf(stderr, "res=%d\n", cqe->res); + break; + } + fds[i] = cqe->res; + if (d->connects == 1) { + if (cqe->flags & IORING_CQE_F_SOCK_NONEMPTY) { + fprintf(stderr, "Non-empty sock on single?\n"); + err = 1; + break; + } + } else { + int last = i + 1 == d->connects; + + if (last && cqe->flags & IORING_CQE_F_SOCK_NONEMPTY) { + fprintf(stderr, "Non-empty sock on last?\n"); + err = 1; + break; + } else if (!last && !(cqe->flags & IORING_CQE_F_SOCK_NONEMPTY)) { + fprintf(stderr, "Empty on multi connect?\n"); + err = 1; + break; + } + } + io_uring_cqe_seen(&ring, cqe); + } + + close(fd); + if (!fixed) { + for (i = 0; i < MAX_ACCEPTS; i++) + if (fds[i] != -1) + close(fds[i]); + } + free(fds); + io_uring_queue_exit(&ring); + return err; +} + +static void *connect_fn(void *data) +{ + struct sockaddr_in addr = { }; + struct data *d = data; + int i; + + pthread_barrier_wait(&d->barrier); + + addr.sin_family = AF_INET; + addr.sin_port = htons(0x1235); + addr.sin_addr.s_addr = inet_addr("127.0.0.1"); + + for (i = 0; i < d->connects; i++) { + int s; + + s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + if (s < 0) { + perror("socket"); + break; + } + if (connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) { + perror("connect"); + break; + } + } + + if (d->connects > 1) + pthread_barrier_wait(&d->conn_barrier); + + return NULL; +} + +static void setup_thread(struct data *d, int nconns) +{ + d->connects = nconns; + pthread_barrier_init(&d->barrier, NULL, 2); + pthread_barrier_init(&d->conn_barrier, NULL, 2); + pthread_create(&d->thread, NULL, connect_fn, d); +} + +static int test(int flags, int fixed) +{ + struct data d; + void *tret; + int ret; + + setup_thread(&d, 1); + ret = test_maccept(&d, flags, fixed); + if (ret) { + fprintf(stderr, "test conns=1 failed\n"); + return ret; + } + if (no_more_accept) + return T_EXIT_SKIP; + + pthread_join(d.thread, &tret); + + setup_thread(&d, MAX_ACCEPTS); + ret = test_maccept(&d, flags, fixed); + if (ret) { + fprintf(stderr, "test conns=MAX failed\n"); + return ret; + } + + pthread_join(d.thread, &tret); + return 0; +} + +int main(int argc, char *argv[]) +{ + int ret; + + if (argc > 1) + return T_EXIT_SKIP; + + ret = test(0, 0); + if (no_more_accept) + return T_EXIT_SKIP; + if (ret) { + fprintf(stderr, "test 0 0 failed\n"); + return ret; + } + + ret = test(IORING_SETUP_SINGLE_ISSUER|IORING_SETUP_DEFER_TASKRUN, 0); + if (ret) { + fprintf(stderr, "test DEFER 0 failed\n"); + return ret; + } + + ret = test(0, 1); + if (ret) { + fprintf(stderr, "test 0 1 failed\n"); + return ret; + } + + ret = test(IORING_SETUP_SINGLE_ISSUER|IORING_SETUP_DEFER_TASKRUN, 1); + if (ret) { + fprintf(stderr, "test DEFER 1 failed\n"); + return ret; + } + + return 0; +} diff --git a/contrib/libs/liburing/test/accept-non-empty.t/ya.make b/contrib/libs/liburing/test/accept-non-empty.t/ya.make new file mode 100644 index 0000000000..c6df3eb032 --- /dev/null +++ b/contrib/libs/liburing/test/accept-non-empty.t/ya.make @@ -0,0 +1,35 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +VERSION(2.7) + +LICENSE(MIT) + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + accept-non-empty.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/accept-reuse.t/ya.make b/contrib/libs/liburing/test/accept-reuse.t/ya.make index 7ad6187e2d..6624289a0e 100644 --- a/contrib/libs/liburing/test/accept-reuse.t/ya.make +++ b/contrib/libs/liburing/test/accept-reuse.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/accept-test.t/ya.make b/contrib/libs/liburing/test/accept-test.t/ya.make index 4f14f4a280..c82e260ee9 100644 --- a/contrib/libs/liburing/test/accept-test.t/ya.make +++ b/contrib/libs/liburing/test/accept-test.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/accept.c b/contrib/libs/liburing/test/accept.c index 2208a54708..49b1ca1345 100644 --- a/contrib/libs/liburing/test/accept.c +++ b/contrib/libs/liburing/test/accept.c @@ -432,7 +432,7 @@ struct test_accept_many_args { }; /* - * Test issue many accepts and see if we handle cancellation on exit + * Test issue many accepts and see if we handle cancelation on exit */ static int test_accept_many(struct test_accept_many_args args) { @@ -487,7 +487,7 @@ static int test_accept_many(struct test_accept_many_args args) if (io_uring_peek_cqe(&m_io_uring, &cqe)) break; if (cqe->res != -ECANCELED) { - fprintf(stderr, "Expected cqe to be cancelled %d\n", cqe->res); + fprintf(stderr, "Expected cqe to be canceled %d\n", cqe->res); ret = 1; goto out; } diff --git a/contrib/libs/liburing/test/accept.t/ya.make b/contrib/libs/liburing/test/accept.t/ya.make index 25632aeb5f..95bb00c414 100644 --- a/contrib/libs/liburing/test/accept.t/ya.make +++ b/contrib/libs/liburing/test/accept.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/across-fork.t/ya.make b/contrib/libs/liburing/test/across-fork.t/ya.make index c8257c2316..1b12588baf 100644 --- a/contrib/libs/liburing/test/across-fork.t/ya.make +++ b/contrib/libs/liburing/test/across-fork.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/b19062a56726.t/ya.make b/contrib/libs/liburing/test/b19062a56726.t/ya.make index 98ff484e7c..5c7a8603ad 100644 --- a/contrib/libs/liburing/test/b19062a56726.t/ya.make +++ b/contrib/libs/liburing/test/b19062a56726.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/b5837bd5311d.t/ya.make b/contrib/libs/liburing/test/b5837bd5311d.t/ya.make index 4d57ddd1a9..74e7ca4d07 100644 --- a/contrib/libs/liburing/test/b5837bd5311d.t/ya.make +++ b/contrib/libs/liburing/test/b5837bd5311d.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/bind-listen.c b/contrib/libs/liburing/test/bind-listen.c new file mode 100644 index 0000000000..25f41b48b5 --- /dev/null +++ b/contrib/libs/liburing/test/bind-listen.c @@ -0,0 +1,409 @@ +#include "../config-host.h" +/* SPDX-License-Identifier: MIT */ +/* + * Configure and operate a TCP socket solely with io_uring. + */ +#include <stdio.h> +#include <string.h> +#include <liburing.h> +#include <err.h> +#include <sys/mman.h> +#include <sys/wait.h> +#include <sys/socket.h> +#include <unistd.h> +#include <stdlib.h> +#include <netinet/ip.h> +#include "liburing.h" +#include "helpers.h" + +static void msec_to_ts(struct __kernel_timespec *ts, unsigned int msec) +{ + ts->tv_sec = msec / 1000; + ts->tv_nsec = (msec % 1000) * 1000000; +} + +static const char *magic = "Hello World!"; +static int use_port = 8000; + +enum { + SRV_INDEX = 0, + CLI_INDEX, + CONN_INDEX, +}; + +static int connect_client(struct io_uring *ring, unsigned short peer_port) +{ + struct __kernel_timespec ts; + struct io_uring_sqe *sqe; + struct io_uring_cqe *cqe; + int head, ret, submitted = 0; + struct sockaddr_in peer_addr; + socklen_t addr_len = sizeof(peer_addr); + + peer_addr.sin_family = AF_INET; + peer_addr.sin_port = peer_port; + peer_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + + sqe = io_uring_get_sqe(ring); + io_uring_prep_socket_direct(sqe, AF_INET, SOCK_STREAM, 0, + CLI_INDEX, 0); + sqe->flags |= IOSQE_IO_LINK; + + sqe = io_uring_get_sqe(ring); + io_uring_prep_connect(sqe, CLI_INDEX, (struct sockaddr*) &peer_addr, addr_len); + sqe->flags |= IOSQE_FIXED_FILE | IOSQE_IO_LINK; + + sqe = io_uring_get_sqe(ring); + io_uring_prep_send(sqe, CLI_INDEX, magic, strlen(magic), 0); + sqe->flags |= IOSQE_FIXED_FILE | IOSQE_IO_LINK; + + submitted = ret = io_uring_submit(ring); + if (ret < 0) + return T_SETUP_SKIP; + + msec_to_ts(&ts, 300); + ret = io_uring_wait_cqes(ring, &cqe, submitted, &ts, NULL); + if (ret < 0) + return T_SETUP_SKIP; + + io_uring_for_each_cqe(ring, head, cqe) { + ret = cqe->res; + if (ret < 0) + return T_SETUP_SKIP; + } io_uring_cq_advance(ring, submitted); + + return T_SETUP_OK; +} + +static int setup_srv(struct io_uring *ring, struct sockaddr_in *server_addr) +{ + struct io_uring_sqe *sqe; + struct io_uring_cqe *cqe; + struct __kernel_timespec ts; + int ret, val, submitted; + unsigned head; + + memset(server_addr, 0, sizeof(struct sockaddr_in)); + server_addr->sin_family = AF_INET; + server_addr->sin_port = htons(use_port++); + server_addr->sin_addr.s_addr = htons(INADDR_ANY); + + sqe = io_uring_get_sqe(ring); + io_uring_prep_socket_direct(sqe, AF_INET, SOCK_STREAM, 0, SRV_INDEX, 0); + sqe->flags |= IOSQE_IO_LINK; + + sqe = io_uring_get_sqe(ring); + val = 1; + io_uring_prep_cmd_sock(sqe, SOCKET_URING_OP_SETSOCKOPT, 0, SOL_SOCKET, + SO_REUSEADDR, &val, sizeof(val)); + sqe->flags |= IOSQE_FIXED_FILE | IOSQE_IO_LINK; + + sqe = io_uring_get_sqe(ring); + io_uring_prep_bind(sqe, SRV_INDEX, (struct sockaddr *) server_addr, + sizeof(struct sockaddr_in)); + sqe->flags |= IOSQE_FIXED_FILE | IOSQE_IO_LINK; + + sqe = io_uring_get_sqe(ring); + io_uring_prep_listen(sqe, SRV_INDEX, 1); + sqe->flags |= IOSQE_FIXED_FILE; + + submitted = ret = io_uring_submit(ring); + if (ret < 0) { + fprintf(stderr, "submission failed. %d\n", ret); + return T_EXIT_FAIL; + } + + msec_to_ts(&ts, 300); + ret = io_uring_wait_cqes(ring, &cqe, ret, &ts, NULL); + if (ret < 0) { + fprintf(stderr, "submission failed. %d\n", ret); + return T_EXIT_FAIL; + } + + io_uring_for_each_cqe(ring, head, cqe) { + ret = cqe->res; + if (ret < 0) { + fprintf(stderr, "Server startup failed. step %d got %d \n", head, ret); + return T_EXIT_FAIL; + } + } io_uring_cq_advance(ring, submitted); + + return T_SETUP_OK; +} + +static int test_good_server(unsigned int ring_flags) +{ + struct sockaddr_in server_addr; + struct __kernel_timespec ts; + struct io_uring_sqe *sqe; + struct io_uring_cqe *cqe; + struct io_uring ring; + int ret; + int fds[3]; + char buf[1024]; + + memset(fds, -1, sizeof(fds)); + + ret = t_create_ring(10, &ring, ring_flags | IORING_SETUP_SUBMIT_ALL); + if (ret < 0) { + fprintf(stderr, "queue_init: %s\n", strerror(-ret)); + return T_SETUP_SKIP; + } + + ret = io_uring_register_files(&ring, fds, 3); + if (ret) { + fprintf(stderr, "server file register %d\n", ret); + return T_SETUP_SKIP; + } + + ret = setup_srv(&ring, &server_addr); + if (ret != T_SETUP_OK) { + fprintf(stderr, "srv startup failed.\n"); + return T_EXIT_FAIL; + } + + if (connect_client(&ring, server_addr.sin_port) != T_SETUP_OK) { + fprintf(stderr, "cli startup failed.\n"); + return T_SETUP_SKIP; + } + + /* Wait for a request */ + sqe = io_uring_get_sqe(&ring); + io_uring_prep_accept_direct(sqe, SRV_INDEX, NULL, NULL, 0, CONN_INDEX); + sqe->flags |= IOSQE_FIXED_FILE; + + io_uring_submit(&ring); + io_uring_wait_cqe(&ring, &cqe); + if (cqe->res < 0) { + fprintf(stderr, "accept failed. %d\n", cqe->res); + return T_EXIT_FAIL; + } + io_uring_cqe_seen(&ring, cqe); + + sqe = io_uring_get_sqe(&ring); + io_uring_prep_recv(sqe, CONN_INDEX, buf, BUFSIZ, 0); + sqe->flags |= IOSQE_FIXED_FILE; + + io_uring_submit(&ring); + io_uring_wait_cqe_timeout(&ring, &cqe, &ts); + + if (cqe->res < 0) { + fprintf(stderr, "bad receive cqe. %d\n", cqe->res); + return T_EXIT_FAIL; + } + ret = cqe->res; + io_uring_cqe_seen(&ring, cqe); + + io_uring_queue_exit(&ring); + + if (ret != strlen(magic) || strncmp(buf, magic, ret)) { + fprintf(stderr, "didn't receive expected string. Got %d '%s'\n", ret, buf); + return T_EXIT_FAIL; + } + + return T_EXIT_PASS; +} + +static int test_bad_bind(void) +{ + struct sockaddr_in server_addr; + struct io_uring_sqe *sqe; + struct io_uring_cqe *cqe; + struct io_uring ring; + int sock = -1, err; + int ret = T_EXIT_FAIL; + + memset(&server_addr, 0, sizeof(struct sockaddr_in)); + server_addr.sin_family = AF_INET; + server_addr.sin_port = htons(9001); + server_addr.sin_addr.s_addr = htons(INADDR_ANY); + + err = t_create_ring(1, &ring, 0); + if (err < 0) { + fprintf(stderr, "queue_init: %s\n", strerror(-ret)); + return T_SETUP_SKIP; + } + + sock = socket(AF_INET, SOCK_STREAM, 0); + if (sock < 0) { + perror("socket"); + goto fail; + } + + /* Bind with size 0 */ + sqe = io_uring_get_sqe(&ring); + io_uring_prep_bind(sqe, sock, (struct sockaddr *) &server_addr, 0); + err = io_uring_submit(&ring); + if (err < 0) + goto fail; + + err = io_uring_wait_cqe(&ring, &cqe); + if (err) + goto fail; + + if (cqe->res != -EINVAL) + goto fail; + io_uring_cqe_seen(&ring, cqe); + + /* Bind with bad fd */ + sqe = io_uring_get_sqe(&ring); + io_uring_prep_bind(sqe, 0, (struct sockaddr *) &server_addr, sizeof(struct sockaddr_in)); + err = io_uring_submit(&ring); + if (err < 0) + goto fail; + + err = io_uring_wait_cqe(&ring, &cqe); + if (err) + goto fail; + if (cqe->res != -ENOTSOCK) + goto fail; + io_uring_cqe_seen(&ring, cqe); + + ret = T_EXIT_PASS; + + /* bind with weird value */ + sqe = io_uring_get_sqe(&ring); + io_uring_prep_bind(sqe, sock, (struct sockaddr *) &server_addr, sizeof(struct sockaddr_in)); + sqe->rw_flags = 1; + err = io_uring_submit(&ring); + if (err < 0) + goto fail; + + err = io_uring_wait_cqe(&ring, &cqe); + if (err) + goto fail; + if (cqe->res != -EINVAL) + goto fail; + io_uring_cqe_seen(&ring, cqe); + + ret = T_EXIT_PASS; + +fail: + io_uring_queue_exit(&ring); + if (sock != -1) + close(sock); + return ret; +} + +static int test_bad_listen(void) +{ + struct sockaddr_in server_addr; + struct io_uring_sqe *sqe; + struct io_uring_cqe *cqe; + struct io_uring ring; + int sock = -1, err; + int ret = T_EXIT_FAIL; + + memset(&server_addr, 0, sizeof(struct sockaddr_in)); + server_addr.sin_family = AF_INET; + server_addr.sin_port = htons(8001); + server_addr.sin_addr.s_addr = htons(INADDR_ANY); + + err = t_create_ring(1, &ring, 0); + if (err < 0) { + fprintf(stderr, "queue_init: %d\n", err); + return T_SETUP_SKIP; + } + + sock = socket(AF_INET, SOCK_STREAM, 0); + if (sock < 0) { + perror("socket"); + goto fail; + } + + err = t_bind_ephemeral_port(sock, &server_addr); + if (err) { + fprintf(stderr, "bind: %s\n", strerror(-err)); + goto fail; + } + + /* listen on bad sock */ + sqe = io_uring_get_sqe(&ring); + io_uring_prep_listen(sqe, 0, 1); + err = io_uring_submit(&ring); + if (err < 0) + goto fail; + + err = io_uring_wait_cqe(&ring, &cqe); + if (err) + goto fail; + + if (cqe->res != -ENOTSOCK) + goto fail; + io_uring_cqe_seen(&ring, cqe); + + /* listen with weird parameters */ + sqe = io_uring_get_sqe(&ring); + io_uring_prep_listen(sqe, sock, 1); + sqe->addr2 = 0xffffff; + err = io_uring_submit(&ring); + if (err < 0) + goto fail; + + err = io_uring_wait_cqe(&ring, &cqe); + if (err) + goto fail; + + if (cqe->res != -EINVAL) + goto fail; + io_uring_cqe_seen(&ring, cqe); + + ret = T_EXIT_PASS; +fail: + io_uring_queue_exit(&ring); + if (sock != -1) + close(sock); + return ret; +} + +int main(int argc, char *argv[]) +{ + struct io_uring_probe *probe; + int ret; + + if (argc > 1) + return 0; + + /* + * This test is not supported on older kernels. Check for + * OP_LISTEN, since that is the last feature required to support + * it. + */ + probe = io_uring_get_probe(); + if (!probe) + return T_EXIT_SKIP; + if (!io_uring_opcode_supported(probe, IORING_OP_LISTEN)) + return T_EXIT_SKIP; + + ret = test_good_server(0); + if (ret) { + fprintf(stderr, "good 0 failed\n"); + return T_EXIT_FAIL; + } + + ret = test_good_server(IORING_SETUP_SINGLE_ISSUER|IORING_SETUP_DEFER_TASKRUN); + if (ret) { + fprintf(stderr, "good defer failed\n"); + return T_EXIT_FAIL; + } + + ret = test_good_server(IORING_SETUP_SQPOLL); + if (ret) { + fprintf(stderr, "good sqpoll failed\n"); + return T_EXIT_FAIL; + } + + ret = test_bad_bind(); + if (ret) { + fprintf(stderr, "bad bind failed\n"); + return T_EXIT_FAIL; + } + + ret = test_bad_listen(); + if (ret) { + fprintf(stderr, "bad listen failed\n"); + return T_EXIT_FAIL; + } + + return T_EXIT_PASS; +} diff --git a/contrib/libs/liburing/test/bind-listen.t/ya.make b/contrib/libs/liburing/test/bind-listen.t/ya.make new file mode 100644 index 0000000000..06ac130345 --- /dev/null +++ b/contrib/libs/liburing/test/bind-listen.t/ya.make @@ -0,0 +1,35 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +VERSION(2.7) + +LICENSE(MIT) + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + bind-listen.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/buf-ring-nommap.c b/contrib/libs/liburing/test/buf-ring-nommap.c index 7624c67fa0..ac4f199c8b 100644 --- a/contrib/libs/liburing/test/buf-ring-nommap.c +++ b/contrib/libs/liburing/test/buf-ring-nommap.c @@ -42,10 +42,12 @@ int main(int argc, char *argv[]) if (posix_memalign(&ring_mem, 16384, 16384)) return T_EXIT_FAIL; + memset(ring_mem, 0, 16384); + p.flags = IORING_SETUP_NO_MMAP; ret = io_uring_queue_init_mem(1, &ring, &p, ring_mem, 16384); if (ret < 0) { - if (ret == -EINVAL) + if (ret == -EINVAL || ret == -ENOMEM) return T_EXIT_SKIP; fprintf(stderr, "queue init failed %d\n", ret); return T_EXIT_FAIL; diff --git a/contrib/libs/liburing/test/buf-ring-nommap.t/ya.make b/contrib/libs/liburing/test/buf-ring-nommap.t/ya.make index d2a66cb153..1acf0938dc 100644 --- a/contrib/libs/liburing/test/buf-ring-nommap.t/ya.make +++ b/contrib/libs/liburing/test/buf-ring-nommap.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/buf-ring-put.t/ya.make b/contrib/libs/liburing/test/buf-ring-put.t/ya.make index 05a9f0e704..f8f026e2a2 100644 --- a/contrib/libs/liburing/test/buf-ring-put.t/ya.make +++ b/contrib/libs/liburing/test/buf-ring-put.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/buf-ring.c b/contrib/libs/liburing/test/buf-ring.c index 682a97ec28..526dddaddc 100644 --- a/contrib/libs/liburing/test/buf-ring.c +++ b/contrib/libs/liburing/test/buf-ring.c @@ -304,16 +304,16 @@ static int test_running(int bgid, int entries, int loops, int use_mmap) ret = t_create_ring(1, &ring, 0); if (ret == T_SETUP_SKIP) - return 0; + return T_EXIT_SKIP; else if (ret != T_SETUP_OK) - return 1; + return T_EXIT_FAIL; if (!use_mmap) { br = io_uring_setup_buf_ring(&ring, entries, bgid, 0, &ret); if (!br) { /* by now should have checked if this is supported or not */ fprintf(stderr, "Buffer ring register failed %d\n", ret); - return 1; + return T_EXIT_FAIL; } } else { struct io_uring_buf_reg reg = { @@ -326,8 +326,10 @@ static int test_running(int bgid, int entries, int loops, int use_mmap) ret = io_uring_register_buf_ring(&ring, ®, 0); if (ret) { + if (ret == -EINVAL) + return T_EXIT_SKIP; fprintf(stderr, "mmap ring register failed %d\n", ret); - return 1; + return T_EXIT_FAIL; } off = IORING_OFF_PBUF_RING | @@ -337,17 +339,17 @@ static int test_running(int bgid, int entries, int loops, int use_mmap) MAP_SHARED | MAP_POPULATE, ring.ring_fd, off); if (br == MAP_FAILED) { perror("mmap"); - return 1; + return T_EXIT_FAIL; } } buffers = malloc(sizeof(bool) * entries); if (!buffers) - return 1; + return T_EXIT_SKIP; read_fd = open("/dev/zero", O_RDONLY); if (read_fd < 0) - return 1; + return T_EXIT_SKIP; for (loop = 0; loop < loops; loop++) { memset(buffers, 0, sizeof(bool) * entries); @@ -360,28 +362,28 @@ static int test_running(int bgid, int entries, int loops, int use_mmap) ret = test_one_read(read_fd, bgid, &ring); if (ret < 0) { fprintf(stderr, "bad run %d/%d = %d\n", loop, idx, ret); - return ret; + return T_EXIT_FAIL; } if (buffers[ret]) { fprintf(stderr, "reused buffer %d/%d = %d!\n", loop, idx, ret); - return 1; + return T_EXIT_FAIL; } if (buffer[0] != 0) { fprintf(stderr, "unexpected read %d %d/%d = %d!\n", (int)buffer[0], loop, idx, ret); - return 1; + return T_EXIT_FAIL; } if (buffer[1] != 1) { fprintf(stderr, "unexpected spilled read %d %d/%d = %d!\n", (int)buffer[1], loop, idx, ret); - return 1; + return T_EXIT_FAIL; } buffers[ret] = true; } ret = test_one_read(read_fd, bgid, &ring); if (ret != -ENOBUFS) { fprintf(stderr, "expected enobufs run %d = %d\n", loop, ret); - return 1; + return T_EXIT_FAIL; } } @@ -389,13 +391,13 @@ static int test_running(int bgid, int entries, int loops, int use_mmap) ret = io_uring_unregister_buf_ring(&ring, bgid); if (ret) { fprintf(stderr, "Buffer ring register failed %d\n", ret); - return 1; + return T_EXIT_FAIL; } close(read_fd); io_uring_queue_exit(&ring); free(buffers); - return 0; + return T_EXIT_PASS; } int main(int argc, char *argv[]) @@ -459,7 +461,9 @@ int main(int argc, char *argv[]) for (i = 0; !no_buf_ring && entries[i] != -1; i++) { ret = test_running(2, entries[i], 3, 1); - if (ret) { + if (ret == T_EXIT_SKIP) { + break; + } else if (ret != T_EXIT_PASS) { fprintf(stderr, "test_running(%d) mmap failed\n", entries[i]); return T_EXIT_FAIL; } diff --git a/contrib/libs/liburing/test/buf-ring.t/ya.make b/contrib/libs/liburing/test/buf-ring.t/ya.make index 0b49f68bed..63b3bac811 100644 --- a/contrib/libs/liburing/test/buf-ring.t/ya.make +++ b/contrib/libs/liburing/test/buf-ring.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/ce593a6c480a.t/ya.make b/contrib/libs/liburing/test/ce593a6c480a.t/ya.make index c4c7dd2bbd..2a1a37f183 100644 --- a/contrib/libs/liburing/test/ce593a6c480a.t/ya.make +++ b/contrib/libs/liburing/test/ce593a6c480a.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/close-opath.t/ya.make b/contrib/libs/liburing/test/close-opath.t/ya.make index 9583b3d9f2..0f156c6373 100644 --- a/contrib/libs/liburing/test/close-opath.t/ya.make +++ b/contrib/libs/liburing/test/close-opath.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/connect-rep.t/ya.make b/contrib/libs/liburing/test/connect-rep.t/ya.make index d4695ed765..4a22b223ac 100644 --- a/contrib/libs/liburing/test/connect-rep.t/ya.make +++ b/contrib/libs/liburing/test/connect-rep.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/connect.t/ya.make b/contrib/libs/liburing/test/connect.t/ya.make index 1015f24ef4..15d4aeedae 100644 --- a/contrib/libs/liburing/test/connect.t/ya.make +++ b/contrib/libs/liburing/test/connect.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/coredump.c b/contrib/libs/liburing/test/coredump.c index 44e2817897..d390b78be9 100644 --- a/contrib/libs/liburing/test/coredump.c +++ b/contrib/libs/liburing/test/coredump.c @@ -56,5 +56,6 @@ int main(int argc, char *argv[]) } wait(&wstat); + unlink("core"); return T_EXIT_PASS; } diff --git a/contrib/libs/liburing/test/coredump.t/ya.make b/contrib/libs/liburing/test/coredump.t/ya.make index 25cf3a3447..cad32c9a7b 100644 --- a/contrib/libs/liburing/test/coredump.t/ya.make +++ b/contrib/libs/liburing/test/coredump.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/cq-full.t/ya.make b/contrib/libs/liburing/test/cq-full.t/ya.make index 4b4463eca6..3ac0b9d38b 100644 --- a/contrib/libs/liburing/test/cq-full.t/ya.make +++ b/contrib/libs/liburing/test/cq-full.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/cq-overflow.t/ya.make b/contrib/libs/liburing/test/cq-overflow.t/ya.make index 4e68b4391d..4d67475587 100644 --- a/contrib/libs/liburing/test/cq-overflow.t/ya.make +++ b/contrib/libs/liburing/test/cq-overflow.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/cq-peek-batch.t/ya.make b/contrib/libs/liburing/test/cq-peek-batch.t/ya.make index d086bff60c..608e643c84 100644 --- a/contrib/libs/liburing/test/cq-peek-batch.t/ya.make +++ b/contrib/libs/liburing/test/cq-peek-batch.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/cq-ready.t/ya.make b/contrib/libs/liburing/test/cq-ready.t/ya.make index 37dc4451a9..e3ec30727e 100644 --- a/contrib/libs/liburing/test/cq-ready.t/ya.make +++ b/contrib/libs/liburing/test/cq-ready.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/cq-size.t/ya.make b/contrib/libs/liburing/test/cq-size.t/ya.make index 3111b101e9..5f6423089a 100644 --- a/contrib/libs/liburing/test/cq-size.t/ya.make +++ b/contrib/libs/liburing/test/cq-size.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/d4ae271dfaae.t/ya.make b/contrib/libs/liburing/test/d4ae271dfaae.t/ya.make index b162415697..30095cf271 100644 --- a/contrib/libs/liburing/test/d4ae271dfaae.t/ya.make +++ b/contrib/libs/liburing/test/d4ae271dfaae.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/d77a67ed5f27.t/ya.make b/contrib/libs/liburing/test/d77a67ed5f27.t/ya.make index f32a909fb2..d8eac8b261 100644 --- a/contrib/libs/liburing/test/d77a67ed5f27.t/ya.make +++ b/contrib/libs/liburing/test/d77a67ed5f27.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/defer-taskrun.t/ya.make b/contrib/libs/liburing/test/defer-taskrun.t/ya.make index 4c700d9fc8..a4303270da 100644 --- a/contrib/libs/liburing/test/defer-taskrun.t/ya.make +++ b/contrib/libs/liburing/test/defer-taskrun.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/defer-tw-timeout.c b/contrib/libs/liburing/test/defer-tw-timeout.c index ea06e19243..b3489abe62 100644 --- a/contrib/libs/liburing/test/defer-tw-timeout.c +++ b/contrib/libs/liburing/test/defer-tw-timeout.c @@ -100,6 +100,11 @@ static int test_file(struct io_uring *ring, char *__fname) fd = open(fname, O_RDONLY | O_DIRECT); if (fd < 0) { + if (errno == EINVAL) { + if (!__fname) + unlink(fname); + return T_EXIT_SKIP; + } perror("open"); if (!__fname) unlink(fname); diff --git a/contrib/libs/liburing/test/defer-tw-timeout.t/ya.make b/contrib/libs/liburing/test/defer-tw-timeout.t/ya.make index cbb1281cb3..e255116361 100644 --- a/contrib/libs/liburing/test/defer-tw-timeout.t/ya.make +++ b/contrib/libs/liburing/test/defer-tw-timeout.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/defer.c b/contrib/libs/liburing/test/defer.c index c1e7478906..1e52dcbf4e 100644 --- a/contrib/libs/liburing/test/defer.c +++ b/contrib/libs/liburing/test/defer.c @@ -89,7 +89,7 @@ static int wait_cqes(struct test_context *ctx) return 0; } -static int test_cancelled_userdata(struct io_uring *ring) +static int test_canceled_userdata(struct io_uring *ring) { struct test_context ctx; int ret, i, nr = 100; @@ -277,9 +277,9 @@ int main(int argc, char *argv[]) } - ret = test_cancelled_userdata(&poll_ring); + ret = test_canceled_userdata(&poll_ring); if (ret) { - printf("test_cancelled_userdata failed\n"); + printf("test_canceled_userdata failed\n"); return ret; } diff --git a/contrib/libs/liburing/test/defer.t/ya.make b/contrib/libs/liburing/test/defer.t/ya.make index 5687a37df9..1a043bd93a 100644 --- a/contrib/libs/liburing/test/defer.t/ya.make +++ b/contrib/libs/liburing/test/defer.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/double-poll-crash.t/ya.make b/contrib/libs/liburing/test/double-poll-crash.t/ya.make index 95a6a129fb..69683beddc 100644 --- a/contrib/libs/liburing/test/double-poll-crash.t/ya.make +++ b/contrib/libs/liburing/test/double-poll-crash.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/drop-submit.t/ya.make b/contrib/libs/liburing/test/drop-submit.t/ya.make index 86ec81b668..709c282398 100644 --- a/contrib/libs/liburing/test/drop-submit.t/ya.make +++ b/contrib/libs/liburing/test/drop-submit.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/eeed8b54e0df.t/ya.make b/contrib/libs/liburing/test/eeed8b54e0df.t/ya.make index 5c66505da1..a602da28d2 100644 --- a/contrib/libs/liburing/test/eeed8b54e0df.t/ya.make +++ b/contrib/libs/liburing/test/eeed8b54e0df.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/empty-eownerdead.t/ya.make b/contrib/libs/liburing/test/empty-eownerdead.t/ya.make index d86f7a8c53..412814da83 100644 --- a/contrib/libs/liburing/test/empty-eownerdead.t/ya.make +++ b/contrib/libs/liburing/test/empty-eownerdead.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/eploop.t/ya.make b/contrib/libs/liburing/test/eploop.t/ya.make index bad82c6f00..6461e6be2c 100644 --- a/contrib/libs/liburing/test/eploop.t/ya.make +++ b/contrib/libs/liburing/test/eploop.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/eventfd-disable.t/ya.make b/contrib/libs/liburing/test/eventfd-disable.t/ya.make index 16d29b9d5f..01b42db6c5 100644 --- a/contrib/libs/liburing/test/eventfd-disable.t/ya.make +++ b/contrib/libs/liburing/test/eventfd-disable.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/eventfd-reg.t/ya.make b/contrib/libs/liburing/test/eventfd-reg.t/ya.make index c3dc596dbb..193586f9bc 100644 --- a/contrib/libs/liburing/test/eventfd-reg.t/ya.make +++ b/contrib/libs/liburing/test/eventfd-reg.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/eventfd-ring.t/ya.make b/contrib/libs/liburing/test/eventfd-ring.t/ya.make index 86ff0dac1a..45d2e55520 100644 --- a/contrib/libs/liburing/test/eventfd-ring.t/ya.make +++ b/contrib/libs/liburing/test/eventfd-ring.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/eventfd.t/ya.make b/contrib/libs/liburing/test/eventfd.t/ya.make index e78b4c5ee6..b64217ee96 100644 --- a/contrib/libs/liburing/test/eventfd.t/ya.make +++ b/contrib/libs/liburing/test/eventfd.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/evloop.t/ya.make b/contrib/libs/liburing/test/evloop.t/ya.make index b46c369692..a5c92be9ca 100644 --- a/contrib/libs/liburing/test/evloop.t/ya.make +++ b/contrib/libs/liburing/test/evloop.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/exec-target.t/ya.make b/contrib/libs/liburing/test/exec-target.t/ya.make index 29ea06a2a2..b47e7f3a0f 100644 --- a/contrib/libs/liburing/test/exec-target.t/ya.make +++ b/contrib/libs/liburing/test/exec-target.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/exit-no-cleanup.t/ya.make b/contrib/libs/liburing/test/exit-no-cleanup.t/ya.make index 61df6fe9e3..6043dd7ec9 100644 --- a/contrib/libs/liburing/test/exit-no-cleanup.t/ya.make +++ b/contrib/libs/liburing/test/exit-no-cleanup.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/fadvise.t/ya.make b/contrib/libs/liburing/test/fadvise.t/ya.make index 3e4e506212..05e6a24928 100644 --- a/contrib/libs/liburing/test/fadvise.t/ya.make +++ b/contrib/libs/liburing/test/fadvise.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/fallocate.t/ya.make b/contrib/libs/liburing/test/fallocate.t/ya.make index efad14c2b1..93b93c9d99 100644 --- a/contrib/libs/liburing/test/fallocate.t/ya.make +++ b/contrib/libs/liburing/test/fallocate.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/fc2a85cb02ef.t/ya.make b/contrib/libs/liburing/test/fc2a85cb02ef.t/ya.make index d533701f7d..96ffd42829 100644 --- a/contrib/libs/liburing/test/fc2a85cb02ef.t/ya.make +++ b/contrib/libs/liburing/test/fc2a85cb02ef.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/fd-install.t/ya.make b/contrib/libs/liburing/test/fd-install.t/ya.make index 6c1ec8c557..55f72f4d28 100644 --- a/contrib/libs/liburing/test/fd-install.t/ya.make +++ b/contrib/libs/liburing/test/fd-install.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/fd-pass.t/ya.make b/contrib/libs/liburing/test/fd-pass.t/ya.make index 4128e73ab7..d7cf684aab 100644 --- a/contrib/libs/liburing/test/fd-pass.t/ya.make +++ b/contrib/libs/liburing/test/fd-pass.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/file-register.t/ya.make b/contrib/libs/liburing/test/file-register.t/ya.make index f8d8fa2d28..f7bc1cd23d 100644 --- a/contrib/libs/liburing/test/file-register.t/ya.make +++ b/contrib/libs/liburing/test/file-register.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/file-update.t/ya.make b/contrib/libs/liburing/test/file-update.t/ya.make index f7c0c714c0..67491db91c 100644 --- a/contrib/libs/liburing/test/file-update.t/ya.make +++ b/contrib/libs/liburing/test/file-update.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/file-verify.t/ya.make b/contrib/libs/liburing/test/file-verify.t/ya.make index b596c57a00..263b811e95 100644 --- a/contrib/libs/liburing/test/file-verify.t/ya.make +++ b/contrib/libs/liburing/test/file-verify.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/files-exit-hang-poll.t/ya.make b/contrib/libs/liburing/test/files-exit-hang-poll.t/ya.make index 3a0385b215..cf7bf1f7b9 100644 --- a/contrib/libs/liburing/test/files-exit-hang-poll.t/ya.make +++ b/contrib/libs/liburing/test/files-exit-hang-poll.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/files-exit-hang-timeout.t/ya.make b/contrib/libs/liburing/test/files-exit-hang-timeout.t/ya.make index f2c9ecc6d5..e91c801769 100644 --- a/contrib/libs/liburing/test/files-exit-hang-timeout.t/ya.make +++ b/contrib/libs/liburing/test/files-exit-hang-timeout.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/fixed-buf-iter.t/ya.make b/contrib/libs/liburing/test/fixed-buf-iter.t/ya.make index 4fc19f8968..f4ea025d7f 100644 --- a/contrib/libs/liburing/test/fixed-buf-iter.t/ya.make +++ b/contrib/libs/liburing/test/fixed-buf-iter.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/fixed-buf-merge.c b/contrib/libs/liburing/test/fixed-buf-merge.c index e75948fa79..ed2e821557 100644 --- a/contrib/libs/liburing/test/fixed-buf-merge.c +++ b/contrib/libs/liburing/test/fixed-buf-merge.c @@ -37,6 +37,10 @@ int main(int argc, char *argv[]) fd = open(filename, O_RDONLY | O_DIRECT, 0644); if (fd < 0) { + if (errno == EINVAL) { + unlink(filename); + return T_EXIT_SKIP; + } perror("open"); goto err_unlink; } diff --git a/contrib/libs/liburing/test/fixed-buf-merge.t/ya.make b/contrib/libs/liburing/test/fixed-buf-merge.t/ya.make index a652ef940d..78178231cc 100644 --- a/contrib/libs/liburing/test/fixed-buf-merge.t/ya.make +++ b/contrib/libs/liburing/test/fixed-buf-merge.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/fixed-hugepage.c b/contrib/libs/liburing/test/fixed-hugepage.c new file mode 100644 index 0000000000..bbc28bb8a6 --- /dev/null +++ b/contrib/libs/liburing/test/fixed-hugepage.c @@ -0,0 +1,412 @@ +#include "../config-host.h" +/* SPDX-License-Identifier: MIT */ +/* + * Test fixed buffers consisting of hugepages. + */ +#include <stdio.h> +#include <string.h> +#include <fcntl.h> +#include <stdlib.h> +#include <sys/mman.h> +#include <linux/mman.h> + +#include "liburing.h" +#include "helpers.h" + +/* + * Before testing + * echo (>=4) > /proc/sys/vm/nr_hugepages + * echo madvise > /sys/kernel/mm/transparent_hugepage/enabled + * echo always > /sys/kernel/mm/transparent_hugepage/hugepages-16kB/enabled + * + * Not 100% guaranteed to get THP-backed memory, but in general it does. + */ +#define MTHP_16KB (16UL * 1024) +#define HUGEPAGE_SIZE (2UL * 1024 * 1024) +#define NR_BUFS 1 +#define IN_FD "/dev/urandom" +#define OUT_FD "/dev/zero" + +static int open_files(char *fname_in, int *fd_in, int *fd_out) +{ + *fd_in = open(fname_in, O_RDONLY, 0644); + if (*fd_in < 0) { + printf("open %s failed\n", fname_in); + return -1; + } + + *fd_out = open(OUT_FD, O_RDWR, 0644); + if (*fd_out < 0) { + printf("open %s failed\n", OUT_FD); + return -1; + } + + return 0; +} + +static void unmap(struct iovec *iov, int nr_bufs, size_t offset) +{ + int i; + + for (i = 0; i < nr_bufs; i++) + munmap(iov[i].iov_base - offset, iov[i].iov_len + offset); +} + +static int mmap_hugebufs(struct iovec *iov, int nr_bufs, size_t buf_size, size_t offset) +{ + int i; + + for (i = 0; i < nr_bufs; i++) { + void *base = NULL; + + base = mmap(NULL, buf_size, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, -1, 0); + if (base == MAP_FAILED) { + printf("Unable to map hugetlb page. Try increasing the " + "value in /proc/sys/vm/nr_hugepages\n"); + unmap(iov, i, offset); + return -1; + } + + memset(base, 0, buf_size); + iov[i].iov_base = base + offset; + iov[i].iov_len = buf_size - offset; + } + + return 0; +} + +/* map a hugepage and smaller page to a contiguous memory */ +static int mmap_mixture(struct iovec *iov, int nr_bufs, size_t buf_size, bool huge_on_left) +{ + int i; + void *small_base = NULL, *huge_base = NULL, *start = NULL, + *huge_start = NULL, *small_start = NULL; + size_t small_size = buf_size - HUGEPAGE_SIZE; + size_t seg_size = ((buf_size / HUGEPAGE_SIZE) + 1) * HUGEPAGE_SIZE; + + start = mmap(NULL, seg_size * nr_bufs, PROT_NONE, + MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0); + if (start == MAP_FAILED) { + printf("Unable to preserve the page mixture memory. " + "Try increasing the RLIMIT_MEMLOCK resource limit\n"); + return -1; + } + + for (i = 0; i < nr_bufs; i++) { + if (huge_on_left) { + huge_start = start; + small_start = start + HUGEPAGE_SIZE; + } else { + huge_start = start + HUGEPAGE_SIZE; + small_start = start + HUGEPAGE_SIZE - small_size; + } + + huge_base = mmap(huge_start, HUGEPAGE_SIZE, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB | MAP_FIXED, -1, 0); + if (huge_base == MAP_FAILED) { + printf("Unable to map hugetlb page in the page mixture. " + "Try increasing the value in /proc/sys/vm/nr_hugepages\n"); + unmap(iov, nr_bufs, 0); + return -1; + } + + small_base = mmap(small_start, small_size, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0); + if (small_base == MAP_FAILED) { + printf("Unable to map small page in the page mixture. " + "Try increasing the RLIMIT_MEMLOCK resource limit\n"); + unmap(iov, nr_bufs, 0); + return -1; + } + + if (huge_on_left) { + iov[i].iov_base = huge_base; + memset(huge_base, 0, buf_size); + } + else { + iov[i].iov_base = small_base; + memset(small_base, 0, buf_size); + } + iov[i].iov_len = buf_size; + start += seg_size; + } + + return 0; +} + +static void free_bufs(struct iovec *iov, int nr_bufs, size_t offset) +{ + int i; + + for (i = 0; i < nr_bufs; i++) + free(iov[i].iov_base - offset); +} + +static int get_mthp_bufs(struct iovec *iov, int nr_bufs, size_t buf_size, + size_t alignment, size_t offset) +{ + int i; + + for (i = 0; i < nr_bufs; i++) { + void *base = NULL; + + if (posix_memalign(&base, alignment, buf_size)) { + printf("Unable to allocate mthp pages. " + "Try increasing the RLIMIT_MEMLOCK resource limit\n"); + free_bufs(iov, i, offset); + return -1; + } + + memset(base, 0, buf_size); + iov[i].iov_base = base + offset; + iov[i].iov_len = buf_size - offset; + } + + return 0; +} + +static int do_read(struct io_uring *ring, int fd, struct iovec *iov, int nr_bufs) +{ + struct io_uring_sqe *sqe; + struct io_uring_cqe *cqe; + int i, ret; + + for (i = 0; i < nr_bufs; i++) { + sqe = io_uring_get_sqe(ring); + if (!sqe) { + fprintf(stderr, "Could not get SQE.\n"); + return -1; + } + + io_uring_prep_read_fixed(sqe, fd, iov[i].iov_base, iov[i].iov_len, 0, i); + io_uring_submit(ring); + + ret = io_uring_wait_cqe(ring, &cqe); + if (ret < 0) { + fprintf(stderr, "Error waiting for completion: %s\n", strerror(-ret)); + return -1; + } + + if (cqe->res < 0) { + fprintf(stderr, "Error in async read operation: %s\n", strerror(-cqe->res)); + return -1; + } + if (cqe->res != iov[i].iov_len) { + fprintf(stderr, "cqe res: %d, expected: %lu\n", cqe->res, (unsigned long) iov[i].iov_len); + return -1; + } + + io_uring_cqe_seen(ring, cqe); + } + + return 0; +} + +static int do_write(struct io_uring *ring, int fd, struct iovec *iov, int nr_bufs) +{ + struct io_uring_sqe *sqe; + struct io_uring_cqe *cqe; + int i, ret; + + for (i = 0; i < nr_bufs; i++) { + sqe = io_uring_get_sqe(ring); + if (!sqe) { + fprintf(stderr, "Could not get SQE.\n"); + return -1; + } + + io_uring_prep_write_fixed(sqe, fd, iov[i].iov_base, iov[i].iov_len, 0, i); + io_uring_submit(ring); + + ret = io_uring_wait_cqe(ring, &cqe); + if (ret < 0) { + fprintf(stderr, "Error waiting for completion: %s\n", strerror(-ret)); + return -1; + } + + if (cqe->res < 0) { + fprintf(stderr, "Error in async write operation: %s\n", strerror(-cqe->res)); + return -1; + } + if (cqe->res != iov[i].iov_len) { + fprintf(stderr, "cqe res: %d, expected: %lu\n", cqe->res, (unsigned long) iov[i].iov_len); + return -1; + } + + io_uring_cqe_seen(ring, cqe); + } + + return 0; +} + +static int register_submit(struct io_uring *ring, struct iovec *iov, + int nr_bufs, int fd_in, int fd_out) +{ + int ret; + + ret = io_uring_register_buffers(ring, iov, nr_bufs); + if (ret) { + fprintf(stderr, "Error registering buffers: %s\n", strerror(-ret)); + return ret; + } + + ret = do_read(ring, fd_in, iov, nr_bufs); + if (ret) { + fprintf(stderr, "Read test failed\n"); + return ret; + } + + ret = do_write(ring, fd_out, iov, nr_bufs); + if (ret) { + fprintf(stderr, "Write test failed\n"); + return ret; + } + + ret = io_uring_unregister_buffers(ring); + if (ret) { + fprintf(stderr, "Error unregistering buffers for one hugepage test: %s", strerror(-ret)); + return ret; + } + + return 0; +} + +static int test_one_hugepage(struct io_uring *ring, int fd_in, int fd_out) +{ + struct iovec iov[NR_BUFS]; + size_t buf_size = HUGEPAGE_SIZE; + int ret; + + if (mmap_hugebufs(iov, NR_BUFS, buf_size, 0)) + return T_EXIT_SKIP; + + ret = register_submit(ring, iov, NR_BUFS, fd_in, fd_out); + unmap(iov, NR_BUFS, 0); + return ret ? T_EXIT_FAIL : T_EXIT_PASS; +} + +static int test_multi_hugepages(struct io_uring *ring, int fd_in, int fd_out) +{ + struct iovec iov[NR_BUFS]; + size_t buf_size = 4 * HUGEPAGE_SIZE; + int ret; + + if (mmap_hugebufs(iov, NR_BUFS, buf_size, 0)) + return T_EXIT_SKIP; + + ret = register_submit(ring, iov, NR_BUFS, fd_in, fd_out); + unmap(iov, NR_BUFS, 0); + return ret ? T_EXIT_FAIL : T_EXIT_PASS; +} + +static int test_unaligned_hugepage(struct io_uring *ring, int fd_in, int fd_out) +{ + struct iovec iov[NR_BUFS]; + size_t buf_size = 3 * HUGEPAGE_SIZE; + size_t offset = 0x1234; + int ret; + + if (mmap_hugebufs(iov, NR_BUFS, buf_size, offset)) + return T_EXIT_SKIP; + + ret = register_submit(ring, iov, NR_BUFS, fd_in, fd_out); + unmap(iov, NR_BUFS, offset); + return ret ? T_EXIT_FAIL : T_EXIT_PASS; +} + +static int test_multi_unaligned_mthps(struct io_uring *ring, int fd_in, int fd_out) +{ + struct iovec iov[NR_BUFS]; + int ret; + size_t buf_size = 3 * MTHP_16KB; + size_t offset = 0x1234; + + if (get_mthp_bufs(iov, NR_BUFS, buf_size, MTHP_16KB, offset)) + return T_EXIT_SKIP; + + ret = register_submit(ring, iov, NR_BUFS, fd_in, fd_out); + free_bufs(iov, NR_BUFS, offset); + return ret ? T_EXIT_FAIL : T_EXIT_PASS; +} + +/* Should not coalesce */ +static int test_page_mixture(struct io_uring *ring, int fd_in, int fd_out, int huge_on_left) +{ + struct iovec iov[NR_BUFS]; + size_t buf_size = HUGEPAGE_SIZE + MTHP_16KB; + int ret; + + if (mmap_mixture(iov, NR_BUFS, buf_size, huge_on_left)) + return T_EXIT_SKIP; + + ret = register_submit(ring, iov, NR_BUFS, fd_in, fd_out); + unmap(iov, NR_BUFS, 0); + return ret ? T_EXIT_FAIL : T_EXIT_PASS; +} + +int main(int argc, char *argv[]) +{ + struct io_uring ring; + int ret, fd_in, fd_out; + char *fname_in; + + if (argc > 1) + fname_in = argv[1]; + else + fname_in = IN_FD; + + if (open_files(fname_in, &fd_in, &fd_out)) + return T_EXIT_SKIP; + + ret = t_create_ring(8, &ring, 0); + if (ret == T_SETUP_SKIP) + return T_EXIT_SKIP; + else if (ret < 0) + return T_EXIT_FAIL; + + ret = test_one_hugepage(&ring, fd_in, fd_out); + if (ret != T_EXIT_PASS) { + if (ret != T_EXIT_SKIP) + fprintf(stderr, "Test one hugepage failed.\n"); + return ret; + } + + ret = test_multi_hugepages(&ring, fd_in, fd_out); + if (ret != T_EXIT_PASS) { + if (ret != T_EXIT_SKIP) + fprintf(stderr, "Test multi hugepages failed.\n"); + return ret; + } + + ret = test_unaligned_hugepage(&ring, fd_in, fd_out); + if (ret != T_EXIT_PASS) { + if (ret != T_EXIT_SKIP) + fprintf(stderr, "Test unaligned hugepage failed.\n"); + return ret; + } + + ret = test_multi_unaligned_mthps(&ring, fd_in, fd_out); + if (ret != T_EXIT_PASS) { + if (ret != T_EXIT_SKIP) + fprintf(stderr, "Test unaligned multi-size'd THPs failed.\n"); + return ret; + } + + ret = test_page_mixture(&ring, fd_in, fd_out, true); + if (ret != T_EXIT_PASS) { + if (ret != T_EXIT_SKIP) + fprintf(stderr, "Test huge small page mixture (start with huge) failed.\n"); + return ret; + } + + ret = test_page_mixture(&ring, fd_in, fd_out, false); + if (ret != T_EXIT_PASS) { + if (ret != T_EXIT_SKIP) + fprintf(stderr, "Test huge small page mixture (start with small) failed.\n"); + return ret; + } + + io_uring_queue_exit(&ring); + return T_EXIT_PASS; +} diff --git a/contrib/libs/liburing/test/fixed-hugepage.t/ya.make b/contrib/libs/liburing/test/fixed-hugepage.t/ya.make new file mode 100644 index 0000000000..9c4ef3dbe4 --- /dev/null +++ b/contrib/libs/liburing/test/fixed-hugepage.t/ya.make @@ -0,0 +1,35 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +VERSION(2.7) + +LICENSE(MIT) + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + fixed-hugepage.c + helpers.c +) + +END() diff --git a/contrib/libs/liburing/test/fixed-link.t/ya.make b/contrib/libs/liburing/test/fixed-link.t/ya.make index 86001d014a..afc5190ea1 100644 --- a/contrib/libs/liburing/test/fixed-link.t/ya.make +++ b/contrib/libs/liburing/test/fixed-link.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/fixed-reuse.t/ya.make b/contrib/libs/liburing/test/fixed-reuse.t/ya.make index 3a3b2d7d81..711704cf4d 100644 --- a/contrib/libs/liburing/test/fixed-reuse.t/ya.make +++ b/contrib/libs/liburing/test/fixed-reuse.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/fpos.c b/contrib/libs/liburing/test/fpos.c index 239a5b2959..61dc4a5055 100644 --- a/contrib/libs/liburing/test/fpos.c +++ b/contrib/libs/liburing/test/fpos.c @@ -99,7 +99,7 @@ static int test_read(struct io_uring *ring, bool async, int blocksize) if (res == 0) { done = true; } else if (res == -ECANCELED) { - /* cancelled, probably ok */ + /* canceled, probably ok */ } else if (res < 0 || res > blocksize) { fprintf(stderr, "bad read: %d\n", res); return -1; diff --git a/contrib/libs/liburing/test/fpos.t/ya.make b/contrib/libs/liburing/test/fpos.t/ya.make index 3bd7031c19..f9faf5bee7 100644 --- a/contrib/libs/liburing/test/fpos.t/ya.make +++ b/contrib/libs/liburing/test/fpos.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/fsync.t/ya.make b/contrib/libs/liburing/test/fsync.t/ya.make index c5218115df..c3be5c5b45 100644 --- a/contrib/libs/liburing/test/fsync.t/ya.make +++ b/contrib/libs/liburing/test/fsync.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/futex.t/ya.make b/contrib/libs/liburing/test/futex.t/ya.make index 3752134a0e..66ce3413c2 100644 --- a/contrib/libs/liburing/test/futex.t/ya.make +++ b/contrib/libs/liburing/test/futex.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/hardlink.t/ya.make b/contrib/libs/liburing/test/hardlink.t/ya.make index 899de38f8c..970e1a324c 100644 --- a/contrib/libs/liburing/test/hardlink.t/ya.make +++ b/contrib/libs/liburing/test/hardlink.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/ignore-single-mmap.c b/contrib/libs/liburing/test/ignore-single-mmap.c new file mode 100644 index 0000000000..2790b871d3 --- /dev/null +++ b/contrib/libs/liburing/test/ignore-single-mmap.c @@ -0,0 +1,49 @@ +#include "../config-host.h" +/* SPDX-License-Identifier: MIT */ +/* + * 6.10-rc merge window had a bug where the rewritten mmap support caused + * rings allocated with > 1 page, but asking for smaller mappings, would + * cause -EFAULT to be returned rather than a succesful map. This hit + * applications either using an ancient liburing with IORING_FEAT_SINGLE_MMAP + * support, or application just ignoring that feature flag and still doing + * 3 mmap operations to map the ring. + */ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "../src/syscall.h" +#include "liburing.h" +#include "helpers.h" + +#define ENTRIES 128 + +int main(int argc, char *argv[]) +{ + struct io_uring_params p = { }; + void *ptr; + int fd; + + if (argc > 1) + return T_EXIT_SKIP; + + fd = __sys_io_uring_setup(ENTRIES, &p); + if (fd < 0) + return T_EXIT_SKIP; + + if (!(p.features & IORING_FEAT_SINGLE_MMAP)) { + close(fd); + return T_EXIT_SKIP; + } + + ptr = __sys_mmap(0, ENTRIES * sizeof(unsigned), PROT_READ | PROT_WRITE, + MAP_SHARED | MAP_POPULATE, fd, + IORING_OFF_SQ_RING); + if (!IS_ERR(ptr)) { + close(fd); + return T_EXIT_PASS; + } + + fprintf(stderr, "ring sqe array mmap: %d\n", PTR_ERR(ptr)); + return T_EXIT_FAIL; +} diff --git a/contrib/libs/liburing/test/ignore-single-mmap.t/ya.make b/contrib/libs/liburing/test/ignore-single-mmap.t/ya.make new file mode 100644 index 0000000000..3942706db9 --- /dev/null +++ b/contrib/libs/liburing/test/ignore-single-mmap.t/ya.make @@ -0,0 +1,35 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +VERSION(2.7) + +LICENSE(MIT) + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + ignore-single-mmap.c +) + +END() diff --git a/contrib/libs/liburing/test/init-mem.c b/contrib/libs/liburing/test/init-mem.c new file mode 100644 index 0000000000..1909e2ac5f --- /dev/null +++ b/contrib/libs/liburing/test/init-mem.c @@ -0,0 +1,165 @@ +#include "../config-host.h" +/* SPDX-License-Identifier: MIT */ +/* + * Description: Check that io_uring_queue_init_mem() doesn't underestimate + * the memory required for various size rings. + */ +#include <stdio.h> +#include <unistd.h> +#include <errno.h> +#include <sys/mman.h> +#include <linux/mman.h> +#include <stdlib.h> +#include <string.h> +#include <netinet/udp.h> +#include <arpa/inet.h> +#include <net/if.h> +#include <error.h> + +#include "liburing.h" +#include "helpers.h" + +#define PRE_RED 0x5aa55aa55aa55aa5ULL +#define POST_RED 0xa55aa55aa55aa55aULL + +struct ctx { + struct io_uring ring; + void *ring_mem; + void *mem; + unsigned long long *pre; + unsigned long long *post; +}; + +struct q_entries { + unsigned int sqes; + unsigned int cqes; +}; + +static int setup_ctx(struct ctx *ctx, struct q_entries *q) +{ + struct io_uring_params p = { }; + int ret; + + if (posix_memalign(&ctx->mem, 4096, 2*1024*1024)) + return T_EXIT_FAIL; + + ctx->pre = ctx->mem + 4096 - sizeof(unsigned long); + *ctx->pre = PRE_RED; + + ctx->ring_mem = ctx->mem + 4096; + p.flags |= IORING_SETUP_CQSIZE | IORING_SETUP_NO_SQARRAY; + p.sq_entries = q->sqes; + p.cq_entries = q->cqes; + + ret = io_uring_queue_init_mem(q->sqes, &ctx->ring, &p, + ctx->ring_mem, 2*1024*1024); + + if (ret < 0) { + if (ret == -EINVAL) + return T_EXIT_SKIP; + fprintf(stderr, "queue init: %d\n", ret); + return T_EXIT_FAIL; + } + + ctx->post = ctx->ring_mem + ret; + *ctx->post = POST_RED; + return 0; +} + +static void clean_ctx(struct ctx *ctx) +{ + io_uring_queue_exit(&ctx->ring); +} + +static int check_red(struct ctx *ctx, unsigned long i) +{ + int fail = 0; + + if (*ctx->pre != PRE_RED) { + printf("pre redzone=%llx at i=%lu\n", *ctx->pre, i); + fail = 1; + } + if (*ctx->post != POST_RED) { + printf("post redzone=%llx at i=%lu\n", *ctx->post, i); + fail = 1; + } + return fail; +} + +static int test(struct q_entries *q) +{ + struct io_uring_sqe *sqe; + struct io_uring_cqe *cqe; + struct ctx ctx = { }; + unsigned long i, ud; + int j, ret, batch; + + ret = setup_ctx(&ctx, q); + if (ret == T_EXIT_SKIP) + return T_EXIT_SKIP; + else if (ret != T_EXIT_PASS) + return ret; + + batch = 64; + if (batch > q->sqes) + batch = q->sqes; + + i = ud = 0; + while (i < q->cqes * 2) { + if (check_red(&ctx, i)) + return T_EXIT_FAIL; + for (j = 0; j < batch; j++) { + sqe = io_uring_get_sqe(&ctx.ring); + io_uring_prep_nop(sqe); + sqe->user_data = j + (unsigned long) i; + } + io_uring_submit(&ctx.ring); + for (j = 0; j < batch; j++) { + ret = io_uring_wait_cqe(&ctx.ring, &cqe); + if (ret) + goto err; + if (cqe->user_data != ud) { + fprintf(stderr, "ud=%lu, wanted %lu\n", (unsigned long) cqe->user_data, ud); + goto err; + } + ud++; + io_uring_cqe_seen(&ctx.ring, cqe); + } + i += batch; + } + + clean_ctx(&ctx); + return T_EXIT_PASS; +err: + clean_ctx(&ctx); + return T_EXIT_FAIL; +} + +int main(int argc, char *argv[]) +{ + struct q_entries q_entries[] = { + { 256, 16384 }, + { 32, 4096 }, + { 128, 8192 }, + { 4096, 32768 }, + { 1, 8 }, + { 2, 1024 }, + }; + int i, ret; + + if (argc > 1) + return T_EXIT_SKIP; + + for (i = 0; i < ARRAY_SIZE(q_entries); i++) { + ret = test(&q_entries[i]); + if (ret == T_EXIT_SKIP) { + return T_EXIT_SKIP; + } else if (ret != T_EXIT_PASS) { + fprintf(stderr, "Failed at %d/%d\n", q_entries[i].sqes, + q_entries[i].cqes); + return T_EXIT_FAIL; + } + } + + return T_EXIT_PASS; +} diff --git a/contrib/libs/liburing/test/init-mem.t/ya.make b/contrib/libs/liburing/test/init-mem.t/ya.make new file mode 100644 index 0000000000..c60cfe5615 --- /dev/null +++ b/contrib/libs/liburing/test/init-mem.t/ya.make @@ -0,0 +1,35 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +VERSION(2.7) + +LICENSE(MIT) + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + init-mem.c +) + +END() diff --git a/contrib/libs/liburing/test/io-cancel.c b/contrib/libs/liburing/test/io-cancel.c index 8d769ea704..16a385f44b 100644 --- a/contrib/libs/liburing/test/io-cancel.c +++ b/contrib/libs/liburing/test/io-cancel.c @@ -94,7 +94,7 @@ static int wait_io(struct io_uring *ring, unsigned nr_io, int do_partial) if (do_partial && cqe->user_data) { if (!(cqe->user_data & 1)) { if (cqe->res != BS) { - fprintf(stderr, "IO %d wasn't cancelled but got error %d\n", (unsigned) cqe->user_data, cqe->res); + fprintf(stderr, "IO %d wasn't canceled but got error %d\n", (unsigned) cqe->user_data, cqe->res); goto err; } } @@ -148,7 +148,7 @@ err: /* * Test cancels. If 'do_partial' is set, then we only attempt to cancel half of - * the submitted IO. This is done to verify that cancelling one piece of IO doesn't + * the submitted IO. This is done to verify that canceling one piece of IO doesn't * impact others. */ static int test_io_cancel(const char *file, int do_write, int do_partial, @@ -272,7 +272,7 @@ static int test_dont_cancel_another_ring(void) ret = io_uring_wait_cqe_timeout(&ring1, &cqe, &ts); if (ret != -ETIME) { - fprintf(stderr, "read got cancelled or wait failed\n"); + fprintf(stderr, "read got canceled or wait failed\n"); return 1; } io_uring_cqe_seen(&ring1, cqe); @@ -348,18 +348,21 @@ static int test_cancel_req_across_fork(void) case 1: if (cqe->res != -EINTR && cqe->res != -ECANCELED) { - fprintf(stderr, "%i %i\n", (int)cqe->user_data, cqe->res); + fprintf(stderr, "user_data %i res %i\n", + (unsigned)cqe->user_data, cqe->res); exit(1); } break; case 2: if (cqe->res != -EALREADY && cqe->res) { - fprintf(stderr, "%i %i\n", (int)cqe->user_data, cqe->res); + fprintf(stderr, "user_data %i res %i\n", + (unsigned)cqe->user_data, cqe->res); exit(1); } break; default: - fprintf(stderr, "%i %i\n", (int)cqe->user_data, cqe->res); + fprintf(stderr, "user_data %i res %i\n", + (unsigned)cqe->user_data, cqe->res); exit(1); } @@ -452,7 +455,8 @@ static int test_cancel_inflight_exit(void) if ((cqe->user_data == 1 && cqe->res != -ECANCELED) || (cqe->user_data == 2 && cqe->res != -ECANCELED) || (cqe->user_data == 3 && cqe->res != -ETIME)) { - fprintf(stderr, "%i %i\n", (int)cqe->user_data, cqe->res); + fprintf(stderr, "user_data %i res %i\n", + (unsigned)cqe->user_data, cqe->res); return 1; } io_uring_cqe_seen(&ring, cqe); @@ -498,7 +502,7 @@ static int test_sqpoll_cancel_iowq_requests(void) sleep(1); io_uring_queue_exit(&ring); - /* close the write end, so if ring is cancelled properly read() fails*/ + /* close the write end, so if ring is canceled properly read() fails*/ close(fds[1]); ret = read(fds[0], buffer, 10); close(fds[0]); diff --git a/contrib/libs/liburing/test/io-cancel.t/ya.make b/contrib/libs/liburing/test/io-cancel.t/ya.make index 3d3cdc6ccf..12379a4a76 100644 --- a/contrib/libs/liburing/test/io-cancel.t/ya.make +++ b/contrib/libs/liburing/test/io-cancel.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/io_uring_enter.c b/contrib/libs/liburing/test/io_uring_enter.c index 7c73d0a403..4204ef5cae 100644 --- a/contrib/libs/liburing/test/io_uring_enter.c +++ b/contrib/libs/liburing/test/io_uring_enter.c @@ -170,7 +170,7 @@ static void submit_io(struct io_uring *ring, unsigned nr) ret = io_uring_submit(ring); unlink(template); if (ret < 0) { - perror("io_uring_enter"); + fprintf(stderr, "io_uring_queue_enter: %s\n", strerror(-ret)); exit(1); } } @@ -195,7 +195,7 @@ int main(int argc, char **argv) ret = t_io_uring_init_sqarray(IORING_MAX_ENTRIES_FALLBACK, &ring, &p); if (ret < 0) { - perror("io_uring_queue_init"); + fprintf(stderr, "queue_init: %s\n", strerror(-ret)); exit(T_EXIT_FAIL); } mask = sq->ring_mask; diff --git a/contrib/libs/liburing/test/io_uring_enter.t/ya.make b/contrib/libs/liburing/test/io_uring_enter.t/ya.make index a60d6cca13..83a0199127 100644 --- a/contrib/libs/liburing/test/io_uring_enter.t/ya.make +++ b/contrib/libs/liburing/test/io_uring_enter.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/io_uring_passthrough.t/ya.make b/contrib/libs/liburing/test/io_uring_passthrough.t/ya.make index de4aae6aaa..63a2078929 100644 --- a/contrib/libs/liburing/test/io_uring_passthrough.t/ya.make +++ b/contrib/libs/liburing/test/io_uring_passthrough.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/io_uring_register.t/ya.make b/contrib/libs/liburing/test/io_uring_register.t/ya.make index c38e994623..1d46c47686 100644 --- a/contrib/libs/liburing/test/io_uring_register.t/ya.make +++ b/contrib/libs/liburing/test/io_uring_register.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/io_uring_setup.t/ya.make b/contrib/libs/liburing/test/io_uring_setup.t/ya.make index 42a94f6032..e98edd9af6 100644 --- a/contrib/libs/liburing/test/io_uring_setup.t/ya.make +++ b/contrib/libs/liburing/test/io_uring_setup.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/iopoll-leak.t/ya.make b/contrib/libs/liburing/test/iopoll-leak.t/ya.make index 98102a9341..f6c3268667 100644 --- a/contrib/libs/liburing/test/iopoll-leak.t/ya.make +++ b/contrib/libs/liburing/test/iopoll-leak.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/iopoll-overflow.t/ya.make b/contrib/libs/liburing/test/iopoll-overflow.t/ya.make index e0a58ef4c1..ee34ce968d 100644 --- a/contrib/libs/liburing/test/iopoll-overflow.t/ya.make +++ b/contrib/libs/liburing/test/iopoll-overflow.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/iopoll.t/ya.make b/contrib/libs/liburing/test/iopoll.t/ya.make index 804acca663..fd11b7ce20 100644 --- a/contrib/libs/liburing/test/iopoll.t/ya.make +++ b/contrib/libs/liburing/test/iopoll.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/lfs-openat-write.t/ya.make b/contrib/libs/liburing/test/lfs-openat-write.t/ya.make index 35111ead56..f577ca7b03 100644 --- a/contrib/libs/liburing/test/lfs-openat-write.t/ya.make +++ b/contrib/libs/liburing/test/lfs-openat-write.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/lfs-openat.t/ya.make b/contrib/libs/liburing/test/lfs-openat.t/ya.make index 32b2f778c0..f0bc0c2b73 100644 --- a/contrib/libs/liburing/test/lfs-openat.t/ya.make +++ b/contrib/libs/liburing/test/lfs-openat.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/link-timeout.t/ya.make b/contrib/libs/liburing/test/link-timeout.t/ya.make index d912679544..31f04f1799 100644 --- a/contrib/libs/liburing/test/link-timeout.t/ya.make +++ b/contrib/libs/liburing/test/link-timeout.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/link.t/ya.make b/contrib/libs/liburing/test/link.t/ya.make index db142c20d2..31a9afdcfc 100644 --- a/contrib/libs/liburing/test/link.t/ya.make +++ b/contrib/libs/liburing/test/link.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/link_drain.t/ya.make b/contrib/libs/liburing/test/link_drain.t/ya.make index 1fcb074fc1..8951552fda 100644 --- a/contrib/libs/liburing/test/link_drain.t/ya.make +++ b/contrib/libs/liburing/test/link_drain.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/madvise.t/ya.make b/contrib/libs/liburing/test/madvise.t/ya.make index 61479e87c8..d0ac4fdc9f 100644 --- a/contrib/libs/liburing/test/madvise.t/ya.make +++ b/contrib/libs/liburing/test/madvise.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/mkdir.t/ya.make b/contrib/libs/liburing/test/mkdir.t/ya.make index 96e55f5d3d..87fefb42d5 100644 --- a/contrib/libs/liburing/test/mkdir.t/ya.make +++ b/contrib/libs/liburing/test/mkdir.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/msg-ring-fd.c b/contrib/libs/liburing/test/msg-ring-fd.c index 84a7d24f5c..7c68906424 100644 --- a/contrib/libs/liburing/test/msg-ring-fd.c +++ b/contrib/libs/liburing/test/msg-ring-fd.c @@ -17,6 +17,7 @@ static int no_msg; static int no_sparse; +static int no_fd_pass; struct data { pthread_t thread; @@ -89,6 +90,9 @@ static int test_remote(struct io_uring *src, int ring_flags) void *tret; int i; + if (no_fd_pass) + return 0; + pthread_barrier_init(&d.barrier, NULL, 2); d.ring_flags = ring_flags; pthread_create(&d.thread, NULL, thread_fn, &d); @@ -161,6 +165,9 @@ static int test_local(struct io_uring *src, struct io_uring *dst) char buf[32], dst_buf[32]; int i; + if (no_fd_pass) + return 0; + fd = -1; ret = io_uring_register_files(dst, &fd, 1); if (ret) { @@ -203,7 +210,9 @@ static int test_local(struct io_uring *src, struct io_uring *dst) fprintf(stderr, "wait_cqe: %d\n", ret); return 1; } - if (cqe->res < 0) { + if (cqe->user_data == 2 && cqe->res == -EINVAL) { + no_fd_pass = 1; + } else if (cqe->res < 0) { fprintf(stderr, "cqe res %d\n", cqe->res); return 1; } @@ -214,6 +223,9 @@ static int test_local(struct io_uring *src, struct io_uring *dst) io_uring_cqe_seen(src, cqe); } + if (no_fd_pass) + goto out; + ret = io_uring_wait_cqe(dst, &cqe); if (ret) { fprintf(stderr, "wait_cqe dst: %d\n", ret); @@ -250,6 +262,7 @@ static int test_local(struct io_uring *src, struct io_uring *dst) return 1; } +out: close(fds[0]); close(fds[1]); io_uring_unregister_files(src); diff --git a/contrib/libs/liburing/test/msg-ring-fd.t/ya.make b/contrib/libs/liburing/test/msg-ring-fd.t/ya.make index 2fd37b146b..e62d69d037 100644 --- a/contrib/libs/liburing/test/msg-ring-fd.t/ya.make +++ b/contrib/libs/liburing/test/msg-ring-fd.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/msg-ring-flags.t/ya.make b/contrib/libs/liburing/test/msg-ring-flags.t/ya.make index af6168d21f..ba23560940 100644 --- a/contrib/libs/liburing/test/msg-ring-flags.t/ya.make +++ b/contrib/libs/liburing/test/msg-ring-flags.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/msg-ring-overflow.t/ya.make b/contrib/libs/liburing/test/msg-ring-overflow.t/ya.make index c62325ce15..cb95daef71 100644 --- a/contrib/libs/liburing/test/msg-ring-overflow.t/ya.make +++ b/contrib/libs/liburing/test/msg-ring-overflow.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/msg-ring.c b/contrib/libs/liburing/test/msg-ring.c index ef9e3b1f85..843ba1f8ef 100644 --- a/contrib/libs/liburing/test/msg-ring.c +++ b/contrib/libs/liburing/test/msg-ring.c @@ -75,19 +75,25 @@ err: struct data { struct io_uring *ring; + unsigned int flags; + pthread_barrier_t startup; pthread_barrier_t barrier; }; static void *wait_cqe_fn(void *__data) { struct data *d = __data; - struct io_uring *ring = d->ring; struct io_uring_cqe *cqe; + struct io_uring ring; int ret; + io_uring_queue_init(4, &ring, d->flags); + d->ring = ˚ + pthread_barrier_wait(&d->startup); + pthread_barrier_wait(&d->barrier); - ret = io_uring_wait_cqe(ring, &cqe); + ret = io_uring_wait_cqe(&ring, &cqe); if (ret) { fprintf(stderr, "wait cqe %d\n", ret); goto err; @@ -102,15 +108,18 @@ static void *wait_cqe_fn(void *__data) goto err; } - io_uring_cqe_seen(ring, cqe); + io_uring_cqe_seen(&ring, cqe); + io_uring_queue_exit(&ring); return NULL; err: - io_uring_cqe_seen(ring, cqe); + io_uring_cqe_seen(&ring, cqe); + io_uring_queue_exit(&ring); return (void *) (unsigned long) 1; } -static int test_remote(struct io_uring *ring, struct io_uring *target) +static int test_remote(struct io_uring *ring, unsigned int ring_flags) { + struct io_uring *target; pthread_t thread; void *tret; struct io_uring_cqe *cqe; @@ -118,10 +127,14 @@ static int test_remote(struct io_uring *ring, struct io_uring *target) struct data d; int ret; - d.ring = target; + d.flags = ring_flags; pthread_barrier_init(&d.barrier, NULL, 2); + pthread_barrier_init(&d.startup, NULL, 2); pthread_create(&thread, NULL, wait_cqe_fn, &d); + pthread_barrier_wait(&d.startup); + target = d.ring; + sqe = io_uring_get_sqe(ring); if (!sqe) { fprintf(stderr, "get sqe failed\n"); @@ -146,10 +159,12 @@ static int test_remote(struct io_uring *ring, struct io_uring *target) } if (cqe->res != 0) { fprintf(stderr, "cqe res %d\n", cqe->res); + io_uring_cqe_seen(ring, cqe); return -1; } if (cqe->user_data != 1) { fprintf(stderr, "user_data %llx\n", (long long) cqe->user_data); + io_uring_cqe_seen(ring, cqe); return -1; } @@ -376,7 +391,7 @@ static int test(int ring_flags) } } - ret = test_remote(&ring, &ring2); + ret = test_remote(&ring, ring_flags); if (ret) { fprintf(stderr, "test_remote failed\n"); return T_EXIT_FAIL; diff --git a/contrib/libs/liburing/test/msg-ring.t/ya.make b/contrib/libs/liburing/test/msg-ring.t/ya.make index de2aa99c31..a1038229eb 100644 --- a/contrib/libs/liburing/test/msg-ring.t/ya.make +++ b/contrib/libs/liburing/test/msg-ring.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/multicqes_drain.c b/contrib/libs/liburing/test/multicqes_drain.c index 43880c0b18..2974597da3 100644 --- a/contrib/libs/liburing/test/multicqes_drain.c +++ b/contrib/libs/liburing/test/multicqes_drain.c @@ -39,8 +39,8 @@ struct sqe_info { * sqe_flags: combination of sqe flags * multi_sqes: record the user_data/index of all the multishot sqes * cnt: how many entries there are in multi_sqes - * we can leverage multi_sqes array for cancellation: we randomly pick - * up an entry in multi_sqes when form a cancellation sqe. + * we can leverage multi_sqes array for cancelation: we randomly pick + * up an entry in multi_sqes when form a cancelation sqe. * multi_cap: limitation of number of multishot sqes */ static const unsigned sqe_flags[4] = { @@ -110,7 +110,7 @@ static __u8 generate_flags(int sqe_op) { __u8 flags = 0; /* - * drain sqe must be put after multishot sqes cancelled + * drain sqe must be put after multishot sqes canceled */ do { flags = sqe_flags[rand() % 4]; @@ -125,7 +125,7 @@ static __u8 generate_flags(int sqe_op) /* * avoid below case: * sqe0(multishot, link)->sqe1(nop, link)->sqe2(nop)->sqe3(cancel_sqe0) - * sqe3 may execute before sqe0 so that sqe0 isn't cancelled + * sqe3 may execute before sqe0 so that sqe0 isn't canceled */ if (sqe_op == multi) flags &= ~IOSQE_IO_LINK; @@ -266,7 +266,7 @@ static int test_generic_drain(struct io_uring *ring) } } /* - * for multishot sqes, record them only when it is cancelled + * for multishot sqes, record them only when it is canceled */ if ((si[index].op != multi) || (cqe_res[j] == -ECANCELED)) compl_bits |= (1ULL << index); diff --git a/contrib/libs/liburing/test/multicqes_drain.t/ya.make b/contrib/libs/liburing/test/multicqes_drain.t/ya.make index 9ebc4ab0ce..f14f880b47 100644 --- a/contrib/libs/liburing/test/multicqes_drain.t/ya.make +++ b/contrib/libs/liburing/test/multicqes_drain.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/no-mmap-inval.c b/contrib/libs/liburing/test/no-mmap-inval.c index e340311ac3..44d3be97d5 100644 --- a/contrib/libs/liburing/test/no-mmap-inval.c +++ b/contrib/libs/liburing/test/no-mmap-inval.c @@ -34,7 +34,7 @@ int main(int argc, char *argv[]) if (ret == -EINVAL) { /* kernel doesn't support SETUP_NO_MMAP */ return T_EXIT_SKIP; - } else if (ret && ret != -EFAULT) { + } else if (ret && (ret != -EFAULT && ret != -ENOMEM)) { fprintf(stderr, "Got %d, wanted -EFAULT\n", ret); return T_EXIT_FAIL; } diff --git a/contrib/libs/liburing/test/no-mmap-inval.t/ya.make b/contrib/libs/liburing/test/no-mmap-inval.t/ya.make index 37e438629b..9ec20bebad 100644 --- a/contrib/libs/liburing/test/no-mmap-inval.t/ya.make +++ b/contrib/libs/liburing/test/no-mmap-inval.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/nolibc.t/ya.make b/contrib/libs/liburing/test/nolibc.t/ya.make index c24e84010c..7f57ccae4b 100644 --- a/contrib/libs/liburing/test/nolibc.t/ya.make +++ b/contrib/libs/liburing/test/nolibc.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/nop-all-sizes.t/ya.make b/contrib/libs/liburing/test/nop-all-sizes.t/ya.make index 1f2df01de6..35fc683f9f 100644 --- a/contrib/libs/liburing/test/nop-all-sizes.t/ya.make +++ b/contrib/libs/liburing/test/nop-all-sizes.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/nop.t/ya.make b/contrib/libs/liburing/test/nop.t/ya.make index 8eccd15969..df373fd678 100644 --- a/contrib/libs/liburing/test/nop.t/ya.make +++ b/contrib/libs/liburing/test/nop.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/ooo-file-unreg.c b/contrib/libs/liburing/test/ooo-file-unreg.c new file mode 100644 index 0000000000..ee5faaf4f8 --- /dev/null +++ b/contrib/libs/liburing/test/ooo-file-unreg.c @@ -0,0 +1,83 @@ +#include "../config-host.h" +/* SPDX-License-Identifier: MIT */ +/* + * Description: Test that out-of-order file updates with inflight requests + * work as expected. + * + */ +#include <stdio.h> +#include <fcntl.h> +#include <sys/socket.h> +#include <unistd.h> +#include <stdlib.h> +#include <sys/poll.h> + +#include "liburing.h" +#include "helpers.h" + +int main(int argc, char *argv[]) +{ + struct io_uring_sqe *sqe; + int res, fds[2], sockid; + struct io_uring ring; + + if (argc > 1) + return T_EXIT_SKIP; + + res = io_uring_queue_init(1, &ring, 0); + if (res) { + fprintf(stderr, "queue_init: %d\n", res); + return T_EXIT_FAIL; + } + + res = io_uring_register_files_sparse(&ring, 2); + if (res) { + if (res == -EINVAL) + return T_EXIT_SKIP; + fprintf(stderr, "sparse reg: %d\n", res); + return T_EXIT_FAIL; + } + + fds[0] = socket(AF_INET, SOCK_DGRAM, 0); + if (fds[0] < 0) { + perror("socket"); + return T_EXIT_FAIL; + } + fds[1] = socket(AF_INET, SOCK_DGRAM, 0); + if (fds[1] < 0) { + perror("socket"); + return T_EXIT_FAIL; + } + + res = io_uring_register_files_update(&ring, 0, fds, 2); + if (res != 2) { + fprintf(stderr, "files updates; %d\n", res); + return T_EXIT_FAIL; + } + + sqe = io_uring_get_sqe(&ring); + io_uring_prep_poll_add(sqe, 0, POLLIN); + sqe->flags = IOSQE_FIXED_FILE; + io_uring_submit(&ring); + + close(fds[0]); + close(fds[1]); + + sockid = -1; + res = io_uring_register_files_update(&ring, 1, &sockid, 1); + if (res != 1) { + fprintf(stderr, "files updates; %d\n", res); + return T_EXIT_FAIL; + } + + sockid = -1; + res = io_uring_register_files_update(&ring, 0, &sockid, 1); + if (res != 1) { + fprintf(stderr, "files updates; %d\n", res); + return T_EXIT_FAIL; + } + + sleep(1); + io_uring_queue_exit(&ring); + return T_EXIT_PASS; +} diff --git a/contrib/libs/liburing/test/ooo-file-unreg.t/ya.make b/contrib/libs/liburing/test/ooo-file-unreg.t/ya.make new file mode 100644 index 0000000000..8df08c00b9 --- /dev/null +++ b/contrib/libs/liburing/test/ooo-file-unreg.t/ya.make @@ -0,0 +1,35 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +VERSION(2.7) + +LICENSE(MIT) + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + ooo-file-unreg.c +) + +END() diff --git a/contrib/libs/liburing/test/open-close.t/ya.make b/contrib/libs/liburing/test/open-close.t/ya.make index aa584ce874..1c96f6a744 100644 --- a/contrib/libs/liburing/test/open-close.t/ya.make +++ b/contrib/libs/liburing/test/open-close.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/open-direct-link.t/ya.make b/contrib/libs/liburing/test/open-direct-link.t/ya.make index 4027551744..a526297eca 100644 --- a/contrib/libs/liburing/test/open-direct-link.t/ya.make +++ b/contrib/libs/liburing/test/open-direct-link.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/open-direct-pick.t/ya.make b/contrib/libs/liburing/test/open-direct-pick.t/ya.make index ab2caa9468..385643a111 100644 --- a/contrib/libs/liburing/test/open-direct-pick.t/ya.make +++ b/contrib/libs/liburing/test/open-direct-pick.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/openat2.t/ya.make b/contrib/libs/liburing/test/openat2.t/ya.make index 8063d9d52a..b7c98e6e2e 100644 --- a/contrib/libs/liburing/test/openat2.t/ya.make +++ b/contrib/libs/liburing/test/openat2.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/personality.t/ya.make b/contrib/libs/liburing/test/personality.t/ya.make index 78b11586ae..5d2750936e 100644 --- a/contrib/libs/liburing/test/personality.t/ya.make +++ b/contrib/libs/liburing/test/personality.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/pipe-bug.t/ya.make b/contrib/libs/liburing/test/pipe-bug.t/ya.make index 0a27f30c2e..b4a71cf37e 100644 --- a/contrib/libs/liburing/test/pipe-bug.t/ya.make +++ b/contrib/libs/liburing/test/pipe-bug.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/pipe-eof.t/ya.make b/contrib/libs/liburing/test/pipe-eof.t/ya.make index 108759b4e4..b53c087814 100644 --- a/contrib/libs/liburing/test/pipe-eof.t/ya.make +++ b/contrib/libs/liburing/test/pipe-eof.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/pipe-reuse.t/ya.make b/contrib/libs/liburing/test/pipe-reuse.t/ya.make index 9bb534150d..f393155c37 100644 --- a/contrib/libs/liburing/test/pipe-reuse.t/ya.make +++ b/contrib/libs/liburing/test/pipe-reuse.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/poll-cancel-all.t/ya.make b/contrib/libs/liburing/test/poll-cancel-all.t/ya.make index e69de7562a..d868fa9fb5 100644 --- a/contrib/libs/liburing/test/poll-cancel-all.t/ya.make +++ b/contrib/libs/liburing/test/poll-cancel-all.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/poll-cancel-ton.t/ya.make b/contrib/libs/liburing/test/poll-cancel-ton.t/ya.make index 6aa6b3dcfc..254f5d774b 100644 --- a/contrib/libs/liburing/test/poll-cancel-ton.t/ya.make +++ b/contrib/libs/liburing/test/poll-cancel-ton.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/poll-cancel.c b/contrib/libs/liburing/test/poll-cancel.c index 2d953b5676..a6589e8da4 100644 --- a/contrib/libs/liburing/test/poll-cancel.c +++ b/contrib/libs/liburing/test/poll-cancel.c @@ -155,11 +155,11 @@ static int __test_poll_cancel_with_timeouts(void) return 1; } - /* test timeout-offset triggering path during cancellation */ + /* test timeout-offset triggering path during cancelation */ sqe = io_uring_get_sqe(&ring); io_uring_prep_timeout(sqe, &ts, off_nr, 0); - /* poll ring2 to trigger cancellation on exit() */ + /* poll ring2 to trigger cancelation on exit() */ sqe = io_uring_get_sqe(&ring); io_uring_prep_poll_add(sqe, ring2.ring_fd, POLLIN); sqe->flags |= IOSQE_IO_LINK; diff --git a/contrib/libs/liburing/test/poll-cancel.t/ya.make b/contrib/libs/liburing/test/poll-cancel.t/ya.make index b351415a75..7f35cc137e 100644 --- a/contrib/libs/liburing/test/poll-cancel.t/ya.make +++ b/contrib/libs/liburing/test/poll-cancel.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/poll-link.t/ya.make b/contrib/libs/liburing/test/poll-link.t/ya.make index 59462033d3..9d6b445155 100644 --- a/contrib/libs/liburing/test/poll-link.t/ya.make +++ b/contrib/libs/liburing/test/poll-link.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/poll-many.t/ya.make b/contrib/libs/liburing/test/poll-many.t/ya.make index 65bef1d2cf..67d9a682f6 100644 --- a/contrib/libs/liburing/test/poll-many.t/ya.make +++ b/contrib/libs/liburing/test/poll-many.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/poll-mshot-overflow.t/ya.make b/contrib/libs/liburing/test/poll-mshot-overflow.t/ya.make index a33bb59053..ccc141a99b 100644 --- a/contrib/libs/liburing/test/poll-mshot-overflow.t/ya.make +++ b/contrib/libs/liburing/test/poll-mshot-overflow.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/poll-mshot-update.t/ya.make b/contrib/libs/liburing/test/poll-mshot-update.t/ya.make index 4778d30dc5..3453c214ee 100644 --- a/contrib/libs/liburing/test/poll-mshot-update.t/ya.make +++ b/contrib/libs/liburing/test/poll-mshot-update.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/poll-race-mshot.t/ya.make b/contrib/libs/liburing/test/poll-race-mshot.t/ya.make index a6cb990f7e..6fdf2c8491 100644 --- a/contrib/libs/liburing/test/poll-race-mshot.t/ya.make +++ b/contrib/libs/liburing/test/poll-race-mshot.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/poll-race.t/ya.make b/contrib/libs/liburing/test/poll-race.t/ya.make index 623800d8f5..1fdc2798b0 100644 --- a/contrib/libs/liburing/test/poll-race.t/ya.make +++ b/contrib/libs/liburing/test/poll-race.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/poll-ring.t/ya.make b/contrib/libs/liburing/test/poll-ring.t/ya.make index 9324f9467b..248be1c132 100644 --- a/contrib/libs/liburing/test/poll-ring.t/ya.make +++ b/contrib/libs/liburing/test/poll-ring.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/poll-v-poll.t/ya.make b/contrib/libs/liburing/test/poll-v-poll.t/ya.make index 9e38b3b746..b48c0ff287 100644 --- a/contrib/libs/liburing/test/poll-v-poll.t/ya.make +++ b/contrib/libs/liburing/test/poll-v-poll.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/poll.t/ya.make b/contrib/libs/liburing/test/poll.t/ya.make index 9343d92a45..809283fd40 100644 --- a/contrib/libs/liburing/test/poll.t/ya.make +++ b/contrib/libs/liburing/test/poll.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/probe.t/ya.make b/contrib/libs/liburing/test/probe.t/ya.make index 76eb74e499..abc6c4a41e 100644 --- a/contrib/libs/liburing/test/probe.t/ya.make +++ b/contrib/libs/liburing/test/probe.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/read-before-exit.t/ya.make b/contrib/libs/liburing/test/read-before-exit.t/ya.make index 9c3d8be8c5..d762a60d86 100644 --- a/contrib/libs/liburing/test/read-before-exit.t/ya.make +++ b/contrib/libs/liburing/test/read-before-exit.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/read-mshot-empty.t/ya.make b/contrib/libs/liburing/test/read-mshot-empty.t/ya.make index 95414a1800..bf50a15474 100644 --- a/contrib/libs/liburing/test/read-mshot-empty.t/ya.make +++ b/contrib/libs/liburing/test/read-mshot-empty.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/read-mshot.t/ya.make b/contrib/libs/liburing/test/read-mshot.t/ya.make index fe851e0f16..a760a7efbd 100644 --- a/contrib/libs/liburing/test/read-mshot.t/ya.make +++ b/contrib/libs/liburing/test/read-mshot.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/read-write.t/ya.make b/contrib/libs/liburing/test/read-write.t/ya.make index ab6591454f..25de751b18 100644 --- a/contrib/libs/liburing/test/read-write.t/ya.make +++ b/contrib/libs/liburing/test/read-write.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/recv-msgall-stream.t/ya.make b/contrib/libs/liburing/test/recv-msgall-stream.t/ya.make index 28abf655e4..428cb35d61 100644 --- a/contrib/libs/liburing/test/recv-msgall-stream.t/ya.make +++ b/contrib/libs/liburing/test/recv-msgall-stream.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/recv-msgall.t/ya.make b/contrib/libs/liburing/test/recv-msgall.t/ya.make index 0536130257..6a779b4378 100644 --- a/contrib/libs/liburing/test/recv-msgall.t/ya.make +++ b/contrib/libs/liburing/test/recv-msgall.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/recv-multishot.t/ya.make b/contrib/libs/liburing/test/recv-multishot.t/ya.make index c32fa366ae..4196930356 100644 --- a/contrib/libs/liburing/test/recv-multishot.t/ya.make +++ b/contrib/libs/liburing/test/recv-multishot.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/recvsend_bundle.c b/contrib/libs/liburing/test/recvsend_bundle.c new file mode 100644 index 0000000000..8d4305e847 --- /dev/null +++ b/contrib/libs/liburing/test/recvsend_bundle.c @@ -0,0 +1,692 @@ +#include "../config-host.h" +/* SPDX-License-Identifier: MIT */ +/* + * Simple test case showing using send and recv bundles + */ +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <arpa/inet.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <pthread.h> + +#define MSG_SIZE 128 +#define NR_MIN_MSGS 4 +#define NR_MAX_MSGS 32 +#define SEQ_SIZE (MSG_SIZE / sizeof(unsigned long)) + +static int nr_msgs; +static int use_tcp; + +#define RECV_BIDS 8192 +#define RECV_BID_MASK (RECV_BIDS - 1) + +#include "liburing.h" +#include "helpers.h" + +#define PORT 10202 +#define HOST "127.0.0.1" + +static int use_port = PORT; + +#define SEND_BGID 7 +#define RECV_BGID 8 + +static int no_send_mshot; + +struct recv_data { + pthread_barrier_t connect; + pthread_barrier_t startup; + pthread_barrier_t barrier; + pthread_barrier_t finish; + unsigned long seq; + int recv_bytes; + int accept_fd; + int abort; + unsigned int max_sends; + int to_eagain; + void *recv_buf; + + int send_bundle; + int recv_bundle; +}; + +static int arm_recv(struct io_uring *ring, struct recv_data *rd) +{ + struct io_uring_sqe *sqe; + int ret; + + sqe = io_uring_get_sqe(ring); + io_uring_prep_recv_multishot(sqe, rd->accept_fd, NULL, 0, 0); + if (rd->recv_bundle && use_tcp) + sqe->ioprio |= IORING_RECVSEND_BUNDLE; + sqe->buf_group = RECV_BGID; + sqe->flags |= IOSQE_BUFFER_SELECT; + sqe->user_data = 2; + + ret = io_uring_submit(ring); + if (ret != 1) { + fprintf(stderr, "submit failed: %d\n", ret); + return 1; + } + + return 0; +} + +static int recv_prep(struct io_uring *ring, struct recv_data *rd, int *sock) +{ + struct sockaddr_in saddr; + int sockfd, ret, val, use_fd; + socklen_t socklen; + + memset(&saddr, 0, sizeof(saddr)); + saddr.sin_family = AF_INET; + saddr.sin_addr.s_addr = htonl(INADDR_ANY); + saddr.sin_port = htons(use_port); + + if (use_tcp) + sockfd = socket(AF_INET, SOCK_STREAM, 0); + else + sockfd = socket(AF_INET, SOCK_DGRAM, 0); + if (sockfd < 0) { + perror("socket"); + return 1; + } + + val = 1; + setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)); + + ret = bind(sockfd, (struct sockaddr *)&saddr, sizeof(saddr)); + if (ret < 0) { + perror("bind"); + goto err; + } + + if (use_tcp) { + ret = listen(sockfd, 1); + if (ret < 0) { + perror("listen"); + goto err; + } + + pthread_barrier_wait(&rd->connect); + + socklen = sizeof(saddr); + use_fd = accept(sockfd, (struct sockaddr *)&saddr, &socklen); + if (use_fd < 0) { + perror("accept"); + goto err; + } + } else { + use_fd = sockfd; + pthread_barrier_wait(&rd->connect); + } + + rd->accept_fd = use_fd; + pthread_barrier_wait(&rd->startup); + pthread_barrier_wait(&rd->barrier); + + if (arm_recv(ring, rd)) + goto err; + + *sock = sockfd; + return 0; +err: + close(sockfd); + return 1; +} + +static int verify_seq(struct recv_data *rd, void *verify_ptr, int verify_sz, + int start_bid) +{ + unsigned long *seqp; + int seq_size = verify_sz / sizeof(unsigned long); + int i; + + seqp = verify_ptr; + for (i = 0; i < seq_size; i++) { + if (rd->seq != *seqp) { + fprintf(stderr, "bid=%d, got seq %lu, wanted %lu, offset %d\n", start_bid, *seqp, rd->seq, i); + return 0; + } + seqp++; + rd->seq++; + } + + return 1; +} + +static int recv_get_cqe(struct io_uring *ring, struct recv_data *rd, + struct io_uring_cqe **cqe) +{ + struct __kernel_timespec ts = { .tv_sec = 0, .tv_nsec = 100000000LL }; + int ret; + + do { + ret = io_uring_wait_cqe_timeout(ring, cqe, &ts); + if (!ret) + return 0; + if (ret == -ETIME) { + if (rd->abort) + break; + continue; + } + fprintf(stderr, "wait recv: %d\n", ret); + break; + } while (1); + + return 1; +} + +static int do_recv(struct io_uring *ring, struct recv_data *rd) +{ + struct io_uring_cqe *cqe; + int bid, next_bid = 0; + void *verify_ptr; + int verify_sz = 0; + int verify_bid = 0; + + verify_ptr = malloc(rd->recv_bytes); + + do { + if (recv_get_cqe(ring, rd, &cqe)) + break; + if (cqe->res == -EINVAL) { + fprintf(stdout, "recv not supported, skipping\n"); + return 0; + } + if (cqe->res < 0) { + fprintf(stderr, "failed recv cqe: %d\n", cqe->res); + goto err; + } + if (!(cqe->flags & IORING_CQE_F_BUFFER)) { + fprintf(stderr, "no buffer set in recv\n"); + goto err; + } + bid = cqe->flags >> IORING_CQE_BUFFER_SHIFT; + if (bid != next_bid) { + fprintf(stderr, "got bid %d, wanted %d\n", bid, next_bid); + goto err; + } + if (!rd->recv_bundle && cqe->res != MSG_SIZE) { + fprintf(stderr, "recv got wrong length: %d\n", cqe->res); + goto err; + } + if (!(verify_sz % MSG_SIZE)) { + if (!verify_seq(rd, verify_ptr, verify_sz, verify_bid)) + goto err; + verify_bid += verify_sz / MSG_SIZE; + verify_bid &= RECV_BID_MASK; + verify_sz = 0; + } else { + memcpy(verify_ptr + verify_sz, rd->recv_buf + (bid * MSG_SIZE), cqe->res); + verify_sz += cqe->res; + } + next_bid = bid + ((cqe->res + MSG_SIZE - 1) / MSG_SIZE); + next_bid &= RECV_BID_MASK; + rd->recv_bytes -= cqe->res; + io_uring_cqe_seen(ring, cqe); + if (!(cqe->flags & IORING_CQE_F_MORE) && rd->recv_bytes) { + if (arm_recv(ring, rd)) + goto err; + } + } while (rd->recv_bytes); + + if (verify_sz && !(verify_sz % MSG_SIZE) && + !verify_seq(rd, verify_ptr, verify_sz, verify_bid)) + goto err; + + pthread_barrier_wait(&rd->finish); + return 0; +err: + pthread_barrier_wait(&rd->finish); + return 1; +} + +static void *recv_fn(void *data) +{ + struct recv_data *rd = data; + struct io_uring_params p = { }; + struct io_uring ring; + struct io_uring_buf_ring *br; + void *buf, *ptr; + int ret, sock, i; + + p.cq_entries = 4096; + p.flags = IORING_SETUP_CQSIZE; + ret = t_create_ring_params(16, &ring, &p); + if (ret == T_SETUP_SKIP) { + ret = 0; + goto err; + } else if (ret < 0) { + goto err; + } + + if (posix_memalign(&buf, 4096, MSG_SIZE * RECV_BIDS)) + goto err; + + br = io_uring_setup_buf_ring(&ring, RECV_BIDS, RECV_BGID, 0, &ret); + if (!br) { + fprintf(stderr, "failed setting up recv ring %d\n", ret); + goto err; + } + + ptr = buf; + for (i = 0; i < RECV_BIDS; i++) { + io_uring_buf_ring_add(br, ptr, MSG_SIZE, i, RECV_BID_MASK, i); + ptr += MSG_SIZE; + } + io_uring_buf_ring_advance(br, RECV_BIDS); + rd->recv_buf = buf; + + ret = recv_prep(&ring, rd, &sock); + if (ret) { + fprintf(stderr, "recv_prep failed: %d\n", ret); + goto err; + } + + ret = do_recv(&ring, rd); + + close(sock); + close(rd->accept_fd); + io_uring_queue_exit(&ring); +err: + return (void *)(intptr_t)ret; +} + +static int __do_send_bundle(struct recv_data *rd, struct io_uring *ring, int sockfd) +{ + struct io_uring_cqe *cqe; + struct io_uring_sqe *sqe; + int bytes_needed = MSG_SIZE * nr_msgs; + int i, ret; + + sqe = io_uring_get_sqe(ring); + io_uring_prep_send_bundle(sqe, sockfd, 0, 0); + sqe->flags |= IOSQE_BUFFER_SELECT; + sqe->buf_group = SEND_BGID; + sqe->user_data = 1; + + ret = io_uring_submit(ring); + if (ret != 1) + return 1; + + pthread_barrier_wait(&rd->barrier); + + for (i = 0; i < nr_msgs; i++) { + ret = io_uring_wait_cqe(ring, &cqe); + if (ret) { + fprintf(stderr, "wait send: %d\n", ret); + return 1; + } + if (!i && cqe->res == -EINVAL) { + rd->abort = 1; + no_send_mshot = 1; + break; + } + if (cqe->res < 0) { + fprintf(stderr, "bad send cqe res: %d\n", cqe->res); + return 1; + } + bytes_needed -= cqe->res; + if (!bytes_needed) { + io_uring_cqe_seen(ring, cqe); + break; + } + if (!(cqe->flags & IORING_CQE_F_MORE)) { + fprintf(stderr, "expected more, but MORE not set\n"); + return 1; + } + io_uring_cqe_seen(ring, cqe); + } + + return 0; +} + +static int __do_send(struct recv_data *rd, struct io_uring *ring, int sockfd) +{ + struct io_uring_cqe *cqe; + struct io_uring_sqe *sqe; + int bytes_needed = MSG_SIZE * nr_msgs; + int i, ret; + + for (i = 0; i < nr_msgs; i++) { + sqe = io_uring_get_sqe(ring); + io_uring_prep_send(sqe, sockfd, NULL, 0, 0); + sqe->user_data = 10 + i; + sqe->flags |= IOSQE_BUFFER_SELECT; + sqe->buf_group = SEND_BGID; + + ret = io_uring_submit(ring); + if (ret != 1) + return 1; + + if (!i) + pthread_barrier_wait(&rd->barrier); + ret = io_uring_wait_cqe(ring, &cqe); + if (ret) { + fprintf(stderr, "send wait cqe %d\n", ret); + return 1; + } + + if (!i && cqe->res == -EINVAL) { + rd->abort = 1; + no_send_mshot = 1; + break; + } + if (cqe->res != MSG_SIZE) { + fprintf(stderr, "send failed cqe: %d\n", cqe->res); + return 1; + } + if (cqe->res < 0) { + fprintf(stderr, "bad send cqe res: %d\n", cqe->res); + return 1; + } + bytes_needed -= cqe->res; + io_uring_cqe_seen(ring, cqe); + if (!bytes_needed) + break; + } + + return 0; +} + +static int do_send(struct recv_data *rd) +{ + struct sockaddr_in saddr; + struct io_uring ring; + unsigned long seq_buf[SEQ_SIZE], send_seq; + struct io_uring_params p = { }; + struct io_uring_buf_ring *br; + int sockfd, ret, len, i; + socklen_t optlen; + void *buf, *ptr; + + ret = io_uring_queue_init_params(16, &ring, &p); + if (ret) { + fprintf(stderr, "queue init failed: %d\n", ret); + return 1; + } + if (!(p.features & IORING_FEAT_RECVSEND_BUNDLE)) { + no_send_mshot = 1; + return 0; + } + + if (posix_memalign(&buf, 4096, MSG_SIZE * nr_msgs)) + return 1; + + br = io_uring_setup_buf_ring(&ring, nr_msgs, SEND_BGID, 0, &ret); + if (!br) { + if (ret == -EINVAL) { + fprintf(stderr, "einval on br setup\n"); + return 0; + } + fprintf(stderr, "failed setting up send ring %d\n", ret); + return 1; + } + + ptr = buf; + for (i = 0; i < nr_msgs; i++) { + io_uring_buf_ring_add(br, ptr, MSG_SIZE, i, nr_msgs - 1, i); + ptr += MSG_SIZE; + } + io_uring_buf_ring_advance(br, nr_msgs); + + memset(&saddr, 0, sizeof(saddr)); + saddr.sin_family = AF_INET; + saddr.sin_port = htons(use_port); + inet_pton(AF_INET, HOST, &saddr.sin_addr); + + if (use_tcp) + sockfd = socket(AF_INET, SOCK_STREAM, 0); + else + sockfd = socket(AF_INET, SOCK_DGRAM, 0); + if (sockfd < 0) { + perror("socket"); + goto err2; + } + + pthread_barrier_wait(&rd->connect); + + ret = connect(sockfd, (struct sockaddr *)&saddr, sizeof(saddr)); + if (ret < 0) { + perror("connect"); + goto err; + } + + pthread_barrier_wait(&rd->startup); + + optlen = sizeof(len); + len = 1024 * MSG_SIZE; + setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, &len, optlen); + + /* almost fill queue, leave room for one message */ + send_seq = 0; + rd->to_eagain = 0; + while (rd->max_sends && rd->max_sends--) { + for (i = 0; i < SEQ_SIZE; i++) + seq_buf[i] = send_seq++; + + ret = send(sockfd, seq_buf, sizeof(seq_buf), MSG_DONTWAIT); + if (ret < 0) { + if (errno == EAGAIN) { + send_seq -= SEQ_SIZE; + break; + } + perror("send"); + return 1; + } else if (ret != sizeof(seq_buf)) { + fprintf(stderr, "short %d send\n", ret); + return 1; + } + + rd->to_eagain++; + rd->recv_bytes += sizeof(seq_buf); + } + + ptr = buf; + for (i = 0; i < nr_msgs; i++) { + unsigned long *pseq = ptr; + int j; + + for (j = 0; j < SEQ_SIZE; j++) + pseq[j] = send_seq++; + ptr += MSG_SIZE; + } + + /* prepare more messages, sending with bundle */ + rd->recv_bytes += (nr_msgs * MSG_SIZE); + if (rd->send_bundle && use_tcp) + ret = __do_send_bundle(rd, &ring, sockfd); + else + ret = __do_send(rd, &ring, sockfd); + if (ret) + goto err; + + pthread_barrier_wait(&rd->finish); + + close(sockfd); + io_uring_queue_exit(&ring); + return 0; + +err: + close(sockfd); +err2: + io_uring_queue_exit(&ring); + pthread_barrier_wait(&rd->finish); + return 1; +} + +static int test(int backlog, unsigned int max_sends, int *to_eagain, + int send_bundle, int recv_bundle) +{ + pthread_t recv_thread; + struct recv_data rd; + int ret; + void *retval; + + /* backlog not reliable on UDP, skip it */ + if ((backlog || max_sends) && !use_tcp) + return T_EXIT_PASS; + + memset(&rd, 0, sizeof(rd)); + pthread_barrier_init(&rd.connect, NULL, 2); + pthread_barrier_init(&rd.startup, NULL, 2); + pthread_barrier_init(&rd.barrier, NULL, 2); + pthread_barrier_init(&rd.finish, NULL, 2); + rd.max_sends = max_sends; + if (to_eagain) + *to_eagain = 0; + + rd.send_bundle = send_bundle; + rd.recv_bundle = recv_bundle; + + ret = pthread_create(&recv_thread, NULL, recv_fn, &rd); + if (ret) { + fprintf(stderr, "Thread create failed: %d\n", ret); + return 1; + } + + ret = do_send(&rd); + if (no_send_mshot) + return 0; + + if (ret) + return ret; + + pthread_join(recv_thread, &retval); + if (to_eagain) + *to_eagain = rd.to_eagain; + return (intptr_t)retval; +} + +static int run_tests(int is_udp) +{ + int ret, eagain_hit; + + nr_msgs = NR_MIN_MSGS; + + /* test basic send bundle first */ + ret = test(0, 0, NULL, 0, 0); + if (ret) { + fprintf(stderr, "test a failed\n"); + return T_EXIT_FAIL; + } + if (no_send_mshot) + return T_EXIT_SKIP; + + /* test recv bundle */ + ret = test(0, 0, NULL, 0, 1); + if (ret) { + fprintf(stderr, "test b failed\n"); + return T_EXIT_FAIL; + } + + /* test bundling recv and send */ + ret = test(0, 0, NULL, 1, 1); + if (ret) { + fprintf(stderr, "test c failed\n"); + return T_EXIT_FAIL; + } + + /* test bundling with full socket */ + ret = test(1, 1000000, &eagain_hit, 1, 1); + if (ret) { + fprintf(stderr, "test d failed\n"); + return T_EXIT_FAIL; + } + + /* test bundling with almost full socket */ + ret = test(1, eagain_hit - (nr_msgs / 2), NULL, 1, 1); + if (ret) { + fprintf(stderr, "test e failed\n"); + return T_EXIT_FAIL; + } + + /* test recv bundle with almost full socket */ + ret = test(1, eagain_hit - (nr_msgs / 2), NULL, 0, 1); + if (ret) { + fprintf(stderr, "test f failed\n"); + return T_EXIT_FAIL; + } + + if (is_udp) + return T_EXIT_PASS; + + /* test send bundle with almost full socket */ + ret = test(1, eagain_hit - (nr_msgs / 2), &eagain_hit, 1, 0); + if (ret) { + fprintf(stderr, "test g failed\n"); + return T_EXIT_FAIL; + } + + /* now repeat the last three tests, but with > FAST_UIOV segments */ + nr_msgs = NR_MAX_MSGS; + + /* test bundling with almost full socket */ + ret = test(1, eagain_hit - (nr_msgs / 2), NULL, 1, 1); + if (ret) { + fprintf(stderr, "test h failed\n"); + return T_EXIT_FAIL; + } + + /* test recv bundle with almost full socket */ + ret = test(1, eagain_hit - (nr_msgs / 2), NULL, 0, 1); + if (ret) { + fprintf(stderr, "test i failed\n"); + return T_EXIT_FAIL; + } + + /* test send bundle with almost full socket */ + ret = test(1, eagain_hit - (nr_msgs / 2), &eagain_hit, 1, 0); + if (ret) { + fprintf(stderr, "test j failed\n"); + return T_EXIT_FAIL; + } + + return T_EXIT_PASS; +} + +static int test_tcp(void) +{ + int ret; + + use_tcp = 1; + ret = run_tests(false); + if (ret == T_EXIT_FAIL) + fprintf(stderr, "TCP test case failed\n"); + return ret; +} + +static int test_udp(void) +{ + int ret; + + use_tcp = 0; + use_port++; + ret = run_tests(true); + if (ret == T_EXIT_FAIL) + fprintf(stderr, "UDP test case failed\n"); + return ret; +} + +int main(int argc, char *argv[]) +{ + int ret; + + if (argc > 1) + return T_EXIT_SKIP; + + ret = test_tcp(); + if (ret != T_EXIT_PASS) + return ret; + + ret = test_udp(); + if (ret != T_EXIT_PASS) + return ret; + + return T_EXIT_PASS; +} diff --git a/contrib/libs/liburing/test/recvsend_bundle.t/ya.make b/contrib/libs/liburing/test/recvsend_bundle.t/ya.make new file mode 100644 index 0000000000..d4928a810d --- /dev/null +++ b/contrib/libs/liburing/test/recvsend_bundle.t/ya.make @@ -0,0 +1,35 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +VERSION(2.7) + +LICENSE(MIT) + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + recvsend_bundle.c +) + +END() diff --git a/contrib/libs/liburing/test/reg-fd-only.t/ya.make b/contrib/libs/liburing/test/reg-fd-only.t/ya.make index 195e9896b6..373599e6c3 100644 --- a/contrib/libs/liburing/test/reg-fd-only.t/ya.make +++ b/contrib/libs/liburing/test/reg-fd-only.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/reg-hint.t/ya.make b/contrib/libs/liburing/test/reg-hint.t/ya.make index 930139eff6..1aaaff7170 100644 --- a/contrib/libs/liburing/test/reg-hint.t/ya.make +++ b/contrib/libs/liburing/test/reg-hint.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/reg-reg-ring.t/ya.make b/contrib/libs/liburing/test/reg-reg-ring.t/ya.make index 151beee463..09fb918298 100644 --- a/contrib/libs/liburing/test/reg-reg-ring.t/ya.make +++ b/contrib/libs/liburing/test/reg-reg-ring.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/regbuf-merge.t/ya.make b/contrib/libs/liburing/test/regbuf-merge.t/ya.make index b5ab2297a3..1a108c6c3e 100644 --- a/contrib/libs/liburing/test/regbuf-merge.t/ya.make +++ b/contrib/libs/liburing/test/regbuf-merge.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/register-restrictions.t/ya.make b/contrib/libs/liburing/test/register-restrictions.t/ya.make index bdb10012d2..6e5e8b92ee 100644 --- a/contrib/libs/liburing/test/register-restrictions.t/ya.make +++ b/contrib/libs/liburing/test/register-restrictions.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/rename.t/ya.make b/contrib/libs/liburing/test/rename.t/ya.make index e2c515d2f1..2c782d7d0a 100644 --- a/contrib/libs/liburing/test/rename.t/ya.make +++ b/contrib/libs/liburing/test/rename.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/ring-leak.t/ya.make b/contrib/libs/liburing/test/ring-leak.t/ya.make index 56f4dba6ee..bb0c0ded49 100644 --- a/contrib/libs/liburing/test/ring-leak.t/ya.make +++ b/contrib/libs/liburing/test/ring-leak.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/ring-leak2.t/ya.make b/contrib/libs/liburing/test/ring-leak2.t/ya.make index e805f0c20c..720bef28bc 100644 --- a/contrib/libs/liburing/test/ring-leak2.t/ya.make +++ b/contrib/libs/liburing/test/ring-leak2.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/ringbuf-read.t/ya.make b/contrib/libs/liburing/test/ringbuf-read.t/ya.make index a7566c0963..894e741045 100644 --- a/contrib/libs/liburing/test/ringbuf-read.t/ya.make +++ b/contrib/libs/liburing/test/ringbuf-read.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/ringbuf-status.t/ya.make b/contrib/libs/liburing/test/ringbuf-status.t/ya.make index 8ad9c1be50..5c45952a94 100644 --- a/contrib/libs/liburing/test/ringbuf-status.t/ya.make +++ b/contrib/libs/liburing/test/ringbuf-status.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/rsrc_tags.t/ya.make b/contrib/libs/liburing/test/rsrc_tags.t/ya.make index 766bd30f7c..7ad3a073e8 100644 --- a/contrib/libs/liburing/test/rsrc_tags.t/ya.make +++ b/contrib/libs/liburing/test/rsrc_tags.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/rw_merge_test.t/ya.make b/contrib/libs/liburing/test/rw_merge_test.t/ya.make index b0daa7fdd7..408f4de290 100644 --- a/contrib/libs/liburing/test/rw_merge_test.t/ya.make +++ b/contrib/libs/liburing/test/rw_merge_test.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/self.t/ya.make b/contrib/libs/liburing/test/self.t/ya.make index ac135e284f..d5a5f0ddc6 100644 --- a/contrib/libs/liburing/test/self.t/ya.make +++ b/contrib/libs/liburing/test/self.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/send-zerocopy.c b/contrib/libs/liburing/test/send-zerocopy.c index dab707d1e5..75149d55d3 100644 --- a/contrib/libs/liburing/test/send-zerocopy.c +++ b/contrib/libs/liburing/test/send-zerocopy.c @@ -72,6 +72,7 @@ static struct iovec buffers_iov[__BUF_NR]; static bool has_sendzc; static bool has_sendmsg; +static bool hit_enomem; static int probe_zc_support(void) { @@ -537,6 +538,17 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se if (cqe->user_data == nr_reqs - 1) expected = chunk_size_last; if (cqe->res != expected) { + if (cqe->res == -ENOMEM) { + if (!hit_enomem) { + fprintf(stderr, "Hit -ENOMEM. " + "Increase ulimit -l " + "limit for a complete " + "test run. Skipping " + "parts.\n"); + hit_enomem = 1; + } + return 0; + } fprintf(stderr, "invalid cqe->res %d expected %d\n", cqe->res, expected); return 1; diff --git a/contrib/libs/liburing/test/send-zerocopy.t/ya.make b/contrib/libs/liburing/test/send-zerocopy.t/ya.make index 049dd20e8b..8488fd09ad 100644 --- a/contrib/libs/liburing/test/send-zerocopy.t/ya.make +++ b/contrib/libs/liburing/test/send-zerocopy.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/send_recv.c b/contrib/libs/liburing/test/send_recv.c index 5bf929ba16..a5c78c42d3 100644 --- a/contrib/libs/liburing/test/send_recv.c +++ b/contrib/libs/liburing/test/send_recv.c @@ -24,7 +24,7 @@ static char str[] = "This is a test of send and recv over io_uring!"; #define HOST "127.0.0.1" static int recv_prep(struct io_uring *ring, struct iovec *iov, int *sock, - int registerfiles) + int registerfiles, int async, int provide) { struct sockaddr_in saddr; struct io_uring_sqe *sqe; @@ -65,6 +65,10 @@ static int recv_prep(struct io_uring *ring, struct iovec *iov, int *sock, io_uring_prep_recv(sqe, use_fd, iov->iov_base, iov->iov_len, 0); if (registerfiles) sqe->flags |= IOSQE_FIXED_FILE; + if (async) + sqe->flags |= IOSQE_ASYNC; + if (provide) + sqe->flags |= IOSQE_BUFFER_SELECT; sqe->user_data = 2; ret = io_uring_submit(ring); @@ -80,7 +84,7 @@ err: return 1; } -static int do_recv(struct io_uring *ring, struct iovec *iov) +static int do_recv(struct io_uring *ring, struct iovec *iov, int enobufs) { struct io_uring_cqe *cqe; int ret; @@ -88,11 +92,18 @@ static int do_recv(struct io_uring *ring, struct iovec *iov) ret = io_uring_wait_cqe(ring, &cqe); if (ret) { fprintf(stdout, "wait_cqe: %d\n", ret); - goto err; + return 1; } if (cqe->res == -EINVAL) { fprintf(stdout, "recv not supported, skipping\n"); - return 0; + goto out; + } + if (cqe->res == -ENOBUFS && enobufs) { + if (cqe->flags & IORING_CQE_F_SOCK_NONEMPTY) { + fprintf(stdout, "NONEMPTY set on -ENOBUFS\n"); + goto err; + } + goto out; } if (cqe->res < 0) { fprintf(stderr, "failed cqe: %d\n", cqe->res); @@ -110,8 +121,11 @@ static int do_recv(struct io_uring *ring, struct iovec *iov) goto err; } +out: + io_uring_cqe_seen(ring, cqe); return 0; err: + io_uring_cqe_seen(ring, cqe); return 1; } @@ -119,6 +133,8 @@ struct recv_data { pthread_mutex_t mutex; int use_sqthread; int registerfiles; + int async; + int provide; }; static void *recv_fn(void *data) @@ -153,13 +169,14 @@ static void *recv_fn(void *data) } } - ret = recv_prep(&ring, &iov, &sock, rd->registerfiles); + ret = recv_prep(&ring, &iov, &sock, rd->registerfiles, rd->async, + rd->provide); if (ret) { fprintf(stderr, "recv_prep failed: %d\n", ret); goto err; } pthread_mutex_unlock(&rd->mutex); - ret = do_recv(&ring, &iov); + ret = do_recv(&ring, &iov, rd->provide); close(sock); io_uring_queue_exit(&ring); @@ -233,7 +250,7 @@ err2: return 1; } -static int test(int use_sqthread, int regfiles) +static int test(int use_sqthread, int regfiles, int async, int provide) { pthread_mutexattr_t attr; pthread_t recv_thread; @@ -247,6 +264,8 @@ static int test(int use_sqthread, int regfiles) pthread_mutex_lock(&rd.mutex); rd.use_sqthread = use_sqthread; rd.registerfiles = regfiles; + rd.async = async; + rd.provide = provide; ret = pthread_create(&recv_thread, NULL, recv_fn, &rd); if (ret) { @@ -318,21 +337,75 @@ int main(int argc, char *argv[]) return ret; } - ret = test(0, 0); + ret = test(0, 0, 1, 1); + if (ret) { + fprintf(stderr, "test sqthread=0 1 1 failed\n"); + return ret; + } + + ret = test(1, 1, 1, 1); + if (ret) { + fprintf(stderr, "test sqthread=1 reg=1 1 1 failed\n"); + return ret; + } + + ret = test(1, 0, 1, 1); + if (ret) { + fprintf(stderr, "test sqthread=1 reg=0 1 1 failed\n"); + return ret; + } + + ret = test(0, 0, 0, 1); + if (ret) { + fprintf(stderr, "test sqthread=0 0 1 failed\n"); + return ret; + } + + ret = test(1, 1, 0, 1); + if (ret) { + fprintf(stderr, "test sqthread=1 reg=1 0 1 failed\n"); + return ret; + } + + ret = test(1, 0, 0, 1); + if (ret) { + fprintf(stderr, "test sqthread=1 reg=0 0 1 failed\n"); + return ret; + } + + ret = test(0, 0, 1, 0); + if (ret) { + fprintf(stderr, "test sqthread=0 0 1 failed\n"); + return ret; + } + + ret = test(1, 1, 1, 0); + if (ret) { + fprintf(stderr, "test sqthread=1 reg=1 1 0 failed\n"); + return ret; + } + + ret = test(1, 0, 1, 0); + if (ret) { + fprintf(stderr, "test sqthread=1 reg=0 1 0 failed\n"); + return ret; + } + + ret = test(0, 0, 0, 0); if (ret) { - fprintf(stderr, "test sqthread=0 failed\n"); + fprintf(stderr, "test sqthread=0 0 0 failed\n"); return ret; } - ret = test(1, 1); + ret = test(1, 1, 0, 0); if (ret) { - fprintf(stderr, "test sqthread=1 reg=1 failed\n"); + fprintf(stderr, "test sqthread=1 reg=1 0 0 failed\n"); return ret; } - ret = test(1, 0); + ret = test(1, 0, 0, 0); if (ret) { - fprintf(stderr, "test sqthread=1 reg=0 failed\n"); + fprintf(stderr, "test sqthread=1 reg=0 0 0 failed\n"); return ret; } diff --git a/contrib/libs/liburing/test/send_recv.t/ya.make b/contrib/libs/liburing/test/send_recv.t/ya.make index aa534fe667..9ebfd4beb7 100644 --- a/contrib/libs/liburing/test/send_recv.t/ya.make +++ b/contrib/libs/liburing/test/send_recv.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/send_recvmsg.t/ya.make b/contrib/libs/liburing/test/send_recvmsg.t/ya.make index 6f4f2e3591..819cfe1e8f 100644 --- a/contrib/libs/liburing/test/send_recvmsg.t/ya.make +++ b/contrib/libs/liburing/test/send_recvmsg.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/shared-wq.t/ya.make b/contrib/libs/liburing/test/shared-wq.t/ya.make index 0538f7b07b..7d6ec12f79 100644 --- a/contrib/libs/liburing/test/shared-wq.t/ya.make +++ b/contrib/libs/liburing/test/shared-wq.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/short-read.t/ya.make b/contrib/libs/liburing/test/short-read.t/ya.make index 010324515c..20b7807f6a 100644 --- a/contrib/libs/liburing/test/short-read.t/ya.make +++ b/contrib/libs/liburing/test/short-read.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/shutdown.t/ya.make b/contrib/libs/liburing/test/shutdown.t/ya.make index e99ccee83f..4f388e64a6 100644 --- a/contrib/libs/liburing/test/shutdown.t/ya.make +++ b/contrib/libs/liburing/test/shutdown.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/sigfd-deadlock.t/ya.make b/contrib/libs/liburing/test/sigfd-deadlock.t/ya.make index 7dae5c63f3..923d05efa3 100644 --- a/contrib/libs/liburing/test/sigfd-deadlock.t/ya.make +++ b/contrib/libs/liburing/test/sigfd-deadlock.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/single-issuer.t/ya.make b/contrib/libs/liburing/test/single-issuer.t/ya.make index 4dc1e6fb9a..22b9933c40 100644 --- a/contrib/libs/liburing/test/single-issuer.t/ya.make +++ b/contrib/libs/liburing/test/single-issuer.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/skip-cqe.t/ya.make b/contrib/libs/liburing/test/skip-cqe.t/ya.make index 3e173bc25e..b2d5c9ae5a 100644 --- a/contrib/libs/liburing/test/skip-cqe.t/ya.make +++ b/contrib/libs/liburing/test/skip-cqe.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/socket-getsetsock-cmd.c b/contrib/libs/liburing/test/socket-getsetsock-cmd.c index 275ac66537..3512983f21 100644 --- a/contrib/libs/liburing/test/socket-getsetsock-cmd.c +++ b/contrib/libs/liburing/test/socket-getsetsock-cmd.c @@ -54,7 +54,8 @@ static struct io_uring create_ring(void) static int submit_cmd_sqe(struct io_uring *ring, int32_t fd, int op, int level, int optname, - void *optval, int optlen) + void *optval, int optlen, + bool async) { struct io_uring_sqe *sqe; int err; @@ -66,6 +67,8 @@ static int submit_cmd_sqe(struct io_uring *ring, int32_t fd, io_uring_prep_cmd_sock(sqe, op, fd, level, optname, optval, optlen); sqe->user_data = USERDATA; + if (async) + sqe->flags |= IOSQE_ASYNC; /* Submitting SQE */ err = io_uring_submit_and_wait(ring, 1); @@ -93,7 +96,7 @@ static int receive_cqe(struct io_uring *ring) * Run getsock operation using SO_RCVBUF using io_uring cmd operation and * getsockopt(2) and compare the results. */ -static int run_get_rcvbuf(struct io_uring *ring, struct fds *sockfds) +static int run_get_rcvbuf(struct io_uring *ring, struct fds *sockfds, bool async) { int sval, uval, ulen, err; unsigned int slen; @@ -105,7 +108,7 @@ static int run_get_rcvbuf(struct io_uring *ring, struct fds *sockfds) /* get through io_uring cmd */ err = submit_cmd_sqe(ring, sockfds->rx, SOCKET_URING_OP_GETSOCKOPT, - SOL_SOCKET, SO_RCVBUF, &uval, ulen); + SOL_SOCKET, SO_RCVBUF, &uval, ulen, async); assert(err == 1); /* Wait for the CQE */ @@ -134,7 +137,7 @@ static int run_get_rcvbuf(struct io_uring *ring, struct fds *sockfds) * Run getsock operation using SO_PEERNAME using io_uring cmd operation * and getsockopt(2) and compare the results. */ -static int run_get_peername(struct io_uring *ring, struct fds *sockfds) +static int run_get_peername(struct io_uring *ring, struct fds *sockfds, bool async) { struct sockaddr sval, uval = {}; socklen_t slen = sizeof(sval); @@ -147,7 +150,7 @@ static int run_get_peername(struct io_uring *ring, struct fds *sockfds) /* Getting SO_PEERNAME */ err = submit_cmd_sqe(ring, sockfds->rx, SOCKET_URING_OP_GETSOCKOPT, - SOL_SOCKET, SO_PEERNAME, &uval, ulen); + SOL_SOCKET, SO_PEERNAME, &uval, ulen, async); assert(err == 1); /* Wait for the CQE */ @@ -179,20 +182,27 @@ static int run_getsockopt_test(struct io_uring *ring, struct fds *sockfds) { int err; - fprintf(stderr, "Testing getsockopt SO_PEERNAME\n"); - err = run_get_peername(ring, sockfds); + err = run_get_peername(ring, sockfds, false); if (err) return err; - fprintf(stderr, "Testing getsockopt SO_RCVBUF\n"); - return run_get_rcvbuf(ring, sockfds); + err = run_get_peername(ring, sockfds, true); + if (err) + return err; + + err = run_get_rcvbuf(ring, sockfds, false); + if (err) + return err; + + return run_get_rcvbuf(ring, sockfds, true); } /* * Given a `val` value, set it in SO_REUSEPORT using io_uring cmd, and read using * getsockopt(2), and make sure they match. */ -static int run_setsockopt_reuseport(struct io_uring *ring, struct fds *sockfds, int val) +static int run_setsockopt_reuseport(struct io_uring *ring, struct fds *sockfds, + int val, bool async) { unsigned int slen, ulen; int sval, uval = val; @@ -203,7 +213,7 @@ static int run_setsockopt_reuseport(struct io_uring *ring, struct fds *sockfds, /* Setting SO_REUSEPORT */ err = submit_cmd_sqe(ring, sockfds->rx, SOCKET_URING_OP_SETSOCKOPT, - SOL_SOCKET, SO_REUSEPORT, &uval, ulen); + SOL_SOCKET, SO_REUSEPORT, &uval, ulen, async); assert(err == 1); err = receive_cqe(ring); @@ -225,7 +235,8 @@ static int run_setsockopt_reuseport(struct io_uring *ring, struct fds *sockfds, * Given a `val` value, set the TCP_USER_TIMEOUT using io_uring and read using * getsockopt(2). Make sure they match */ -static int run_setsockopt_usertimeout(struct io_uring *ring, struct fds *sockfds, int val) +static int run_setsockopt_usertimeout(struct io_uring *ring, struct fds *sockfds, + int val, bool async) { int optname = TCP_USER_TIMEOUT; int level = IPPROTO_TCP; @@ -239,7 +250,7 @@ static int run_setsockopt_usertimeout(struct io_uring *ring, struct fds *sockfds /* Setting timeout */ err = submit_cmd_sqe(ring, sockfds->rx, SOCKET_URING_OP_SETSOCKOPT, - level, optname, &uval, ulen); + level, optname, &uval, ulen, async); assert(err == 1); err = receive_cqe(ring); @@ -262,19 +273,22 @@ static int run_setsockopt_usertimeout(struct io_uring *ring, struct fds *sockfds static int run_setsockopt_test(struct io_uring *ring, struct fds *sockfds) { int err, i; + int j; - fprintf(stderr, "Testing setsockopt SOL_SOCKET/SO_REUSEPORT\n"); - for (i = 0; i <= 1; i++) { - err = run_setsockopt_reuseport(ring, sockfds, i); - if (err) - return err; - } + for (j = 0; j < 2; j++) { + bool async = j & 1; - fprintf(stderr, "Testing setsockopt IPPROTO_TCP/TCP_FASTOPEN\n"); - for (i = 1; i <= 10; i++) { - err = run_setsockopt_usertimeout(ring, sockfds, i); - if (err) - return err; + for (i = 0; i <= 1; i++) { + err = run_setsockopt_reuseport(ring, sockfds, i, async); + if (err) + return err; + } + + for (i = 1; i <= 10; i++) { + err = run_setsockopt_usertimeout(ring, sockfds, i, async); + if (err) + return err; + } } return err; diff --git a/contrib/libs/liburing/test/socket-getsetsock-cmd.t/ya.make b/contrib/libs/liburing/test/socket-getsetsock-cmd.t/ya.make index cfb50a091f..17a58600d7 100644 --- a/contrib/libs/liburing/test/socket-getsetsock-cmd.t/ya.make +++ b/contrib/libs/liburing/test/socket-getsetsock-cmd.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/socket-io-cmd.t/ya.make b/contrib/libs/liburing/test/socket-io-cmd.t/ya.make index 0d95a370f2..1bef521386 100644 --- a/contrib/libs/liburing/test/socket-io-cmd.t/ya.make +++ b/contrib/libs/liburing/test/socket-io-cmd.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/socket-rw-eagain.t/ya.make b/contrib/libs/liburing/test/socket-rw-eagain.t/ya.make index d6c6124cec..b8be4cd81a 100644 --- a/contrib/libs/liburing/test/socket-rw-eagain.t/ya.make +++ b/contrib/libs/liburing/test/socket-rw-eagain.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/socket-rw-offset.t/ya.make b/contrib/libs/liburing/test/socket-rw-offset.t/ya.make index 8274260532..58f6331b37 100644 --- a/contrib/libs/liburing/test/socket-rw-offset.t/ya.make +++ b/contrib/libs/liburing/test/socket-rw-offset.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/socket-rw.t/ya.make b/contrib/libs/liburing/test/socket-rw.t/ya.make index 1b276d2ade..df06bc4449 100644 --- a/contrib/libs/liburing/test/socket-rw.t/ya.make +++ b/contrib/libs/liburing/test/socket-rw.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/socket.t/ya.make b/contrib/libs/liburing/test/socket.t/ya.make index c5598df6c4..598bf99516 100644 --- a/contrib/libs/liburing/test/socket.t/ya.make +++ b/contrib/libs/liburing/test/socket.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/splice.t/ya.make b/contrib/libs/liburing/test/splice.t/ya.make index 1fe1ab6f95..2dc1ee706a 100644 --- a/contrib/libs/liburing/test/splice.t/ya.make +++ b/contrib/libs/liburing/test/splice.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/sq-full-cpp.t/ya.make b/contrib/libs/liburing/test/sq-full-cpp.t/ya.make index 26e1aafe13..5a4d26b61a 100644 --- a/contrib/libs/liburing/test/sq-full-cpp.t/ya.make +++ b/contrib/libs/liburing/test/sq-full-cpp.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/sq-full.t/ya.make b/contrib/libs/liburing/test/sq-full.t/ya.make index 14f2839dbc..baa4eb0cf5 100644 --- a/contrib/libs/liburing/test/sq-full.t/ya.make +++ b/contrib/libs/liburing/test/sq-full.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/sq-poll-dup.t/ya.make b/contrib/libs/liburing/test/sq-poll-dup.t/ya.make index ecd16fb29e..9e86468e20 100644 --- a/contrib/libs/liburing/test/sq-poll-dup.t/ya.make +++ b/contrib/libs/liburing/test/sq-poll-dup.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/sq-poll-kthread.t/ya.make b/contrib/libs/liburing/test/sq-poll-kthread.t/ya.make index 3457033f1b..61be5885c7 100644 --- a/contrib/libs/liburing/test/sq-poll-kthread.t/ya.make +++ b/contrib/libs/liburing/test/sq-poll-kthread.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/sq-poll-share.t/ya.make b/contrib/libs/liburing/test/sq-poll-share.t/ya.make index 7594905de6..7b739bc0f6 100644 --- a/contrib/libs/liburing/test/sq-poll-share.t/ya.make +++ b/contrib/libs/liburing/test/sq-poll-share.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/sq-space_left.t/ya.make b/contrib/libs/liburing/test/sq-space_left.t/ya.make index d2796f2a0b..f23eec434a 100644 --- a/contrib/libs/liburing/test/sq-space_left.t/ya.make +++ b/contrib/libs/liburing/test/sq-space_left.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/sqpoll-disable-exit.t/ya.make b/contrib/libs/liburing/test/sqpoll-disable-exit.t/ya.make index 19017498ea..69163bf995 100644 --- a/contrib/libs/liburing/test/sqpoll-disable-exit.t/ya.make +++ b/contrib/libs/liburing/test/sqpoll-disable-exit.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/sqpoll-exec.c b/contrib/libs/liburing/test/sqpoll-exec.c new file mode 100644 index 0000000000..069171b272 --- /dev/null +++ b/contrib/libs/liburing/test/sqpoll-exec.c @@ -0,0 +1,133 @@ +#include "../config-host.h" +/* SPDX-License-Identifier: MIT */ +/* + * Description: Check that closing a file with SQPOLL has it immediately closed + * upon receiving the CQE for the close. The 6.9 kernel had a bug + * where SQPOLL would not run kernel wide task_work when running the + * private task_work, which would defer the close if this was the + * final close of the file. + */ +#include <errno.h> +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <string.h> +#include <fcntl.h> +#include <sys/time.h> +#include <sys/wait.h> +#include <sys/types.h> +#include <sys/stat.h> + +#include "helpers.h" +#include "liburing.h" + +static int fill_exec_target(char *dst, char *path) +{ + struct stat sb; + + /* + * Should either be ./exec-target.t or test/exec-target.t + */ + sprintf(dst, "%s", path); + return stat(dst, &sb); +} + +static int test_exec(struct io_uring *ring, char * const argv[]) +{ + char prog_path[PATH_MAX]; + struct io_uring_sqe *sqe; + struct io_uring_cqe *cqe; + int ret, wstatus, fd; + pid_t p; + + if (fill_exec_target(prog_path, "./exec-target.t") && + fill_exec_target(prog_path, "test/exec-target.t")) { + fprintf(stdout, "Can't find exec-target, skipping\n"); + return 0; + } + + sqe = io_uring_get_sqe(ring); + io_uring_prep_openat(sqe, AT_FDCWD, prog_path, O_WRONLY, 0); + sqe->user_data = 0; + + io_uring_submit(ring); + + ret = io_uring_wait_cqe(ring, &cqe); + if (ret) { + fprintf(stderr, "wait cqe %d\n", ret); + return 1; + } + if (cqe->res < 0) { + fprintf(stderr, "open: %d\n", cqe->res); + return 1; + } + fd = cqe->res; + io_uring_cqe_seen(ring, cqe); + + sqe = io_uring_get_sqe(ring); + io_uring_prep_close(sqe, fd); + sqe->user_data = 1; + + io_uring_submit(ring); + + ret = io_uring_wait_cqe(ring, &cqe); + if (ret) { + fprintf(stderr, "wait cqe %d\n", ret); + return 1; + } + if (cqe->res < 0) { + fprintf(stderr, "close: %d\n", cqe->res); + return 1; + } + io_uring_cqe_seen(ring, cqe); + + p = fork(); + if (p == -1) { + fprintf(stderr, "fork() failed\n"); + return 1; + } + + if (p == 0) { + /* file should be closed, try exec'ing it */ + ret = execve(prog_path, argv, NULL); + if (ret) { + fprintf(stderr, "exec failed: %s\n", strerror(errno)); + exit(1); + } + } + + if (waitpid(p, &wstatus, 0) == (pid_t)-1) { + perror("waitpid()"); + return 1; + } + if (!WIFEXITED(wstatus) || WEXITSTATUS(wstatus)) + return 1; + + return 0; +} + +int main(int argc, char * const argv[]) +{ + struct io_uring_params p = { .flags = IORING_SETUP_SQPOLL, }; + struct io_uring ring; + int ret, i; + + if (argc > 1) + return T_EXIT_SKIP; + + ret = t_create_ring_params(8, &ring, &p); + if (ret == T_SETUP_SKIP) + return T_EXIT_SKIP; + else if (ret != T_SETUP_OK) + return T_EXIT_FAIL; + + for (i = 0; i < 20; i++) { + ret = test_exec(&ring, argv); + if (ret) { + fprintf(stderr, "test_exec failed\n"); + return ret; + } + } + + return T_EXIT_PASS; +} diff --git a/contrib/libs/liburing/test/sqpoll-exec.t/ya.make b/contrib/libs/liburing/test/sqpoll-exec.t/ya.make new file mode 100644 index 0000000000..7c98e7a947 --- /dev/null +++ b/contrib/libs/liburing/test/sqpoll-exec.t/ya.make @@ -0,0 +1,35 @@ +# Generated by devtools/yamaker. + +PROGRAM() + +WITHOUT_LICENSE_TEXTS() + +VERSION(2.7) + +LICENSE(MIT) + +PEERDIR( + contrib/libs/liburing +) + +ADDINCL( + contrib/libs/liburing/src/include +) + +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + +CFLAGS( + -DLIBURING_BUILD_TEST + -D__SANE_USERSPACE_TYPES__ +) + +SRCDIR(contrib/libs/liburing/test) + +SRCS( + helpers.c + sqpoll-exec.c +) + +END() diff --git a/contrib/libs/liburing/test/sqpoll-exit-hang.t/ya.make b/contrib/libs/liburing/test/sqpoll-exit-hang.t/ya.make index ace1abebdd..c3fdac8493 100644 --- a/contrib/libs/liburing/test/sqpoll-exit-hang.t/ya.make +++ b/contrib/libs/liburing/test/sqpoll-exit-hang.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/sqpoll-sleep.t/ya.make b/contrib/libs/liburing/test/sqpoll-sleep.t/ya.make index 3319f3a922..ccf2774f1d 100644 --- a/contrib/libs/liburing/test/sqpoll-sleep.t/ya.make +++ b/contrib/libs/liburing/test/sqpoll-sleep.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/stdout.t/ya.make b/contrib/libs/liburing/test/stdout.t/ya.make index 5fe98974f1..53a1c134cc 100644 --- a/contrib/libs/liburing/test/stdout.t/ya.make +++ b/contrib/libs/liburing/test/stdout.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/submit-and-wait.t/ya.make b/contrib/libs/liburing/test/submit-and-wait.t/ya.make index ed3d422e6d..63234cd835 100644 --- a/contrib/libs/liburing/test/submit-and-wait.t/ya.make +++ b/contrib/libs/liburing/test/submit-and-wait.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/submit-link-fail.t/ya.make b/contrib/libs/liburing/test/submit-link-fail.t/ya.make index ff0304284b..342296fe78 100644 --- a/contrib/libs/liburing/test/submit-link-fail.t/ya.make +++ b/contrib/libs/liburing/test/submit-link-fail.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/submit-reuse.t/ya.make b/contrib/libs/liburing/test/submit-reuse.t/ya.make index a230e5db4d..05b78c046d 100644 --- a/contrib/libs/liburing/test/submit-reuse.t/ya.make +++ b/contrib/libs/liburing/test/submit-reuse.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/symlink.t/ya.make b/contrib/libs/liburing/test/symlink.t/ya.make index 334bc6be8a..781a2bacff 100644 --- a/contrib/libs/liburing/test/symlink.t/ya.make +++ b/contrib/libs/liburing/test/symlink.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/sync-cancel.t/ya.make b/contrib/libs/liburing/test/sync-cancel.t/ya.make index 565e12e143..d6a5a15318 100644 --- a/contrib/libs/liburing/test/sync-cancel.t/ya.make +++ b/contrib/libs/liburing/test/sync-cancel.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/teardowns.t/ya.make b/contrib/libs/liburing/test/teardowns.t/ya.make index 9572eafd2b..f227ee9f18 100644 --- a/contrib/libs/liburing/test/teardowns.t/ya.make +++ b/contrib/libs/liburing/test/teardowns.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/thread-exit.t/ya.make b/contrib/libs/liburing/test/thread-exit.t/ya.make index 36a413aead..eefdfcf3f1 100644 --- a/contrib/libs/liburing/test/thread-exit.t/ya.make +++ b/contrib/libs/liburing/test/thread-exit.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/timeout-new.t/ya.make b/contrib/libs/liburing/test/timeout-new.t/ya.make index 4996ca45c2..1303f2cf15 100644 --- a/contrib/libs/liburing/test/timeout-new.t/ya.make +++ b/contrib/libs/liburing/test/timeout-new.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/timeout.c b/contrib/libs/liburing/test/timeout.c index d43c15db17..8e3c7bdf7c 100644 --- a/contrib/libs/liburing/test/timeout.c +++ b/contrib/libs/liburing/test/timeout.c @@ -1234,7 +1234,7 @@ static int test_timeout_link_cancel(void) exit(1); } - /* trigger full cancellation */ + /* trigger full cancelation */ ret = execl(prog_path, prog_path, NULL); if (ret) { fprintf(stderr, "exec failed %i\n", errno); diff --git a/contrib/libs/liburing/test/timeout.t/ya.make b/contrib/libs/liburing/test/timeout.t/ya.make index 59de54895c..3b26c010dd 100644 --- a/contrib/libs/liburing/test/timeout.t/ya.make +++ b/contrib/libs/liburing/test/timeout.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/truncate.t/ya.make b/contrib/libs/liburing/test/truncate.t/ya.make index b347333a79..6a4e13ab41 100644 --- a/contrib/libs/liburing/test/truncate.t/ya.make +++ b/contrib/libs/liburing/test/truncate.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/tty-write-dpoll.t/ya.make b/contrib/libs/liburing/test/tty-write-dpoll.t/ya.make index b870c76dbd..f51141ac1e 100644 --- a/contrib/libs/liburing/test/tty-write-dpoll.t/ya.make +++ b/contrib/libs/liburing/test/tty-write-dpoll.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/unlink.t/ya.make b/contrib/libs/liburing/test/unlink.t/ya.make index 1e299f0c2a..8c6bf7cdc3 100644 --- a/contrib/libs/liburing/test/unlink.t/ya.make +++ b/contrib/libs/liburing/test/unlink.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/version.t/ya.make b/contrib/libs/liburing/test/version.t/ya.make index 53fbb57536..8f387e4ca4 100644 --- a/contrib/libs/liburing/test/version.t/ya.make +++ b/contrib/libs/liburing/test/version.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/waitid.t/ya.make b/contrib/libs/liburing/test/waitid.t/ya.make index cd026f76fd..d1b66baa8b 100644 --- a/contrib/libs/liburing/test/waitid.t/ya.make +++ b/contrib/libs/liburing/test/waitid.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/wakeup-hang.t/ya.make b/contrib/libs/liburing/test/wakeup-hang.t/ya.make index cb952544e5..32f72dadef 100644 --- a/contrib/libs/liburing/test/wakeup-hang.t/ya.make +++ b/contrib/libs/liburing/test/wakeup-hang.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/wq-aff.t/ya.make b/contrib/libs/liburing/test/wq-aff.t/ya.make index afe992a717..fc8c72502a 100644 --- a/contrib/libs/liburing/test/wq-aff.t/ya.make +++ b/contrib/libs/liburing/test/wq-aff.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/test/xattr.t/ya.make b/contrib/libs/liburing/test/xattr.t/ya.make index 75bde60951..9a4d76006a 100644 --- a/contrib/libs/liburing/test/xattr.t/ya.make +++ b/contrib/libs/liburing/test/xattr.t/ya.make @@ -4,7 +4,7 @@ PROGRAM() WITHOUT_LICENSE_TEXTS() -VERSION(2.6) +VERSION(2.7) LICENSE(MIT) diff --git a/contrib/libs/liburing/ya.make b/contrib/libs/liburing/ya.make index 691e937324..9ee5aee27d 100644 --- a/contrib/libs/liburing/ya.make +++ b/contrib/libs/liburing/ya.make @@ -2,9 +2,9 @@ LIBRARY() -VERSION(2.6) +VERSION(2.7) -ORIGINAL_SOURCE(https://github.com/axboe/liburing/archive/liburing-2.6.tar.gz) +ORIGINAL_SOURCE(https://github.com/axboe/liburing/archive/liburing-2.7.tar.gz) LICENSE( "(GPL-2.0-only WITH Linux-syscall-note OR MIT)" AND @@ -47,12 +47,14 @@ RECURSE( test/a0908ae19763.t test/a4c0b3decb33.t test/accept-link.t + test/accept-non-empty.t test/accept-reuse.t test/accept-test.t test/accept.t test/across-fork.t test/b19062a56726.t test/b5837bd5311d.t + test/bind-listen.t test/buf-ring-nommap.t test/buf-ring-put.t test/buf-ring.t @@ -95,12 +97,15 @@ RECURSE( test/files-exit-hang-timeout.t test/fixed-buf-iter.t test/fixed-buf-merge.t + test/fixed-hugepage.t test/fixed-link.t test/fixed-reuse.t test/fpos.t test/fsync.t test/futex.t test/hardlink.t + test/ignore-single-mmap.t + test/init-mem.t test/io-cancel.t test/io_uring_enter.t test/io_uring_passthrough.t @@ -125,6 +130,7 @@ RECURSE( test/nolibc.t test/nop-all-sizes.t test/nop.t + test/ooo-file-unreg.t test/open-close.t test/open-direct-link.t test/open-direct-pick.t @@ -153,6 +159,7 @@ RECURSE( test/recv-msgall-stream.t test/recv-msgall.t test/recv-multishot.t + test/recvsend_bundle.t test/reg-fd-only.t test/reg-hint.t test/reg-reg-ring.t @@ -189,6 +196,7 @@ RECURSE( test/sq-poll-share.t test/sq-space_left.t test/sqpoll-disable-exit.t + test/sqpoll-exec.t test/sqpoll-exit-hang.t test/sqpoll-sleep.t test/stdout.t |