@nxtedition/rocksdb 5.2.35 → 5.2.38
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 +136 -164
- package/binding.gyp +1 -1
- 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/README.md +32 -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/microbench/README.md +60 -0
- package/deps/rocksdb/rocksdb/monitoring/statistics.cc +3 -0
- package/deps/rocksdb/rocksdb/monitoring/stats_history_test.cc +3 -7
- package/deps/rocksdb/rocksdb/plugin/README.md +43 -0
- package/deps/rocksdb/rocksdb/port/README +10 -0
- 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/utilities/transactions/lock/range/range_tree/lib/README +13 -0
- package/deps/rocksdb/rocksdb.gyp +3 -4
- package/deps/snappy/snappy-1.1.7/README.md +149 -0
- 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/deps/rocksdb/rocksdb/cmake/modules/CxxFlags.cmake +0 -7
- package/deps/rocksdb/rocksdb/cmake/modules/FindJeMalloc.cmake +0 -29
- package/deps/rocksdb/rocksdb/cmake/modules/FindNUMA.cmake +0 -29
- package/deps/rocksdb/rocksdb/cmake/modules/FindSnappy.cmake +0 -29
- package/deps/rocksdb/rocksdb/cmake/modules/FindTBB.cmake +0 -33
- package/deps/rocksdb/rocksdb/cmake/modules/Findgflags.cmake +0 -29
- package/deps/rocksdb/rocksdb/cmake/modules/Findlz4.cmake +0 -29
- package/deps/rocksdb/rocksdb/cmake/modules/Finduring.cmake +0 -26
- package/deps/rocksdb/rocksdb/cmake/modules/Findzstd.cmake +0 -29
- package/deps/rocksdb/rocksdb/cmake/modules/ReadVersion.cmake +0 -10
- package/package-lock.json +0 -23687
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/* SPDX-License-Identifier: MIT */
|
|
2
|
+
/*
|
|
3
|
+
* Description: test SQPOLL with IORING_SETUP_ATTACH_WQ and closing of
|
|
4
|
+
* the original ring descriptor.
|
|
5
|
+
*/
|
|
6
|
+
#include <errno.h>
|
|
7
|
+
#include <stdio.h>
|
|
8
|
+
#include <unistd.h>
|
|
9
|
+
#include <stdlib.h>
|
|
10
|
+
#include <string.h>
|
|
11
|
+
#include <fcntl.h>
|
|
12
|
+
#include <sys/types.h>
|
|
13
|
+
#include <sys/poll.h>
|
|
14
|
+
#include <sys/eventfd.h>
|
|
15
|
+
#include <sys/resource.h>
|
|
16
|
+
|
|
17
|
+
#include "helpers.h"
|
|
18
|
+
#include "liburing.h"
|
|
19
|
+
|
|
20
|
+
#define FILE_SIZE (128 * 1024 * 1024)
|
|
21
|
+
#define BS 4096
|
|
22
|
+
#define BUFFERS 64
|
|
23
|
+
|
|
24
|
+
#define NR_RINGS 4
|
|
25
|
+
|
|
26
|
+
static struct iovec *vecs;
|
|
27
|
+
static struct io_uring rings[NR_RINGS];
|
|
28
|
+
|
|
29
|
+
static int wait_io(struct io_uring *ring, int nr_ios)
|
|
30
|
+
{
|
|
31
|
+
struct io_uring_cqe *cqe;
|
|
32
|
+
|
|
33
|
+
while (nr_ios) {
|
|
34
|
+
io_uring_wait_cqe(ring, &cqe);
|
|
35
|
+
if (cqe->res != BS) {
|
|
36
|
+
fprintf(stderr, "Unexpected ret %d\n", cqe->res);
|
|
37
|
+
return 1;
|
|
38
|
+
}
|
|
39
|
+
io_uring_cqe_seen(ring, cqe);
|
|
40
|
+
nr_ios--;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static int queue_io(struct io_uring *ring, int fd, int nr_ios)
|
|
47
|
+
{
|
|
48
|
+
unsigned long off;
|
|
49
|
+
int i;
|
|
50
|
+
|
|
51
|
+
i = 0;
|
|
52
|
+
off = 0;
|
|
53
|
+
while (nr_ios) {
|
|
54
|
+
struct io_uring_sqe *sqe;
|
|
55
|
+
|
|
56
|
+
sqe = io_uring_get_sqe(ring);
|
|
57
|
+
if (!sqe)
|
|
58
|
+
break;
|
|
59
|
+
io_uring_prep_read(sqe, fd, vecs[i].iov_base, vecs[i].iov_len, off);
|
|
60
|
+
nr_ios--;
|
|
61
|
+
i++;
|
|
62
|
+
off += BS;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
io_uring_submit(ring);
|
|
66
|
+
return i;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static int do_io(int fd, int ring_start, int ring_end)
|
|
70
|
+
{
|
|
71
|
+
int i, rets[NR_RINGS];
|
|
72
|
+
unsigned ios = 0;
|
|
73
|
+
|
|
74
|
+
while (ios < 32) {
|
|
75
|
+
for (i = ring_start; i < ring_end; i++) {
|
|
76
|
+
int ret = queue_io(&rings[i], fd, BUFFERS);
|
|
77
|
+
if (ret < 0)
|
|
78
|
+
goto err;
|
|
79
|
+
rets[i] = ret;
|
|
80
|
+
}
|
|
81
|
+
for (i = ring_start; i < ring_end; i++) {
|
|
82
|
+
if (wait_io(&rings[i], rets[i]))
|
|
83
|
+
goto err;
|
|
84
|
+
}
|
|
85
|
+
ios += BUFFERS;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return 0;
|
|
89
|
+
err:
|
|
90
|
+
return 1;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
static int test(int fd, int do_dup_and_close, int close_ring)
|
|
94
|
+
{
|
|
95
|
+
int i, ret, ring_fd;
|
|
96
|
+
|
|
97
|
+
for (i = 0; i < NR_RINGS; i++) {
|
|
98
|
+
struct io_uring_params p = { };
|
|
99
|
+
|
|
100
|
+
p.flags = IORING_SETUP_SQPOLL;
|
|
101
|
+
p.sq_thread_idle = 100;
|
|
102
|
+
if (i) {
|
|
103
|
+
p.wq_fd = rings[0].ring_fd;
|
|
104
|
+
p.flags |= IORING_SETUP_ATTACH_WQ;
|
|
105
|
+
}
|
|
106
|
+
ret = io_uring_queue_init_params(BUFFERS, &rings[i], &p);
|
|
107
|
+
if (ret) {
|
|
108
|
+
fprintf(stderr, "queue_init: %d/%d\n", ret, i);
|
|
109
|
+
goto err;
|
|
110
|
+
}
|
|
111
|
+
/* no sharing for non-fixed either */
|
|
112
|
+
if (!(p.features & IORING_FEAT_SQPOLL_NONFIXED)) {
|
|
113
|
+
fprintf(stdout, "No SQPOLL sharing, skipping\n");
|
|
114
|
+
return 0;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/* test all rings */
|
|
119
|
+
if (do_io(fd, 0, NR_RINGS))
|
|
120
|
+
goto err;
|
|
121
|
+
|
|
122
|
+
/* dup and close original ring fd */
|
|
123
|
+
ring_fd = dup(rings[0].ring_fd);
|
|
124
|
+
if (close_ring)
|
|
125
|
+
close(rings[0].ring_fd);
|
|
126
|
+
rings[0].ring_fd = ring_fd;
|
|
127
|
+
if (do_dup_and_close)
|
|
128
|
+
goto done;
|
|
129
|
+
|
|
130
|
+
/* test all but closed one */
|
|
131
|
+
if (do_io(fd, 1, NR_RINGS))
|
|
132
|
+
goto err;
|
|
133
|
+
|
|
134
|
+
/* test closed one */
|
|
135
|
+
if (do_io(fd, 0, 1))
|
|
136
|
+
goto err;
|
|
137
|
+
|
|
138
|
+
/* make sure thread is idle so we enter the kernel */
|
|
139
|
+
usleep(200000);
|
|
140
|
+
|
|
141
|
+
/* test closed one */
|
|
142
|
+
if (do_io(fd, 0, 1))
|
|
143
|
+
goto err;
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
done:
|
|
147
|
+
for (i = 0; i < NR_RINGS; i++)
|
|
148
|
+
io_uring_queue_exit(&rings[i]);
|
|
149
|
+
|
|
150
|
+
return 0;
|
|
151
|
+
err:
|
|
152
|
+
return 1;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
int main(int argc, char *argv[])
|
|
156
|
+
{
|
|
157
|
+
char *fname;
|
|
158
|
+
int ret, fd;
|
|
159
|
+
|
|
160
|
+
if (argc > 1) {
|
|
161
|
+
fname = argv[1];
|
|
162
|
+
} else {
|
|
163
|
+
fname = ".basic-rw";
|
|
164
|
+
t_create_file(fname, FILE_SIZE);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
vecs = t_create_buffers(BUFFERS, BS);
|
|
168
|
+
|
|
169
|
+
fd = open(fname, O_RDONLY | O_DIRECT);
|
|
170
|
+
if (fname != argv[1])
|
|
171
|
+
unlink(fname);
|
|
172
|
+
|
|
173
|
+
if (fd < 0) {
|
|
174
|
+
perror("open");
|
|
175
|
+
return -1;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
ret = test(fd, 0, 0);
|
|
179
|
+
if (ret) {
|
|
180
|
+
fprintf(stderr, "test 0 0 failed\n");
|
|
181
|
+
goto err;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
ret = test(fd, 0, 1);
|
|
185
|
+
if (ret) {
|
|
186
|
+
fprintf(stderr, "test 0 1 failed\n");
|
|
187
|
+
goto err;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
ret = test(fd, 1, 0);
|
|
192
|
+
if (ret) {
|
|
193
|
+
fprintf(stderr, "test 1 0 failed\n");
|
|
194
|
+
goto err;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return 0;
|
|
198
|
+
err:
|
|
199
|
+
return 1;
|
|
200
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Description: test if io_uring SQ poll kthread is stopped when the userspace
|
|
3
|
+
* process ended with or without closing the io_uring fd
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
#include <errno.h>
|
|
7
|
+
#include <fcntl.h>
|
|
8
|
+
#include <stdio.h>
|
|
9
|
+
#include <unistd.h>
|
|
10
|
+
#include <pthread.h>
|
|
11
|
+
#include <stdbool.h>
|
|
12
|
+
#include <stdlib.h>
|
|
13
|
+
#include <string.h>
|
|
14
|
+
#include <signal.h>
|
|
15
|
+
#include <sys/poll.h>
|
|
16
|
+
#include <sys/wait.h>
|
|
17
|
+
#include <sys/epoll.h>
|
|
18
|
+
|
|
19
|
+
#include "liburing.h"
|
|
20
|
+
#include "helpers.h"
|
|
21
|
+
|
|
22
|
+
#define SQ_THREAD_IDLE 2000
|
|
23
|
+
#define BUF_SIZE 128
|
|
24
|
+
#define KTHREAD_NAME "io_uring-sq"
|
|
25
|
+
|
|
26
|
+
enum {
|
|
27
|
+
TEST_OK = 0,
|
|
28
|
+
TEST_SKIPPED = 1,
|
|
29
|
+
TEST_FAILED = 2,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
static int do_test_sq_poll_kthread_stopped(bool do_exit)
|
|
33
|
+
{
|
|
34
|
+
int ret = 0, pipe1[2];
|
|
35
|
+
struct io_uring_params param;
|
|
36
|
+
struct io_uring ring;
|
|
37
|
+
struct io_uring_sqe *sqe;
|
|
38
|
+
struct io_uring_cqe *cqe;
|
|
39
|
+
uint8_t buf[BUF_SIZE];
|
|
40
|
+
struct iovec iov;
|
|
41
|
+
|
|
42
|
+
if (pipe(pipe1) != 0) {
|
|
43
|
+
perror("pipe");
|
|
44
|
+
return TEST_FAILED;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
memset(¶m, 0, sizeof(param));
|
|
48
|
+
param.flags |= IORING_SETUP_SQPOLL;
|
|
49
|
+
param.sq_thread_idle = SQ_THREAD_IDLE;
|
|
50
|
+
|
|
51
|
+
ret = t_create_ring_params(16, &ring, ¶m);
|
|
52
|
+
if (ret == T_SETUP_SKIP) {
|
|
53
|
+
ret = TEST_FAILED;
|
|
54
|
+
goto err_pipe;
|
|
55
|
+
} else if (ret != T_SETUP_OK) {
|
|
56
|
+
fprintf(stderr, "ring setup failed\n");
|
|
57
|
+
ret = TEST_FAILED;
|
|
58
|
+
goto err_pipe;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
ret = io_uring_register_files(&ring, &pipe1[1], 1);
|
|
62
|
+
if (ret) {
|
|
63
|
+
fprintf(stderr, "file reg failed: %d\n", ret);
|
|
64
|
+
ret = TEST_FAILED;
|
|
65
|
+
goto err_uring;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
iov.iov_base = buf;
|
|
69
|
+
iov.iov_len = BUF_SIZE;
|
|
70
|
+
|
|
71
|
+
sqe = io_uring_get_sqe(&ring);
|
|
72
|
+
if (!sqe) {
|
|
73
|
+
fprintf(stderr, "io_uring_get_sqe failed\n");
|
|
74
|
+
ret = TEST_FAILED;
|
|
75
|
+
goto err_uring;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
io_uring_prep_writev(sqe, 0, &iov, 1, 0);
|
|
79
|
+
sqe->flags |= IOSQE_FIXED_FILE;
|
|
80
|
+
|
|
81
|
+
ret = io_uring_submit(&ring);
|
|
82
|
+
if (ret < 0) {
|
|
83
|
+
fprintf(stderr, "io_uring_submit failed - ret: %d\n",
|
|
84
|
+
ret);
|
|
85
|
+
ret = TEST_FAILED;
|
|
86
|
+
goto err_uring;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
ret = io_uring_wait_cqe(&ring, &cqe);
|
|
90
|
+
if (ret < 0) {
|
|
91
|
+
fprintf(stderr, "io_uring_wait_cqe - ret: %d\n",
|
|
92
|
+
ret);
|
|
93
|
+
ret = TEST_FAILED;
|
|
94
|
+
goto err_uring;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (cqe->res != BUF_SIZE) {
|
|
98
|
+
fprintf(stderr, "unexpected cqe->res %d [expected %d]\n",
|
|
99
|
+
cqe->res, BUF_SIZE);
|
|
100
|
+
ret = TEST_FAILED;
|
|
101
|
+
goto err_uring;
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
io_uring_cqe_seen(&ring, cqe);
|
|
106
|
+
|
|
107
|
+
ret = TEST_OK;
|
|
108
|
+
|
|
109
|
+
err_uring:
|
|
110
|
+
if (do_exit)
|
|
111
|
+
io_uring_queue_exit(&ring);
|
|
112
|
+
err_pipe:
|
|
113
|
+
close(pipe1[0]);
|
|
114
|
+
close(pipe1[1]);
|
|
115
|
+
|
|
116
|
+
return ret;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
int test_sq_poll_kthread_stopped(bool do_exit)
|
|
120
|
+
{
|
|
121
|
+
pid_t pid;
|
|
122
|
+
int status = 0;
|
|
123
|
+
|
|
124
|
+
pid = fork();
|
|
125
|
+
|
|
126
|
+
if (pid == 0) {
|
|
127
|
+
int ret = do_test_sq_poll_kthread_stopped(do_exit);
|
|
128
|
+
exit(ret);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
pid = wait(&status);
|
|
132
|
+
if (status != 0)
|
|
133
|
+
return WEXITSTATUS(status);
|
|
134
|
+
|
|
135
|
+
sleep(1);
|
|
136
|
+
if (system("ps --ppid 2 | grep " KTHREAD_NAME) == 0) {
|
|
137
|
+
fprintf(stderr, "%s kthread still running!\n", KTHREAD_NAME);
|
|
138
|
+
return TEST_FAILED;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return 0;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
int main(int argc, char *argv[])
|
|
145
|
+
{
|
|
146
|
+
int ret;
|
|
147
|
+
|
|
148
|
+
if (argc > 1)
|
|
149
|
+
return 0;
|
|
150
|
+
|
|
151
|
+
ret = test_sq_poll_kthread_stopped(true);
|
|
152
|
+
if (ret == TEST_SKIPPED) {
|
|
153
|
+
printf("test_sq_poll_kthread_stopped_exit: skipped\n");
|
|
154
|
+
} else if (ret == TEST_FAILED) {
|
|
155
|
+
fprintf(stderr, "test_sq_poll_kthread_stopped_exit failed\n");
|
|
156
|
+
return ret;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
ret = test_sq_poll_kthread_stopped(false);
|
|
160
|
+
if (ret == TEST_SKIPPED) {
|
|
161
|
+
printf("test_sq_poll_kthread_stopped_noexit: skipped\n");
|
|
162
|
+
} else if (ret == TEST_FAILED) {
|
|
163
|
+
fprintf(stderr, "test_sq_poll_kthread_stopped_noexit failed\n");
|
|
164
|
+
return ret;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return 0;
|
|
168
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/* SPDX-License-Identifier: MIT */
|
|
2
|
+
/*
|
|
3
|
+
* Description: test SQPOLL with IORING_SETUP_ATTACH_WQ
|
|
4
|
+
*/
|
|
5
|
+
#include <errno.h>
|
|
6
|
+
#include <stdio.h>
|
|
7
|
+
#include <unistd.h>
|
|
8
|
+
#include <stdlib.h>
|
|
9
|
+
#include <string.h>
|
|
10
|
+
#include <fcntl.h>
|
|
11
|
+
#include <sys/types.h>
|
|
12
|
+
#include <sys/poll.h>
|
|
13
|
+
#include <sys/eventfd.h>
|
|
14
|
+
#include <sys/resource.h>
|
|
15
|
+
|
|
16
|
+
#include "helpers.h"
|
|
17
|
+
#include "liburing.h"
|
|
18
|
+
|
|
19
|
+
#define FILE_SIZE (128 * 1024 * 1024)
|
|
20
|
+
#define BS 4096
|
|
21
|
+
#define BUFFERS 64
|
|
22
|
+
|
|
23
|
+
#define NR_RINGS 4
|
|
24
|
+
|
|
25
|
+
static struct iovec *vecs;
|
|
26
|
+
|
|
27
|
+
static int wait_io(struct io_uring *ring, int nr_ios)
|
|
28
|
+
{
|
|
29
|
+
struct io_uring_cqe *cqe;
|
|
30
|
+
|
|
31
|
+
while (nr_ios) {
|
|
32
|
+
int ret = io_uring_wait_cqe(ring, &cqe);
|
|
33
|
+
|
|
34
|
+
if (ret == -EAGAIN) {
|
|
35
|
+
continue;
|
|
36
|
+
} else if (ret) {
|
|
37
|
+
fprintf(stderr, "io_uring_wait_cqe failed %i\n", ret);
|
|
38
|
+
return 1;
|
|
39
|
+
}
|
|
40
|
+
if (cqe->res != BS) {
|
|
41
|
+
fprintf(stderr, "Unexpected ret %d\n", cqe->res);
|
|
42
|
+
return 1;
|
|
43
|
+
}
|
|
44
|
+
io_uring_cqe_seen(ring, cqe);
|
|
45
|
+
nr_ios--;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return 0;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
static int queue_io(struct io_uring *ring, int fd, int nr_ios)
|
|
52
|
+
{
|
|
53
|
+
unsigned long off;
|
|
54
|
+
int i;
|
|
55
|
+
|
|
56
|
+
i = 0;
|
|
57
|
+
off = 0;
|
|
58
|
+
while (nr_ios) {
|
|
59
|
+
struct io_uring_sqe *sqe;
|
|
60
|
+
|
|
61
|
+
sqe = io_uring_get_sqe(ring);
|
|
62
|
+
if (!sqe)
|
|
63
|
+
break;
|
|
64
|
+
io_uring_prep_read(sqe, fd, vecs[i].iov_base, vecs[i].iov_len, off);
|
|
65
|
+
nr_ios--;
|
|
66
|
+
i++;
|
|
67
|
+
off += BS;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
io_uring_submit(ring);
|
|
71
|
+
return i;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
int main(int argc, char *argv[])
|
|
75
|
+
{
|
|
76
|
+
struct io_uring rings[NR_RINGS];
|
|
77
|
+
int rets[NR_RINGS];
|
|
78
|
+
unsigned long ios;
|
|
79
|
+
int i, ret, fd;
|
|
80
|
+
char *fname;
|
|
81
|
+
|
|
82
|
+
if (argc > 1) {
|
|
83
|
+
fname = argv[1];
|
|
84
|
+
} else {
|
|
85
|
+
fname = ".basic-rw";
|
|
86
|
+
t_create_file(fname, FILE_SIZE);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
vecs = t_create_buffers(BUFFERS, BS);
|
|
90
|
+
|
|
91
|
+
fd = open(fname, O_RDONLY | O_DIRECT);
|
|
92
|
+
if (fname != argv[1])
|
|
93
|
+
unlink(fname);
|
|
94
|
+
if (fd < 0) {
|
|
95
|
+
perror("open");
|
|
96
|
+
return -1;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
for (i = 0; i < NR_RINGS; i++) {
|
|
100
|
+
struct io_uring_params p = { };
|
|
101
|
+
|
|
102
|
+
p.flags = IORING_SETUP_SQPOLL;
|
|
103
|
+
if (i) {
|
|
104
|
+
p.wq_fd = rings[0].ring_fd;
|
|
105
|
+
p.flags |= IORING_SETUP_ATTACH_WQ;
|
|
106
|
+
}
|
|
107
|
+
ret = io_uring_queue_init_params(BUFFERS, &rings[i], &p);
|
|
108
|
+
if (ret) {
|
|
109
|
+
fprintf(stderr, "queue_init: %d/%d\n", ret, i);
|
|
110
|
+
goto err;
|
|
111
|
+
}
|
|
112
|
+
/* no sharing for non-fixed either */
|
|
113
|
+
if (!(p.features & IORING_FEAT_SQPOLL_NONFIXED)) {
|
|
114
|
+
fprintf(stdout, "No SQPOLL sharing, skipping\n");
|
|
115
|
+
return 0;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
ios = 0;
|
|
120
|
+
while (ios < (FILE_SIZE / BS)) {
|
|
121
|
+
for (i = 0; i < NR_RINGS; i++) {
|
|
122
|
+
ret = queue_io(&rings[i], fd, BUFFERS);
|
|
123
|
+
if (ret < 0)
|
|
124
|
+
goto err;
|
|
125
|
+
rets[i] = ret;
|
|
126
|
+
}
|
|
127
|
+
for (i = 0; i < NR_RINGS; i++) {
|
|
128
|
+
if (wait_io(&rings[i], rets[i]))
|
|
129
|
+
goto err;
|
|
130
|
+
}
|
|
131
|
+
ios += BUFFERS;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return 0;
|
|
135
|
+
err:
|
|
136
|
+
return 1;
|
|
137
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/* SPDX-License-Identifier: MIT */
|
|
2
|
+
/*
|
|
3
|
+
* Description: test SQ queue space left
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
#include <errno.h>
|
|
7
|
+
#include <stdio.h>
|
|
8
|
+
#include <unistd.h>
|
|
9
|
+
#include <stdlib.h>
|
|
10
|
+
#include <string.h>
|
|
11
|
+
#include <fcntl.h>
|
|
12
|
+
|
|
13
|
+
#include "liburing.h"
|
|
14
|
+
|
|
15
|
+
static int test_left(void)
|
|
16
|
+
{
|
|
17
|
+
struct io_uring_sqe *sqe;
|
|
18
|
+
struct io_uring ring;
|
|
19
|
+
int ret, i = 0, s;
|
|
20
|
+
|
|
21
|
+
ret = io_uring_queue_init(8, &ring, 0);
|
|
22
|
+
if (ret) {
|
|
23
|
+
fprintf(stderr, "ring setup failed: %d\n", ret);
|
|
24
|
+
return 1;
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if ((s = io_uring_sq_space_left(&ring)) != 8) {
|
|
29
|
+
fprintf(stderr, "Got %d SQEs left, expected %d\n", s, 8);
|
|
30
|
+
goto err;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
i = 0;
|
|
34
|
+
while ((sqe = io_uring_get_sqe(&ring)) != NULL) {
|
|
35
|
+
i++;
|
|
36
|
+
if ((s = io_uring_sq_space_left(&ring)) != 8 - i) {
|
|
37
|
+
fprintf(stderr, "Got %d SQEs left, expected %d\n", s, 8 - i);
|
|
38
|
+
goto err;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (i != 8) {
|
|
43
|
+
fprintf(stderr, "Got %d SQEs, expected %d\n", i, 8);
|
|
44
|
+
goto err;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
io_uring_queue_exit(&ring);
|
|
48
|
+
return 0;
|
|
49
|
+
err:
|
|
50
|
+
io_uring_queue_exit(&ring);
|
|
51
|
+
return 1;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static int test_sync(void)
|
|
55
|
+
{
|
|
56
|
+
struct io_uring_sqe *sqe;
|
|
57
|
+
struct io_uring ring;
|
|
58
|
+
int ret, i;
|
|
59
|
+
|
|
60
|
+
ret = io_uring_queue_init(32, &ring, 0);
|
|
61
|
+
if (ret) {
|
|
62
|
+
fprintf(stderr, "ring setup failed: %d\n", ret);
|
|
63
|
+
return 1;
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* prep 8 NOPS */
|
|
68
|
+
for (i = 0; i < 8; i++) {
|
|
69
|
+
sqe = io_uring_get_sqe(&ring);
|
|
70
|
+
if (!sqe) {
|
|
71
|
+
fprintf(stderr, "get sqe failed\n");
|
|
72
|
+
goto err;
|
|
73
|
+
}
|
|
74
|
+
io_uring_prep_nop(sqe);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/* prep known bad command, this should terminate submission */
|
|
78
|
+
sqe = io_uring_get_sqe(&ring);
|
|
79
|
+
if (!sqe) {
|
|
80
|
+
fprintf(stderr, "get sqe failed\n");
|
|
81
|
+
goto err;
|
|
82
|
+
}
|
|
83
|
+
io_uring_prep_nop(sqe);
|
|
84
|
+
sqe->opcode = 0xfe;
|
|
85
|
+
|
|
86
|
+
/* prep 8 NOPS */
|
|
87
|
+
for (i = 0; i < 8; i++) {
|
|
88
|
+
sqe = io_uring_get_sqe(&ring);
|
|
89
|
+
if (!sqe) {
|
|
90
|
+
fprintf(stderr, "get sqe failed\n");
|
|
91
|
+
goto err;
|
|
92
|
+
}
|
|
93
|
+
io_uring_prep_nop(sqe);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/* we should have 8 + 1 + 8 pending now */
|
|
97
|
+
ret = io_uring_sq_ready(&ring);
|
|
98
|
+
if (ret != 17) {
|
|
99
|
+
fprintf(stderr, "%d ready, wanted 17\n", ret);
|
|
100
|
+
goto err;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
ret = io_uring_submit(&ring);
|
|
104
|
+
|
|
105
|
+
/* should submit 8 successfully, then error #9 and stop */
|
|
106
|
+
if (ret != 9) {
|
|
107
|
+
fprintf(stderr, "submitted %d, wanted 9\n", ret);
|
|
108
|
+
goto err;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* should now have 8 ready, with 9 gone */
|
|
112
|
+
ret = io_uring_sq_ready(&ring);
|
|
113
|
+
if (ret != 8) {
|
|
114
|
+
fprintf(stderr, "%d ready, wanted 8\n", ret);
|
|
115
|
+
goto err;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
ret = io_uring_submit(&ring);
|
|
119
|
+
|
|
120
|
+
/* the last 8 should submit fine */
|
|
121
|
+
if (ret != 8) {
|
|
122
|
+
fprintf(stderr, "submitted %d, wanted 8\n", ret);
|
|
123
|
+
goto err;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
ret = io_uring_sq_ready(&ring);
|
|
127
|
+
if (ret) {
|
|
128
|
+
fprintf(stderr, "%d ready, wanted 0\n", ret);
|
|
129
|
+
goto err;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
io_uring_queue_exit(&ring);
|
|
133
|
+
return 0;
|
|
134
|
+
err:
|
|
135
|
+
io_uring_queue_exit(&ring);
|
|
136
|
+
return 1;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
int main(int argc, char *argv[])
|
|
140
|
+
{
|
|
141
|
+
int ret;
|
|
142
|
+
|
|
143
|
+
if (argc > 1)
|
|
144
|
+
return 0;
|
|
145
|
+
|
|
146
|
+
ret = test_left();
|
|
147
|
+
if (ret) {
|
|
148
|
+
fprintf(stderr, "test_left failed\n");
|
|
149
|
+
return ret;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
ret = test_sync();
|
|
153
|
+
if (ret) {
|
|
154
|
+
fprintf(stderr, "test_sync failed\n");
|
|
155
|
+
return ret;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return 0;
|
|
159
|
+
}
|