@nxtedition/rocksdb 5.2.36 → 5.2.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding.cc +66 -91
- package/deps/liburing/liburing/COPYING +502 -0
- package/deps/liburing/liburing/COPYING.GPL +339 -0
- package/deps/liburing/liburing/LICENSE +7 -0
- package/deps/liburing/liburing/Makefile +84 -0
- package/deps/liburing/liburing/Makefile.quiet +11 -0
- package/deps/liburing/liburing/README +46 -0
- package/deps/liburing/liburing/configure +420 -0
- package/deps/liburing/liburing/debian/README.Debian +7 -0
- package/deps/liburing/liburing/debian/changelog +27 -0
- package/deps/liburing/liburing/debian/compat +1 -0
- package/deps/liburing/liburing/debian/control +48 -0
- package/deps/liburing/liburing/debian/copyright +49 -0
- package/deps/liburing/liburing/debian/liburing-dev.install +4 -0
- package/deps/liburing/liburing/debian/liburing-dev.manpages +6 -0
- package/deps/liburing/liburing/debian/liburing1-udeb.install +1 -0
- package/deps/liburing/liburing/debian/liburing1.install +1 -0
- package/deps/liburing/liburing/debian/liburing1.symbols +32 -0
- package/deps/liburing/liburing/debian/patches/series +1 -0
- package/deps/liburing/liburing/debian/rules +81 -0
- package/deps/liburing/liburing/debian/source/format +1 -0
- package/deps/liburing/liburing/debian/source/local-options +2 -0
- package/deps/liburing/liburing/debian/source/options +1 -0
- package/deps/liburing/liburing/debian/watch +3 -0
- package/deps/liburing/liburing/examples/Makefile +29 -0
- package/deps/liburing/liburing/examples/io_uring-cp.c +279 -0
- package/deps/liburing/liburing/examples/io_uring-test.c +112 -0
- package/deps/liburing/liburing/examples/link-cp.c +193 -0
- package/deps/liburing/liburing/examples/ucontext-cp.c +273 -0
- package/deps/liburing/liburing/liburing.pc.in +12 -0
- package/deps/liburing/liburing/liburing.spec +66 -0
- package/deps/liburing/liburing/make-debs.sh +53 -0
- package/deps/liburing/liburing/man/io_uring.7 +736 -0
- package/deps/liburing/liburing/man/io_uring_enter.2 +1403 -0
- package/deps/liburing/liburing/man/io_uring_get_sqe.3 +37 -0
- package/deps/liburing/liburing/man/io_uring_queue_exit.3 +27 -0
- package/deps/liburing/liburing/man/io_uring_queue_init.3 +44 -0
- package/deps/liburing/liburing/man/io_uring_register.2 +605 -0
- package/deps/liburing/liburing/man/io_uring_setup.2 +515 -0
- package/deps/liburing/liburing/src/Makefile +76 -0
- package/deps/liburing/liburing/src/include/liburing/barrier.h +73 -0
- package/deps/liburing/liburing/src/include/liburing/io_uring.h +422 -0
- package/deps/liburing/liburing/src/include/liburing.h +775 -0
- package/deps/liburing/liburing/src/liburing.map +46 -0
- package/deps/liburing/liburing/src/queue.c +403 -0
- package/deps/liburing/liburing/src/register.c +299 -0
- package/deps/liburing/liburing/src/setup.c +356 -0
- package/deps/liburing/liburing/src/syscall.c +73 -0
- package/deps/liburing/liburing/src/syscall.h +20 -0
- package/deps/liburing/liburing/test/232c93d07b74-test.c +305 -0
- package/deps/liburing/liburing/test/35fa71a030ca-test.c +329 -0
- package/deps/liburing/liburing/test/500f9fbadef8-test.c +89 -0
- package/deps/liburing/liburing/test/7ad0e4b2f83c-test.c +93 -0
- package/deps/liburing/liburing/test/8a9973408177-test.c +106 -0
- package/deps/liburing/liburing/test/917257daa0fe-test.c +53 -0
- package/deps/liburing/liburing/test/Makefile +312 -0
- package/deps/liburing/liburing/test/a0908ae19763-test.c +58 -0
- package/deps/liburing/liburing/test/a4c0b3decb33-test.c +180 -0
- package/deps/liburing/liburing/test/accept-link.c +251 -0
- package/deps/liburing/liburing/test/accept-reuse.c +164 -0
- package/deps/liburing/liburing/test/accept-test.c +79 -0
- package/deps/liburing/liburing/test/accept.c +476 -0
- package/deps/liburing/liburing/test/across-fork.c +283 -0
- package/deps/liburing/liburing/test/b19062a56726-test.c +53 -0
- package/deps/liburing/liburing/test/b5837bd5311d-test.c +77 -0
- package/deps/liburing/liburing/test/ce593a6c480a-test.c +135 -0
- package/deps/liburing/liburing/test/close-opath.c +122 -0
- package/deps/liburing/liburing/test/config +10 -0
- package/deps/liburing/liburing/test/connect.c +398 -0
- package/deps/liburing/liburing/test/cq-full.c +96 -0
- package/deps/liburing/liburing/test/cq-overflow.c +294 -0
- package/deps/liburing/liburing/test/cq-peek-batch.c +102 -0
- package/deps/liburing/liburing/test/cq-ready.c +94 -0
- package/deps/liburing/liburing/test/cq-size.c +58 -0
- package/deps/liburing/liburing/test/d4ae271dfaae-test.c +96 -0
- package/deps/liburing/liburing/test/d77a67ed5f27-test.c +65 -0
- package/deps/liburing/liburing/test/defer.c +307 -0
- package/deps/liburing/liburing/test/double-poll-crash.c +186 -0
- package/deps/liburing/liburing/test/eeed8b54e0df-test.c +114 -0
- package/deps/liburing/liburing/test/empty-eownerdead.c +42 -0
- package/deps/liburing/liburing/test/eventfd-disable.c +151 -0
- package/deps/liburing/liburing/test/eventfd-ring.c +97 -0
- package/deps/liburing/liburing/test/eventfd.c +112 -0
- package/deps/liburing/liburing/test/fadvise.c +202 -0
- package/deps/liburing/liburing/test/fallocate.c +249 -0
- package/deps/liburing/liburing/test/fc2a85cb02ef-test.c +138 -0
- package/deps/liburing/liburing/test/file-register.c +843 -0
- package/deps/liburing/liburing/test/file-update.c +173 -0
- package/deps/liburing/liburing/test/files-exit-hang-poll.c +128 -0
- package/deps/liburing/liburing/test/files-exit-hang-timeout.c +134 -0
- package/deps/liburing/liburing/test/fixed-link.c +90 -0
- package/deps/liburing/liburing/test/fsync.c +224 -0
- package/deps/liburing/liburing/test/hardlink.c +136 -0
- package/deps/liburing/liburing/test/helpers.c +135 -0
- package/deps/liburing/liburing/test/helpers.h +67 -0
- package/deps/liburing/liburing/test/io-cancel.c +537 -0
- package/deps/liburing/liburing/test/io_uring_enter.c +296 -0
- package/deps/liburing/liburing/test/io_uring_register.c +664 -0
- package/deps/liburing/liburing/test/io_uring_setup.c +192 -0
- package/deps/liburing/liburing/test/iopoll.c +366 -0
- package/deps/liburing/liburing/test/lfs-openat-write.c +117 -0
- package/deps/liburing/liburing/test/lfs-openat.c +273 -0
- package/deps/liburing/liburing/test/link-timeout.c +1107 -0
- package/deps/liburing/liburing/test/link.c +496 -0
- package/deps/liburing/liburing/test/link_drain.c +229 -0
- package/deps/liburing/liburing/test/madvise.c +195 -0
- package/deps/liburing/liburing/test/mkdir.c +108 -0
- package/deps/liburing/liburing/test/multicqes_drain.c +383 -0
- package/deps/liburing/liburing/test/nop-all-sizes.c +107 -0
- package/deps/liburing/liburing/test/nop.c +115 -0
- package/deps/liburing/liburing/test/open-close.c +146 -0
- package/deps/liburing/liburing/test/openat2.c +240 -0
- package/deps/liburing/liburing/test/personality.c +204 -0
- package/deps/liburing/liburing/test/pipe-eof.c +81 -0
- package/deps/liburing/liburing/test/pipe-reuse.c +105 -0
- package/deps/liburing/liburing/test/poll-cancel-ton.c +139 -0
- package/deps/liburing/liburing/test/poll-cancel.c +135 -0
- package/deps/liburing/liburing/test/poll-link.c +227 -0
- package/deps/liburing/liburing/test/poll-many.c +208 -0
- package/deps/liburing/liburing/test/poll-mshot-update.c +273 -0
- package/deps/liburing/liburing/test/poll-ring.c +48 -0
- package/deps/liburing/liburing/test/poll-v-poll.c +353 -0
- package/deps/liburing/liburing/test/poll.c +109 -0
- package/deps/liburing/liburing/test/probe.c +137 -0
- package/deps/liburing/liburing/test/read-write.c +876 -0
- package/deps/liburing/liburing/test/register-restrictions.c +633 -0
- package/deps/liburing/liburing/test/rename.c +134 -0
- package/deps/liburing/liburing/test/ring-leak.c +173 -0
- package/deps/liburing/liburing/test/ring-leak2.c +249 -0
- package/deps/liburing/liburing/test/rsrc_tags.c +449 -0
- package/deps/liburing/liburing/test/runtests-loop.sh +16 -0
- package/deps/liburing/liburing/test/runtests.sh +170 -0
- package/deps/liburing/liburing/test/rw_merge_test.c +97 -0
- package/deps/liburing/liburing/test/self.c +91 -0
- package/deps/liburing/liburing/test/send_recv.c +291 -0
- package/deps/liburing/liburing/test/send_recvmsg.c +345 -0
- package/deps/liburing/liburing/test/sendmsg_fs_cve.c +198 -0
- package/deps/liburing/liburing/test/shared-wq.c +84 -0
- package/deps/liburing/liburing/test/short-read.c +75 -0
- package/deps/liburing/liburing/test/shutdown.c +163 -0
- package/deps/liburing/liburing/test/sigfd-deadlock.c +74 -0
- package/deps/liburing/liburing/test/socket-rw-eagain.c +156 -0
- package/deps/liburing/liburing/test/socket-rw.c +147 -0
- package/deps/liburing/liburing/test/splice.c +511 -0
- package/deps/liburing/liburing/test/sq-full-cpp.cc +45 -0
- package/deps/liburing/liburing/test/sq-full.c +45 -0
- package/deps/liburing/liburing/test/sq-poll-dup.c +200 -0
- package/deps/liburing/liburing/test/sq-poll-kthread.c +168 -0
- package/deps/liburing/liburing/test/sq-poll-share.c +137 -0
- package/deps/liburing/liburing/test/sq-space_left.c +159 -0
- package/deps/liburing/liburing/test/sqpoll-cancel-hang.c +159 -0
- package/deps/liburing/liburing/test/sqpoll-disable-exit.c +195 -0
- package/deps/liburing/liburing/test/sqpoll-exit-hang.c +77 -0
- package/deps/liburing/liburing/test/sqpoll-sleep.c +68 -0
- package/deps/liburing/liburing/test/statx.c +172 -0
- package/deps/liburing/liburing/test/stdout.c +232 -0
- package/deps/liburing/liburing/test/submit-link-fail.c +154 -0
- package/deps/liburing/liburing/test/submit-reuse.c +239 -0
- package/deps/liburing/liburing/test/symlink.c +116 -0
- package/deps/liburing/liburing/test/teardowns.c +58 -0
- package/deps/liburing/liburing/test/thread-exit.c +131 -0
- package/deps/liburing/liburing/test/timeout-new.c +246 -0
- package/deps/liburing/liburing/test/timeout-overflow.c +204 -0
- package/deps/liburing/liburing/test/timeout.c +1354 -0
- package/deps/liburing/liburing/test/unlink.c +111 -0
- package/deps/liburing/liburing/test/wakeup-hang.c +162 -0
- package/deps/liburing/liburing.gyp +20 -0
- package/deps/rocksdb/rocksdb/db/corruption_test.cc +62 -0
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl.h +7 -62
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_files.cc +25 -11
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_open.cc +74 -155
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_secondary.cc +1 -2
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_secondary.h +2 -2
- package/deps/rocksdb/rocksdb/env/fs_posix.cc +13 -0
- package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.cc +4 -2
- package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.h +22 -4
- package/deps/rocksdb/rocksdb/file/prefetch_test.cc +5 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/file_system.h +15 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/statistics.h +5 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/version.h +1 -1
- package/deps/rocksdb/rocksdb/monitoring/statistics.cc +3 -0
- package/deps/rocksdb/rocksdb/monitoring/stats_history_test.cc +3 -7
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.h +2 -1
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_test.cc +44 -29
- package/deps/rocksdb/rocksdb.gyp +4 -3
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/node.napi.node +0 -0
- package/prebuilds/darwin-x64/node.napi.node +0 -0
- package/prebuilds/linux-x64/node.napi.node +0 -0
- package/prebuilds/prebuilds/linux-x64/node.napi.node +0 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/* SPDX-License-Identifier: MIT */
|
|
2
|
+
/*
|
|
3
|
+
* Description: test io_uring symlinkat handling
|
|
4
|
+
*/
|
|
5
|
+
#include <fcntl.h>
|
|
6
|
+
#include <stdio.h>
|
|
7
|
+
#include <string.h>
|
|
8
|
+
#include <sys/stat.h>
|
|
9
|
+
#include <sys/types.h>
|
|
10
|
+
#include <unistd.h>
|
|
11
|
+
|
|
12
|
+
#include "liburing.h"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
static int do_symlinkat(struct io_uring *ring, const char *oldname, const char *newname)
|
|
16
|
+
{
|
|
17
|
+
int ret;
|
|
18
|
+
struct io_uring_sqe *sqe;
|
|
19
|
+
struct io_uring_cqe *cqe;
|
|
20
|
+
|
|
21
|
+
sqe = io_uring_get_sqe(ring);
|
|
22
|
+
if (!sqe) {
|
|
23
|
+
fprintf(stderr, "sqe get failed\n");
|
|
24
|
+
goto err;
|
|
25
|
+
}
|
|
26
|
+
io_uring_prep_symlinkat(sqe, oldname, AT_FDCWD, newname);
|
|
27
|
+
|
|
28
|
+
ret = io_uring_submit(ring);
|
|
29
|
+
if (ret != 1) {
|
|
30
|
+
fprintf(stderr, "submit failed: %d\n", ret);
|
|
31
|
+
goto err;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
ret = io_uring_wait_cqes(ring, &cqe, 1, 0, 0);
|
|
35
|
+
if (ret) {
|
|
36
|
+
fprintf(stderr, "wait_cqe failed: %d\n", ret);
|
|
37
|
+
goto err;
|
|
38
|
+
}
|
|
39
|
+
ret = cqe->res;
|
|
40
|
+
io_uring_cqe_seen(ring, cqe);
|
|
41
|
+
return ret;
|
|
42
|
+
err:
|
|
43
|
+
return 1;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
int test_link_contents(const char* linkname, const char *expected_contents)
|
|
47
|
+
{
|
|
48
|
+
char buf[128];
|
|
49
|
+
int ret = readlink(linkname, buf, 127);
|
|
50
|
+
if (ret < 0) {
|
|
51
|
+
perror("readlink");
|
|
52
|
+
return ret;
|
|
53
|
+
}
|
|
54
|
+
buf[ret] = 0;
|
|
55
|
+
if (strncmp(buf, expected_contents, 128)) {
|
|
56
|
+
fprintf(stderr, "link contents differs from expected: '%s' vs '%s'",
|
|
57
|
+
buf, expected_contents);
|
|
58
|
+
return -1;
|
|
59
|
+
}
|
|
60
|
+
return 0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
int main(int argc, char *argv[])
|
|
64
|
+
{
|
|
65
|
+
static const char target[] = "io_uring-symlinkat-test-target";
|
|
66
|
+
static const char linkname[] = "io_uring-symlinkat-test-link";
|
|
67
|
+
int ret;
|
|
68
|
+
struct io_uring ring;
|
|
69
|
+
|
|
70
|
+
if (argc > 1)
|
|
71
|
+
return 0;
|
|
72
|
+
|
|
73
|
+
ret = io_uring_queue_init(8, &ring, 0);
|
|
74
|
+
if (ret) {
|
|
75
|
+
fprintf(stderr, "queue init failed: %d\n", ret);
|
|
76
|
+
return ret;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
ret = do_symlinkat(&ring, target, linkname);
|
|
80
|
+
if (ret < 0) {
|
|
81
|
+
if (ret == -EBADF || ret == -EINVAL) {
|
|
82
|
+
fprintf(stdout, "symlinkat not supported, skipping\n");
|
|
83
|
+
goto out;
|
|
84
|
+
}
|
|
85
|
+
fprintf(stderr, "symlinkat: %s\n", strerror(-ret));
|
|
86
|
+
goto err;
|
|
87
|
+
} else if (ret) {
|
|
88
|
+
goto err;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
ret = test_link_contents(linkname, target);
|
|
92
|
+
if (ret < 0)
|
|
93
|
+
goto err1;
|
|
94
|
+
|
|
95
|
+
ret = do_symlinkat(&ring, target, linkname);
|
|
96
|
+
if (ret != -EEXIST) {
|
|
97
|
+
fprintf(stderr, "test_symlinkat linkname already exists failed: %d\n", ret);
|
|
98
|
+
goto err1;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
ret = do_symlinkat(&ring, target, "surely/this/does/not/exist");
|
|
102
|
+
if (ret != -ENOENT) {
|
|
103
|
+
fprintf(stderr, "test_symlinkat no parent failed: %d\n", ret);
|
|
104
|
+
goto err1;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
out:
|
|
108
|
+
unlinkat(AT_FDCWD, linkname, 0);
|
|
109
|
+
io_uring_queue_exit(&ring);
|
|
110
|
+
return 0;
|
|
111
|
+
err1:
|
|
112
|
+
unlinkat(AT_FDCWD, linkname, 0);
|
|
113
|
+
err:
|
|
114
|
+
io_uring_queue_exit(&ring);
|
|
115
|
+
return 1;
|
|
116
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/* SPDX-License-Identifier: MIT */
|
|
2
|
+
#include <stdint.h>
|
|
3
|
+
#include <stdio.h>
|
|
4
|
+
#include <stdlib.h>
|
|
5
|
+
#include <string.h>
|
|
6
|
+
#include <sys/types.h>
|
|
7
|
+
#include <sys/wait.h>
|
|
8
|
+
#include <unistd.h>
|
|
9
|
+
#include <errno.h>
|
|
10
|
+
|
|
11
|
+
#include "liburing.h"
|
|
12
|
+
|
|
13
|
+
static void loop(void)
|
|
14
|
+
{
|
|
15
|
+
int i, ret = 0;
|
|
16
|
+
|
|
17
|
+
for (i = 0; i < 100; i++) {
|
|
18
|
+
struct io_uring ring;
|
|
19
|
+
int fd;
|
|
20
|
+
|
|
21
|
+
memset(&ring, 0, sizeof(ring));
|
|
22
|
+
fd = io_uring_queue_init(0xa4, &ring, 0);
|
|
23
|
+
if (fd >= 0) {
|
|
24
|
+
close(fd);
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (fd != -ENOMEM)
|
|
28
|
+
ret++;
|
|
29
|
+
}
|
|
30
|
+
exit(ret);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
int main(int argc, char *argv[])
|
|
34
|
+
{
|
|
35
|
+
int i, ret, status;
|
|
36
|
+
|
|
37
|
+
if (argc > 1)
|
|
38
|
+
return 0;
|
|
39
|
+
|
|
40
|
+
for (i = 0; i < 12; i++) {
|
|
41
|
+
if (!fork()) {
|
|
42
|
+
loop();
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
ret = 0;
|
|
48
|
+
for (i = 0; i < 12; i++) {
|
|
49
|
+
if (waitpid(-1, &status, 0) < 0) {
|
|
50
|
+
perror("waitpid");
|
|
51
|
+
return 1;
|
|
52
|
+
}
|
|
53
|
+
if (WEXITSTATUS(status))
|
|
54
|
+
ret++;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return ret;
|
|
58
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/* SPDX-License-Identifier: MIT */
|
|
2
|
+
/*
|
|
3
|
+
* Description: test that thread pool issued requests don't cancel on thread
|
|
4
|
+
* exit, but do get canceled once the parent exits. Do both
|
|
5
|
+
* writes that finish and a poll request that sticks around.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
#include <errno.h>
|
|
9
|
+
#include <stdio.h>
|
|
10
|
+
#include <unistd.h>
|
|
11
|
+
#include <stdlib.h>
|
|
12
|
+
#include <string.h>
|
|
13
|
+
#include <fcntl.h>
|
|
14
|
+
#include <sys/poll.h>
|
|
15
|
+
#include <pthread.h>
|
|
16
|
+
|
|
17
|
+
#include "helpers.h"
|
|
18
|
+
#include "liburing.h"
|
|
19
|
+
|
|
20
|
+
#define NR_IOS 8
|
|
21
|
+
#define WSIZE 512
|
|
22
|
+
|
|
23
|
+
struct d {
|
|
24
|
+
int fd;
|
|
25
|
+
struct io_uring *ring;
|
|
26
|
+
unsigned long off;
|
|
27
|
+
int pipe_fd;
|
|
28
|
+
int err;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
static void *do_io(void *data)
|
|
32
|
+
{
|
|
33
|
+
struct d *d = data;
|
|
34
|
+
struct io_uring_sqe *sqe;
|
|
35
|
+
char *buffer;
|
|
36
|
+
int ret;
|
|
37
|
+
|
|
38
|
+
buffer = t_malloc(WSIZE);
|
|
39
|
+
memset(buffer, 0x5a, WSIZE);
|
|
40
|
+
sqe = io_uring_get_sqe(d->ring);
|
|
41
|
+
if (!sqe) {
|
|
42
|
+
d->err++;
|
|
43
|
+
return NULL;
|
|
44
|
+
}
|
|
45
|
+
io_uring_prep_write(sqe, d->fd, buffer, WSIZE, d->off);
|
|
46
|
+
sqe->user_data = d->off;
|
|
47
|
+
|
|
48
|
+
sqe = io_uring_get_sqe(d->ring);
|
|
49
|
+
if (!sqe) {
|
|
50
|
+
d->err++;
|
|
51
|
+
return NULL;
|
|
52
|
+
}
|
|
53
|
+
io_uring_prep_poll_add(sqe, d->pipe_fd, POLLIN);
|
|
54
|
+
|
|
55
|
+
ret = io_uring_submit(d->ring);
|
|
56
|
+
if (ret != 2)
|
|
57
|
+
d->err++;
|
|
58
|
+
|
|
59
|
+
free(buffer);
|
|
60
|
+
return NULL;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
int main(int argc, char *argv[])
|
|
64
|
+
{
|
|
65
|
+
struct io_uring ring;
|
|
66
|
+
const char *fname;
|
|
67
|
+
pthread_t thread;
|
|
68
|
+
int ret, do_unlink, i, fd;
|
|
69
|
+
struct d d;
|
|
70
|
+
int fds[2];
|
|
71
|
+
|
|
72
|
+
if (pipe(fds) < 0) {
|
|
73
|
+
perror("pipe");
|
|
74
|
+
return 1;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
ret = io_uring_queue_init(32, &ring, 0);
|
|
78
|
+
if (ret) {
|
|
79
|
+
fprintf(stderr, "ring setup failed\n");
|
|
80
|
+
return 1;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (argc > 1) {
|
|
84
|
+
fname = argv[1];
|
|
85
|
+
do_unlink = 0;
|
|
86
|
+
} else {
|
|
87
|
+
fname = ".thread.exit";
|
|
88
|
+
do_unlink = 1;
|
|
89
|
+
t_create_file(fname, 4096);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
fd = open(fname, O_WRONLY);
|
|
93
|
+
if (do_unlink)
|
|
94
|
+
unlink(fname);
|
|
95
|
+
if (fd < 0) {
|
|
96
|
+
perror("open");
|
|
97
|
+
return 1;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
d.fd = fd;
|
|
101
|
+
d.ring = ˚
|
|
102
|
+
d.off = 0;
|
|
103
|
+
d.pipe_fd = fds[0];
|
|
104
|
+
d.err = 0;
|
|
105
|
+
for (i = 0; i < NR_IOS; i++) {
|
|
106
|
+
memset(&thread, 0, sizeof(thread));
|
|
107
|
+
pthread_create(&thread, NULL, do_io, &d);
|
|
108
|
+
pthread_join(thread, NULL);
|
|
109
|
+
d.off += WSIZE;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
for (i = 0; i < NR_IOS; i++) {
|
|
113
|
+
struct io_uring_cqe *cqe;
|
|
114
|
+
|
|
115
|
+
ret = io_uring_wait_cqe(&ring, &cqe);
|
|
116
|
+
if (ret) {
|
|
117
|
+
fprintf(stderr, "io_uring_wait_cqe=%d\n", ret);
|
|
118
|
+
goto err;
|
|
119
|
+
}
|
|
120
|
+
if (cqe->res != WSIZE) {
|
|
121
|
+
fprintf(stderr, "cqe->res=%d, Expected %d\n", cqe->res,
|
|
122
|
+
WSIZE);
|
|
123
|
+
goto err;
|
|
124
|
+
}
|
|
125
|
+
io_uring_cqe_seen(&ring, cqe);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return d.err;
|
|
129
|
+
err:
|
|
130
|
+
return 1;
|
|
131
|
+
}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/* SPDX-License-Identifier: MIT */
|
|
2
|
+
/*
|
|
3
|
+
* Description: tests for getevents timeout
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
#include <stdio.h>
|
|
7
|
+
#include <sys/time.h>
|
|
8
|
+
#include <unistd.h>
|
|
9
|
+
#include <pthread.h>
|
|
10
|
+
#include "liburing.h"
|
|
11
|
+
|
|
12
|
+
#define TIMEOUT_MSEC 200
|
|
13
|
+
#define TIMEOUT_SEC 10
|
|
14
|
+
|
|
15
|
+
int thread_ret0, thread_ret1;
|
|
16
|
+
int cnt = 0;
|
|
17
|
+
pthread_mutex_t mutex;
|
|
18
|
+
|
|
19
|
+
static void msec_to_ts(struct __kernel_timespec *ts, unsigned int msec)
|
|
20
|
+
{
|
|
21
|
+
ts->tv_sec = msec / 1000;
|
|
22
|
+
ts->tv_nsec = (msec % 1000) * 1000000;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static unsigned long long mtime_since(const struct timeval *s,
|
|
26
|
+
const struct timeval *e)
|
|
27
|
+
{
|
|
28
|
+
long long sec, usec;
|
|
29
|
+
|
|
30
|
+
sec = e->tv_sec - s->tv_sec;
|
|
31
|
+
usec = (e->tv_usec - s->tv_usec);
|
|
32
|
+
if (sec > 0 && usec < 0) {
|
|
33
|
+
sec--;
|
|
34
|
+
usec += 1000000;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
sec *= 1000;
|
|
38
|
+
usec /= 1000;
|
|
39
|
+
return sec + usec;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static unsigned long long mtime_since_now(struct timeval *tv)
|
|
43
|
+
{
|
|
44
|
+
struct timeval end;
|
|
45
|
+
|
|
46
|
+
gettimeofday(&end, NULL);
|
|
47
|
+
return mtime_since(tv, &end);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
static int test_return_before_timeout(struct io_uring *ring)
|
|
52
|
+
{
|
|
53
|
+
struct io_uring_cqe *cqe;
|
|
54
|
+
struct io_uring_sqe *sqe;
|
|
55
|
+
int ret;
|
|
56
|
+
struct __kernel_timespec ts;
|
|
57
|
+
|
|
58
|
+
sqe = io_uring_get_sqe(ring);
|
|
59
|
+
if (!sqe) {
|
|
60
|
+
fprintf(stderr, "%s: get sqe failed\n", __FUNCTION__);
|
|
61
|
+
return 1;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
io_uring_prep_nop(sqe);
|
|
65
|
+
|
|
66
|
+
ret = io_uring_submit(ring);
|
|
67
|
+
if (ret <= 0) {
|
|
68
|
+
fprintf(stderr, "%s: sqe submit failed: %d\n", __FUNCTION__, ret);
|
|
69
|
+
return 1;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
msec_to_ts(&ts, TIMEOUT_MSEC);
|
|
73
|
+
ret = io_uring_wait_cqe_timeout(ring, &cqe, &ts);
|
|
74
|
+
if (ret < 0) {
|
|
75
|
+
fprintf(stderr, "%s: timeout error: %d\n", __FUNCTION__, ret);
|
|
76
|
+
return 1;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
io_uring_cqe_seen(ring, cqe);
|
|
80
|
+
return 0;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
static int test_return_after_timeout(struct io_uring *ring)
|
|
84
|
+
{
|
|
85
|
+
struct io_uring_cqe *cqe;
|
|
86
|
+
int ret;
|
|
87
|
+
struct __kernel_timespec ts;
|
|
88
|
+
struct timeval tv;
|
|
89
|
+
unsigned long long exp;
|
|
90
|
+
|
|
91
|
+
msec_to_ts(&ts, TIMEOUT_MSEC);
|
|
92
|
+
gettimeofday(&tv, NULL);
|
|
93
|
+
ret = io_uring_wait_cqe_timeout(ring, &cqe, &ts);
|
|
94
|
+
exp = mtime_since_now(&tv);
|
|
95
|
+
if (ret != -ETIME) {
|
|
96
|
+
fprintf(stderr, "%s: timeout error: %d\n", __FUNCTION__, ret);
|
|
97
|
+
return 1;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (exp < TIMEOUT_MSEC / 2 || exp > (TIMEOUT_MSEC * 3) / 2) {
|
|
101
|
+
fprintf(stderr, "%s: Timeout seems wonky (got %llu)\n", __FUNCTION__, exp);
|
|
102
|
+
return 1;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return 0;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
int __reap_thread_fn(void *data) {
|
|
109
|
+
struct io_uring *ring = (struct io_uring *)data;
|
|
110
|
+
struct io_uring_cqe *cqe;
|
|
111
|
+
struct __kernel_timespec ts;
|
|
112
|
+
|
|
113
|
+
msec_to_ts(&ts, TIMEOUT_SEC);
|
|
114
|
+
pthread_mutex_lock(&mutex);
|
|
115
|
+
cnt++;
|
|
116
|
+
pthread_mutex_unlock(&mutex);
|
|
117
|
+
return io_uring_wait_cqe_timeout(ring, &cqe, &ts);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
void *reap_thread_fn0(void *data) {
|
|
121
|
+
thread_ret0 = __reap_thread_fn(data);
|
|
122
|
+
return NULL;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
void *reap_thread_fn1(void *data) {
|
|
126
|
+
thread_ret1 = __reap_thread_fn(data);
|
|
127
|
+
return NULL;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/*
|
|
131
|
+
* This is to test issuing a sqe in main thread and reaping it in two child-thread
|
|
132
|
+
* at the same time. To see if timeout feature works or not.
|
|
133
|
+
*/
|
|
134
|
+
int test_multi_threads_timeout() {
|
|
135
|
+
struct io_uring ring;
|
|
136
|
+
int ret;
|
|
137
|
+
bool both_wait = false;
|
|
138
|
+
pthread_t reap_thread0, reap_thread1;
|
|
139
|
+
struct io_uring_sqe *sqe;
|
|
140
|
+
|
|
141
|
+
ret = io_uring_queue_init(8, &ring, 0);
|
|
142
|
+
if (ret) {
|
|
143
|
+
fprintf(stderr, "%s: ring setup failed: %d\n", __FUNCTION__, ret);
|
|
144
|
+
return 1;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
pthread_create(&reap_thread0, NULL, reap_thread_fn0, &ring);
|
|
148
|
+
pthread_create(&reap_thread1, NULL, reap_thread_fn1, &ring);
|
|
149
|
+
|
|
150
|
+
/*
|
|
151
|
+
* make two threads both enter io_uring_wait_cqe_timeout() before issuing the sqe
|
|
152
|
+
* as possible as we can. So that there are two threads in the ctx->wait queue.
|
|
153
|
+
* In this way, we can test if a cqe wakes up two threads at the same time.
|
|
154
|
+
*/
|
|
155
|
+
while(!both_wait) {
|
|
156
|
+
pthread_mutex_lock(&mutex);
|
|
157
|
+
if (cnt == 2)
|
|
158
|
+
both_wait = true;
|
|
159
|
+
pthread_mutex_unlock(&mutex);
|
|
160
|
+
sleep(1);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
sqe = io_uring_get_sqe(&ring);
|
|
164
|
+
if (!sqe) {
|
|
165
|
+
fprintf(stderr, "%s: get sqe failed\n", __FUNCTION__);
|
|
166
|
+
goto err;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
io_uring_prep_nop(sqe);
|
|
170
|
+
|
|
171
|
+
ret = io_uring_submit(&ring);
|
|
172
|
+
if (ret <= 0) {
|
|
173
|
+
fprintf(stderr, "%s: sqe submit failed: %d\n", __FUNCTION__, ret);
|
|
174
|
+
goto err;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
pthread_join(reap_thread0, NULL);
|
|
178
|
+
pthread_join(reap_thread1, NULL);
|
|
179
|
+
|
|
180
|
+
if ((thread_ret0 && thread_ret0 != -ETIME) || (thread_ret1 && thread_ret1 != -ETIME)) {
|
|
181
|
+
fprintf(stderr, "%s: thread wait cqe timeout failed: %d %d\n",
|
|
182
|
+
__FUNCTION__, thread_ret0, thread_ret1);
|
|
183
|
+
goto err;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return 0;
|
|
187
|
+
err:
|
|
188
|
+
return 1;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
int main(int argc, char *argv[])
|
|
192
|
+
{
|
|
193
|
+
struct io_uring ring_normal, ring_sq;
|
|
194
|
+
int ret;
|
|
195
|
+
|
|
196
|
+
if (argc > 1)
|
|
197
|
+
return 0;
|
|
198
|
+
|
|
199
|
+
ret = io_uring_queue_init(8, &ring_normal, 0);
|
|
200
|
+
if (ret) {
|
|
201
|
+
fprintf(stderr, "ring_normal setup failed: %d\n", ret);
|
|
202
|
+
return 1;
|
|
203
|
+
}
|
|
204
|
+
if (!(ring_normal.features & IORING_FEAT_EXT_ARG)) {
|
|
205
|
+
fprintf(stderr, "feature IORING_FEAT_EXT_ARG not supported, skipping.\n");
|
|
206
|
+
return 0;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
ret = test_return_before_timeout(&ring_normal);
|
|
210
|
+
if (ret) {
|
|
211
|
+
fprintf(stderr, "ring_normal: test_return_before_timeout failed\n");
|
|
212
|
+
return ret;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
ret = test_return_after_timeout(&ring_normal);
|
|
216
|
+
if (ret) {
|
|
217
|
+
fprintf(stderr, "ring_normal: test_return_after_timeout failed\n");
|
|
218
|
+
return ret;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
ret = io_uring_queue_init(8, &ring_sq, IORING_SETUP_SQPOLL);
|
|
222
|
+
if (ret) {
|
|
223
|
+
fprintf(stderr, "ring_sq setup failed: %d\n", ret);
|
|
224
|
+
return 1;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
ret = test_return_before_timeout(&ring_sq);
|
|
228
|
+
if (ret) {
|
|
229
|
+
fprintf(stderr, "ring_sq: test_return_before_timeout failed\n");
|
|
230
|
+
return ret;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
ret = test_return_after_timeout(&ring_sq);
|
|
234
|
+
if (ret) {
|
|
235
|
+
fprintf(stderr, "ring_sq: test_return_after_timeout failed\n");
|
|
236
|
+
return ret;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
ret = test_multi_threads_timeout();
|
|
240
|
+
if (ret) {
|
|
241
|
+
fprintf(stderr, "test_multi_threads_timeout failed\n");
|
|
242
|
+
return ret;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return 0;
|
|
246
|
+
}
|