@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.
Files changed (190) hide show
  1. package/binding.cc +66 -91
  2. package/deps/liburing/liburing/COPYING +502 -0
  3. package/deps/liburing/liburing/COPYING.GPL +339 -0
  4. package/deps/liburing/liburing/LICENSE +7 -0
  5. package/deps/liburing/liburing/Makefile +84 -0
  6. package/deps/liburing/liburing/Makefile.quiet +11 -0
  7. package/deps/liburing/liburing/README +46 -0
  8. package/deps/liburing/liburing/configure +420 -0
  9. package/deps/liburing/liburing/debian/README.Debian +7 -0
  10. package/deps/liburing/liburing/debian/changelog +27 -0
  11. package/deps/liburing/liburing/debian/compat +1 -0
  12. package/deps/liburing/liburing/debian/control +48 -0
  13. package/deps/liburing/liburing/debian/copyright +49 -0
  14. package/deps/liburing/liburing/debian/liburing-dev.install +4 -0
  15. package/deps/liburing/liburing/debian/liburing-dev.manpages +6 -0
  16. package/deps/liburing/liburing/debian/liburing1-udeb.install +1 -0
  17. package/deps/liburing/liburing/debian/liburing1.install +1 -0
  18. package/deps/liburing/liburing/debian/liburing1.symbols +32 -0
  19. package/deps/liburing/liburing/debian/patches/series +1 -0
  20. package/deps/liburing/liburing/debian/rules +81 -0
  21. package/deps/liburing/liburing/debian/source/format +1 -0
  22. package/deps/liburing/liburing/debian/source/local-options +2 -0
  23. package/deps/liburing/liburing/debian/source/options +1 -0
  24. package/deps/liburing/liburing/debian/watch +3 -0
  25. package/deps/liburing/liburing/examples/Makefile +29 -0
  26. package/deps/liburing/liburing/examples/io_uring-cp.c +279 -0
  27. package/deps/liburing/liburing/examples/io_uring-test.c +112 -0
  28. package/deps/liburing/liburing/examples/link-cp.c +193 -0
  29. package/deps/liburing/liburing/examples/ucontext-cp.c +273 -0
  30. package/deps/liburing/liburing/liburing.pc.in +12 -0
  31. package/deps/liburing/liburing/liburing.spec +66 -0
  32. package/deps/liburing/liburing/make-debs.sh +53 -0
  33. package/deps/liburing/liburing/man/io_uring.7 +736 -0
  34. package/deps/liburing/liburing/man/io_uring_enter.2 +1403 -0
  35. package/deps/liburing/liburing/man/io_uring_get_sqe.3 +37 -0
  36. package/deps/liburing/liburing/man/io_uring_queue_exit.3 +27 -0
  37. package/deps/liburing/liburing/man/io_uring_queue_init.3 +44 -0
  38. package/deps/liburing/liburing/man/io_uring_register.2 +605 -0
  39. package/deps/liburing/liburing/man/io_uring_setup.2 +515 -0
  40. package/deps/liburing/liburing/src/Makefile +76 -0
  41. package/deps/liburing/liburing/src/include/liburing/barrier.h +73 -0
  42. package/deps/liburing/liburing/src/include/liburing/io_uring.h +422 -0
  43. package/deps/liburing/liburing/src/include/liburing.h +775 -0
  44. package/deps/liburing/liburing/src/liburing.map +46 -0
  45. package/deps/liburing/liburing/src/queue.c +403 -0
  46. package/deps/liburing/liburing/src/register.c +299 -0
  47. package/deps/liburing/liburing/src/setup.c +356 -0
  48. package/deps/liburing/liburing/src/syscall.c +73 -0
  49. package/deps/liburing/liburing/src/syscall.h +20 -0
  50. package/deps/liburing/liburing/test/232c93d07b74-test.c +305 -0
  51. package/deps/liburing/liburing/test/35fa71a030ca-test.c +329 -0
  52. package/deps/liburing/liburing/test/500f9fbadef8-test.c +89 -0
  53. package/deps/liburing/liburing/test/7ad0e4b2f83c-test.c +93 -0
  54. package/deps/liburing/liburing/test/8a9973408177-test.c +106 -0
  55. package/deps/liburing/liburing/test/917257daa0fe-test.c +53 -0
  56. package/deps/liburing/liburing/test/Makefile +312 -0
  57. package/deps/liburing/liburing/test/a0908ae19763-test.c +58 -0
  58. package/deps/liburing/liburing/test/a4c0b3decb33-test.c +180 -0
  59. package/deps/liburing/liburing/test/accept-link.c +251 -0
  60. package/deps/liburing/liburing/test/accept-reuse.c +164 -0
  61. package/deps/liburing/liburing/test/accept-test.c +79 -0
  62. package/deps/liburing/liburing/test/accept.c +476 -0
  63. package/deps/liburing/liburing/test/across-fork.c +283 -0
  64. package/deps/liburing/liburing/test/b19062a56726-test.c +53 -0
  65. package/deps/liburing/liburing/test/b5837bd5311d-test.c +77 -0
  66. package/deps/liburing/liburing/test/ce593a6c480a-test.c +135 -0
  67. package/deps/liburing/liburing/test/close-opath.c +122 -0
  68. package/deps/liburing/liburing/test/config +10 -0
  69. package/deps/liburing/liburing/test/connect.c +398 -0
  70. package/deps/liburing/liburing/test/cq-full.c +96 -0
  71. package/deps/liburing/liburing/test/cq-overflow.c +294 -0
  72. package/deps/liburing/liburing/test/cq-peek-batch.c +102 -0
  73. package/deps/liburing/liburing/test/cq-ready.c +94 -0
  74. package/deps/liburing/liburing/test/cq-size.c +58 -0
  75. package/deps/liburing/liburing/test/d4ae271dfaae-test.c +96 -0
  76. package/deps/liburing/liburing/test/d77a67ed5f27-test.c +65 -0
  77. package/deps/liburing/liburing/test/defer.c +307 -0
  78. package/deps/liburing/liburing/test/double-poll-crash.c +186 -0
  79. package/deps/liburing/liburing/test/eeed8b54e0df-test.c +114 -0
  80. package/deps/liburing/liburing/test/empty-eownerdead.c +42 -0
  81. package/deps/liburing/liburing/test/eventfd-disable.c +151 -0
  82. package/deps/liburing/liburing/test/eventfd-ring.c +97 -0
  83. package/deps/liburing/liburing/test/eventfd.c +112 -0
  84. package/deps/liburing/liburing/test/fadvise.c +202 -0
  85. package/deps/liburing/liburing/test/fallocate.c +249 -0
  86. package/deps/liburing/liburing/test/fc2a85cb02ef-test.c +138 -0
  87. package/deps/liburing/liburing/test/file-register.c +843 -0
  88. package/deps/liburing/liburing/test/file-update.c +173 -0
  89. package/deps/liburing/liburing/test/files-exit-hang-poll.c +128 -0
  90. package/deps/liburing/liburing/test/files-exit-hang-timeout.c +134 -0
  91. package/deps/liburing/liburing/test/fixed-link.c +90 -0
  92. package/deps/liburing/liburing/test/fsync.c +224 -0
  93. package/deps/liburing/liburing/test/hardlink.c +136 -0
  94. package/deps/liburing/liburing/test/helpers.c +135 -0
  95. package/deps/liburing/liburing/test/helpers.h +67 -0
  96. package/deps/liburing/liburing/test/io-cancel.c +537 -0
  97. package/deps/liburing/liburing/test/io_uring_enter.c +296 -0
  98. package/deps/liburing/liburing/test/io_uring_register.c +664 -0
  99. package/deps/liburing/liburing/test/io_uring_setup.c +192 -0
  100. package/deps/liburing/liburing/test/iopoll.c +366 -0
  101. package/deps/liburing/liburing/test/lfs-openat-write.c +117 -0
  102. package/deps/liburing/liburing/test/lfs-openat.c +273 -0
  103. package/deps/liburing/liburing/test/link-timeout.c +1107 -0
  104. package/deps/liburing/liburing/test/link.c +496 -0
  105. package/deps/liburing/liburing/test/link_drain.c +229 -0
  106. package/deps/liburing/liburing/test/madvise.c +195 -0
  107. package/deps/liburing/liburing/test/mkdir.c +108 -0
  108. package/deps/liburing/liburing/test/multicqes_drain.c +383 -0
  109. package/deps/liburing/liburing/test/nop-all-sizes.c +107 -0
  110. package/deps/liburing/liburing/test/nop.c +115 -0
  111. package/deps/liburing/liburing/test/open-close.c +146 -0
  112. package/deps/liburing/liburing/test/openat2.c +240 -0
  113. package/deps/liburing/liburing/test/personality.c +204 -0
  114. package/deps/liburing/liburing/test/pipe-eof.c +81 -0
  115. package/deps/liburing/liburing/test/pipe-reuse.c +105 -0
  116. package/deps/liburing/liburing/test/poll-cancel-ton.c +139 -0
  117. package/deps/liburing/liburing/test/poll-cancel.c +135 -0
  118. package/deps/liburing/liburing/test/poll-link.c +227 -0
  119. package/deps/liburing/liburing/test/poll-many.c +208 -0
  120. package/deps/liburing/liburing/test/poll-mshot-update.c +273 -0
  121. package/deps/liburing/liburing/test/poll-ring.c +48 -0
  122. package/deps/liburing/liburing/test/poll-v-poll.c +353 -0
  123. package/deps/liburing/liburing/test/poll.c +109 -0
  124. package/deps/liburing/liburing/test/probe.c +137 -0
  125. package/deps/liburing/liburing/test/read-write.c +876 -0
  126. package/deps/liburing/liburing/test/register-restrictions.c +633 -0
  127. package/deps/liburing/liburing/test/rename.c +134 -0
  128. package/deps/liburing/liburing/test/ring-leak.c +173 -0
  129. package/deps/liburing/liburing/test/ring-leak2.c +249 -0
  130. package/deps/liburing/liburing/test/rsrc_tags.c +449 -0
  131. package/deps/liburing/liburing/test/runtests-loop.sh +16 -0
  132. package/deps/liburing/liburing/test/runtests.sh +170 -0
  133. package/deps/liburing/liburing/test/rw_merge_test.c +97 -0
  134. package/deps/liburing/liburing/test/self.c +91 -0
  135. package/deps/liburing/liburing/test/send_recv.c +291 -0
  136. package/deps/liburing/liburing/test/send_recvmsg.c +345 -0
  137. package/deps/liburing/liburing/test/sendmsg_fs_cve.c +198 -0
  138. package/deps/liburing/liburing/test/shared-wq.c +84 -0
  139. package/deps/liburing/liburing/test/short-read.c +75 -0
  140. package/deps/liburing/liburing/test/shutdown.c +163 -0
  141. package/deps/liburing/liburing/test/sigfd-deadlock.c +74 -0
  142. package/deps/liburing/liburing/test/socket-rw-eagain.c +156 -0
  143. package/deps/liburing/liburing/test/socket-rw.c +147 -0
  144. package/deps/liburing/liburing/test/splice.c +511 -0
  145. package/deps/liburing/liburing/test/sq-full-cpp.cc +45 -0
  146. package/deps/liburing/liburing/test/sq-full.c +45 -0
  147. package/deps/liburing/liburing/test/sq-poll-dup.c +200 -0
  148. package/deps/liburing/liburing/test/sq-poll-kthread.c +168 -0
  149. package/deps/liburing/liburing/test/sq-poll-share.c +137 -0
  150. package/deps/liburing/liburing/test/sq-space_left.c +159 -0
  151. package/deps/liburing/liburing/test/sqpoll-cancel-hang.c +159 -0
  152. package/deps/liburing/liburing/test/sqpoll-disable-exit.c +195 -0
  153. package/deps/liburing/liburing/test/sqpoll-exit-hang.c +77 -0
  154. package/deps/liburing/liburing/test/sqpoll-sleep.c +68 -0
  155. package/deps/liburing/liburing/test/statx.c +172 -0
  156. package/deps/liburing/liburing/test/stdout.c +232 -0
  157. package/deps/liburing/liburing/test/submit-link-fail.c +154 -0
  158. package/deps/liburing/liburing/test/submit-reuse.c +239 -0
  159. package/deps/liburing/liburing/test/symlink.c +116 -0
  160. package/deps/liburing/liburing/test/teardowns.c +58 -0
  161. package/deps/liburing/liburing/test/thread-exit.c +131 -0
  162. package/deps/liburing/liburing/test/timeout-new.c +246 -0
  163. package/deps/liburing/liburing/test/timeout-overflow.c +204 -0
  164. package/deps/liburing/liburing/test/timeout.c +1354 -0
  165. package/deps/liburing/liburing/test/unlink.c +111 -0
  166. package/deps/liburing/liburing/test/wakeup-hang.c +162 -0
  167. package/deps/liburing/liburing.gyp +20 -0
  168. package/deps/rocksdb/rocksdb/db/corruption_test.cc +62 -0
  169. package/deps/rocksdb/rocksdb/db/db_impl/db_impl.h +7 -62
  170. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_files.cc +25 -11
  171. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_open.cc +74 -155
  172. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_secondary.cc +1 -2
  173. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_secondary.h +2 -2
  174. package/deps/rocksdb/rocksdb/env/fs_posix.cc +13 -0
  175. package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.cc +4 -2
  176. package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.h +22 -4
  177. package/deps/rocksdb/rocksdb/file/prefetch_test.cc +5 -0
  178. package/deps/rocksdb/rocksdb/include/rocksdb/file_system.h +15 -0
  179. package/deps/rocksdb/rocksdb/include/rocksdb/statistics.h +5 -0
  180. package/deps/rocksdb/rocksdb/include/rocksdb/version.h +1 -1
  181. package/deps/rocksdb/rocksdb/monitoring/statistics.cc +3 -0
  182. package/deps/rocksdb/rocksdb/monitoring/stats_history_test.cc +3 -7
  183. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.h +2 -1
  184. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_test.cc +44 -29
  185. package/deps/rocksdb/rocksdb.gyp +4 -3
  186. package/package.json +1 -1
  187. package/prebuilds/darwin-arm64/node.napi.node +0 -0
  188. package/prebuilds/darwin-x64/node.napi.node +0 -0
  189. package/prebuilds/linux-x64/node.napi.node +0 -0
  190. package/prebuilds/prebuilds/linux-x64/node.napi.node +0 -0
@@ -0,0 +1,283 @@
1
+ /* SPDX-License-Identifier: MIT */
2
+ /*
3
+ * Description: test sharing a ring across a fork
4
+ */
5
+ #include <fcntl.h>
6
+ #include <pthread.h>
7
+ #include <signal.h>
8
+ #include <stdio.h>
9
+ #include <stdlib.h>
10
+ #include <string.h>
11
+ #include <sys/mman.h>
12
+ #include <sys/stat.h>
13
+ #include <sys/types.h>
14
+ #include <sys/wait.h>
15
+ #include <unistd.h>
16
+
17
+ #include "liburing.h"
18
+
19
+
20
+ struct forktestmem
21
+ {
22
+ struct io_uring ring;
23
+ pthread_barrier_t barrier;
24
+ pthread_barrierattr_t barrierattr;
25
+ };
26
+
27
+ static int open_tempfile(const char *dir, const char *fname)
28
+ {
29
+ int fd;
30
+ char buf[32];
31
+
32
+ snprintf(buf, sizeof(buf), "%s/%s",
33
+ dir, fname);
34
+ fd = open(buf, O_RDWR | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR);
35
+ if (fd < 0) {
36
+ perror("open");
37
+ exit(1);
38
+ }
39
+
40
+ return fd;
41
+ }
42
+
43
+ static int submit_write(struct io_uring *ring, int fd, const char *str,
44
+ int wait)
45
+ {
46
+ struct io_uring_sqe *sqe;
47
+ struct iovec iovec;
48
+ int ret;
49
+
50
+ sqe = io_uring_get_sqe(ring);
51
+ if (!sqe) {
52
+ fprintf(stderr, "could not get sqe\n");
53
+ return 1;
54
+ }
55
+
56
+ iovec.iov_base = (char *) str;
57
+ iovec.iov_len = strlen(str);
58
+ io_uring_prep_writev(sqe, fd, &iovec, 1, 0);
59
+ ret = io_uring_submit_and_wait(ring, wait);
60
+ if (ret < 0) {
61
+ fprintf(stderr, "submit failed: %s\n", strerror(-ret));
62
+ return 1;
63
+ }
64
+
65
+ return 0;
66
+ }
67
+
68
+ static int wait_cqe(struct io_uring *ring, const char *stage)
69
+ {
70
+ struct io_uring_cqe *cqe;
71
+ int ret;
72
+
73
+ ret = io_uring_wait_cqe(ring, &cqe);
74
+ if (ret) {
75
+ fprintf(stderr, "%s wait_cqe failed %d\n", stage, ret);
76
+ return 1;
77
+ }
78
+ if (cqe->res < 0) {
79
+ fprintf(stderr, "%s cqe failed %d\n", stage, cqe->res);
80
+ return 1;
81
+ }
82
+
83
+ io_uring_cqe_seen(ring, cqe);
84
+ return 0;
85
+ }
86
+
87
+ static int verify_file(const char *tmpdir, const char *fname, const char* expect)
88
+ {
89
+ int fd;
90
+ char buf[512];
91
+ int err = 0;
92
+
93
+ memset(buf, 0, sizeof(buf));
94
+
95
+ fd = open_tempfile(tmpdir, fname);
96
+ if (fd < 0)
97
+ return 1;
98
+
99
+ if (read(fd, buf, sizeof(buf) - 1) < 0)
100
+ return 1;
101
+
102
+ if (strcmp(buf, expect) != 0) {
103
+ fprintf(stderr, "content mismatch for %s\n"
104
+ "got:\n%s\n"
105
+ "expected:\n%s\n",
106
+ fname, buf, expect);
107
+ err = 1;
108
+ }
109
+
110
+ close(fd);
111
+ return err;
112
+ }
113
+
114
+ static void cleanup(const char *tmpdir)
115
+ {
116
+ char buf[32];
117
+
118
+ /* don't check errors, called during partial runs */
119
+
120
+ snprintf(buf, sizeof(buf), "%s/%s", tmpdir, "shared");
121
+ unlink(buf);
122
+
123
+ snprintf(buf, sizeof(buf), "%s/%s", tmpdir, "parent1");
124
+ unlink(buf);
125
+
126
+ snprintf(buf, sizeof(buf), "%s/%s", tmpdir, "parent2");
127
+ unlink(buf);
128
+
129
+ snprintf(buf, sizeof(buf), "%s/%s", tmpdir, "child");
130
+ unlink(buf);
131
+
132
+ rmdir(tmpdir);
133
+ }
134
+
135
+ int main(int argc, char *argv[])
136
+ {
137
+ struct forktestmem *shmem;
138
+ char tmpdir[] = "forktmpXXXXXX";
139
+ int shared_fd;
140
+ int ret;
141
+ pid_t p;
142
+
143
+ if (argc > 1)
144
+ return 0;
145
+
146
+ shmem = mmap(0, sizeof(struct forktestmem), PROT_READ|PROT_WRITE,
147
+ MAP_SHARED | MAP_ANONYMOUS, 0, 0);
148
+ if (!shmem) {
149
+ fprintf(stderr, "mmap failed\n");
150
+ exit(1);
151
+ }
152
+
153
+ pthread_barrierattr_init(&shmem->barrierattr);
154
+ pthread_barrierattr_setpshared(&shmem->barrierattr, 1);
155
+ pthread_barrier_init(&shmem->barrier, &shmem->barrierattr, 2);
156
+
157
+ ret = io_uring_queue_init(10, &shmem->ring, 0);
158
+ if (ret < 0) {
159
+ fprintf(stderr, "queue init failed\n");
160
+ exit(1);
161
+ }
162
+
163
+ if (mkdtemp(tmpdir) == NULL) {
164
+ fprintf(stderr, "temp directory creation failed\n");
165
+ exit(1);
166
+ }
167
+
168
+ shared_fd = open_tempfile(tmpdir, "shared");
169
+
170
+ /*
171
+ * First do a write before the fork, to test whether child can
172
+ * reap that
173
+ */
174
+ if (submit_write(&shmem->ring, shared_fd, "before fork: write shared fd\n", 0))
175
+ goto errcleanup;
176
+
177
+ p = fork();
178
+ switch (p) {
179
+ case -1:
180
+ fprintf(stderr, "fork failed\n");
181
+ goto errcleanup;
182
+
183
+ default: {
184
+ /* parent */
185
+ int parent_fd1;
186
+ int parent_fd2;
187
+ int wstatus;
188
+
189
+ /* wait till fork is started up */
190
+ pthread_barrier_wait(&shmem->barrier);
191
+
192
+ parent_fd1 = open_tempfile(tmpdir, "parent1");
193
+ parent_fd2 = open_tempfile(tmpdir, "parent2");
194
+
195
+ /* do a parent write to the shared fd */
196
+ if (submit_write(&shmem->ring, shared_fd, "parent: write shared fd\n", 0))
197
+ goto errcleanup;
198
+
199
+ /* do a parent write to an fd where same numbered fd exists in child */
200
+ if (submit_write(&shmem->ring, parent_fd1, "parent: write parent fd 1\n", 0))
201
+ goto errcleanup;
202
+
203
+ /* do a parent write to an fd where no same numbered fd exists in child */
204
+ if (submit_write(&shmem->ring, parent_fd2, "parent: write parent fd 2\n", 0))
205
+ goto errcleanup;
206
+
207
+ /* wait to switch read/writ roles with child */
208
+ pthread_barrier_wait(&shmem->barrier);
209
+
210
+ /* now wait for child to exit, to ensure we still can read completion */
211
+ waitpid(p, &wstatus, 0);
212
+ if (WEXITSTATUS(wstatus) != 0) {
213
+ fprintf(stderr, "child failed\n");
214
+ goto errcleanup;
215
+ }
216
+
217
+ if (wait_cqe(&shmem->ring, "p cqe 1"))
218
+ goto errcleanup;
219
+
220
+ if (wait_cqe(&shmem->ring, "p cqe 2"))
221
+ goto errcleanup;
222
+
223
+ /* check that IO can still be submitted after child exited */
224
+ if (submit_write(&shmem->ring, shared_fd, "parent: write shared fd after child exit\n", 0))
225
+ goto errcleanup;
226
+
227
+ if (wait_cqe(&shmem->ring, "p cqe 3"))
228
+ goto errcleanup;
229
+
230
+ break;
231
+ }
232
+ case 0: {
233
+ /* child */
234
+ int child_fd;
235
+
236
+ /* wait till fork is started up */
237
+ pthread_barrier_wait(&shmem->barrier);
238
+
239
+ child_fd = open_tempfile(tmpdir, "child");
240
+
241
+ if (wait_cqe(&shmem->ring, "c cqe shared"))
242
+ exit(1);
243
+
244
+ if (wait_cqe(&shmem->ring, "c cqe parent 1"))
245
+ exit(1);
246
+
247
+ if (wait_cqe(&shmem->ring, "c cqe parent 2"))
248
+ exit(1);
249
+
250
+ if (wait_cqe(&shmem->ring, "c cqe parent 3"))
251
+ exit(1);
252
+
253
+ /* wait to switch read/writ roles with parent */
254
+ pthread_barrier_wait(&shmem->barrier);
255
+
256
+ if (submit_write(&shmem->ring, child_fd, "child: write child fd\n", 0))
257
+ exit(1);
258
+
259
+ /* ensure both writes have finished before child exits */
260
+ if (submit_write(&shmem->ring, shared_fd, "child: write shared fd\n", 2))
261
+ exit(1);
262
+
263
+ exit(0);
264
+ }
265
+ }
266
+
267
+ if (verify_file(tmpdir, "shared",
268
+ "before fork: write shared fd\n"
269
+ "parent: write shared fd\n"
270
+ "child: write shared fd\n"
271
+ "parent: write shared fd after child exit\n") ||
272
+ verify_file(tmpdir, "parent1", "parent: write parent fd 1\n") ||
273
+ verify_file(tmpdir, "parent2", "parent: write parent fd 2\n") ||
274
+ verify_file(tmpdir, "child", "child: write child fd\n"))
275
+ goto errcleanup;
276
+
277
+ cleanup(tmpdir);
278
+ exit(0);
279
+
280
+ errcleanup:
281
+ cleanup(tmpdir);
282
+ exit(1);
283
+ }
@@ -0,0 +1,53 @@
1
+ /* SPDX-License-Identifier: MIT */
2
+ // autogenerated by syzkaller (https://github.com/google/syzkaller)
3
+
4
+ #include <endian.h>
5
+ #include <stdint.h>
6
+ #include <stdio.h>
7
+ #include <stdlib.h>
8
+ #include <string.h>
9
+ #include <sys/types.h>
10
+ #include <sys/mman.h>
11
+ #include <unistd.h>
12
+
13
+ #include "liburing.h"
14
+ #include "../src/syscall.h"
15
+
16
+ int main(int argc, char *argv[])
17
+ {
18
+ if (argc > 1)
19
+ return 0;
20
+
21
+ mmap((void *) 0x20000000, 0x1000000, 3, 0x32, -1, 0);
22
+
23
+ *(uint32_t*)0x20000200 = 0;
24
+ *(uint32_t*)0x20000204 = 0;
25
+ *(uint32_t*)0x20000208 = 5;
26
+ *(uint32_t*)0x2000020c = 0x400;
27
+ *(uint32_t*)0x20000210 = 0;
28
+ *(uint32_t*)0x20000214 = 0;
29
+ *(uint32_t*)0x20000218 = 0;
30
+ *(uint32_t*)0x2000021c = 0;
31
+ *(uint32_t*)0x20000220 = 0;
32
+ *(uint32_t*)0x20000224 = 0;
33
+ *(uint32_t*)0x20000228 = 0;
34
+ *(uint32_t*)0x2000022c = 0;
35
+ *(uint32_t*)0x20000230 = 0;
36
+ *(uint32_t*)0x20000234 = 0;
37
+ *(uint32_t*)0x20000238 = 0;
38
+ *(uint32_t*)0x2000023c = 0;
39
+ *(uint32_t*)0x20000240 = 0;
40
+ *(uint32_t*)0x20000244 = 0;
41
+ *(uint64_t*)0x20000248 = 0;
42
+ *(uint32_t*)0x20000250 = 0;
43
+ *(uint32_t*)0x20000254 = 0;
44
+ *(uint32_t*)0x20000258 = 0;
45
+ *(uint32_t*)0x2000025c = 0;
46
+ *(uint32_t*)0x20000260 = 0;
47
+ *(uint32_t*)0x20000264 = 0;
48
+ *(uint32_t*)0x20000268 = 0;
49
+ *(uint32_t*)0x2000026c = 0;
50
+ *(uint64_t*)0x20000270 = 0;
51
+ __sys_io_uring_setup(0xc9f, (struct io_uring_params *) 0x20000200);
52
+ return 0;
53
+ }
@@ -0,0 +1,77 @@
1
+ /* SPDX-License-Identifier: MIT */
2
+ /*
3
+ * Description: Check to see if wait_nr is being honored.
4
+ */
5
+ #include <stdio.h>
6
+ #include "liburing.h"
7
+
8
+ int main(int argc, char *argv[])
9
+ {
10
+ struct io_uring_sqe *sqe;
11
+ struct io_uring_cqe *cqe;
12
+ struct io_uring ring;
13
+ int ret;
14
+ struct __kernel_timespec ts = {
15
+ .tv_sec = 0,
16
+ .tv_nsec = 10000000
17
+ };
18
+
19
+ if (argc > 1)
20
+ return 0;
21
+
22
+ if (io_uring_queue_init(4, &ring, 0) != 0) {
23
+ fprintf(stderr, "ring setup failed\n");
24
+ return 1;
25
+ }
26
+
27
+ /*
28
+ * First, submit the timeout sqe so we can actually finish the test
29
+ * if everything is in working order.
30
+ */
31
+ sqe = io_uring_get_sqe(&ring);
32
+ if (!sqe) {
33
+ fprintf(stderr, "get sqe failed\n");
34
+ return 1;
35
+ }
36
+ io_uring_prep_timeout(sqe, &ts, (unsigned)-1, 0);
37
+
38
+ ret = io_uring_submit(&ring);
39
+ if (ret != 1) {
40
+ fprintf(stderr, "Got submit %d, expected 1\n", ret);
41
+ return 1;
42
+ }
43
+
44
+ /*
45
+ * Next, submit a nop and wait for two events. If everything is working
46
+ * as it should, we should be waiting for more than a millisecond and we
47
+ * should see two cqes. Otherwise, execution continues immediately
48
+ * and we see only one cqe.
49
+ */
50
+ sqe = io_uring_get_sqe(&ring);
51
+ if (!sqe) {
52
+ fprintf(stderr, "get sqe failed\n");
53
+ return 1;
54
+ }
55
+ io_uring_prep_nop(sqe);
56
+
57
+ ret = io_uring_submit_and_wait(&ring, 2);
58
+ if (ret != 1) {
59
+ fprintf(stderr, "Got submit %d, expected 1\n", ret);
60
+ return 1;
61
+ }
62
+
63
+ if (io_uring_peek_cqe(&ring, &cqe) != 0) {
64
+ fprintf(stderr, "Unable to peek cqe!\n");
65
+ return 1;
66
+ }
67
+
68
+ io_uring_cqe_seen(&ring, cqe);
69
+
70
+ if (io_uring_peek_cqe(&ring, &cqe) != 0) {
71
+ fprintf(stderr, "Unable to peek cqe!\n");
72
+ return 1;
73
+ }
74
+
75
+ io_uring_queue_exit(&ring);
76
+ return 0;
77
+ }
@@ -0,0 +1,135 @@
1
+ /*
2
+ * Test 5.7 regression with task_work not being run while a task is
3
+ * waiting on another event in the kernel.
4
+ */
5
+ #include <errno.h>
6
+ #include <poll.h>
7
+ #include <stdio.h>
8
+ #include <stdlib.h>
9
+ #include <sys/eventfd.h>
10
+ #include <unistd.h>
11
+ #include <pthread.h>
12
+ #include "liburing.h"
13
+ #include "helpers.h"
14
+
15
+ static int use_sqpoll = 0;
16
+
17
+ void notify_fd(int fd)
18
+ {
19
+ char buf[8] = {0, 0, 0, 0, 0, 0, 1};
20
+ int ret;
21
+
22
+ ret = write(fd, &buf, 8);
23
+ if (ret < 0)
24
+ perror("write");
25
+ }
26
+
27
+ void *delay_set_fd_from_thread(void *data)
28
+ {
29
+ int fd = (intptr_t) data;
30
+
31
+ sleep(1);
32
+ notify_fd(fd);
33
+ return NULL;
34
+ }
35
+
36
+ int main(int argc, char *argv[])
37
+ {
38
+ struct io_uring_params p = {};
39
+ struct io_uring ring;
40
+ int loop_fd, other_fd;
41
+ struct io_uring_sqe *sqe;
42
+ struct io_uring_cqe *cqe = NULL;
43
+ int ret, use_fd;
44
+ char buf[8] = {0, 0, 0, 0, 0, 0, 1};
45
+ pthread_t tid;
46
+
47
+ if (argc > 1)
48
+ return 0;
49
+
50
+ /* Create an eventfd to be registered with the loop to be
51
+ * notified of events being ready
52
+ */
53
+ loop_fd = eventfd(0, EFD_CLOEXEC);
54
+ if (loop_fd == -1) {
55
+ fprintf(stderr, "eventfd errno=%d\n", errno);
56
+ return 1;
57
+ }
58
+
59
+ /* Create an eventfd that can create events */
60
+ use_fd = other_fd = eventfd(0, EFD_CLOEXEC);
61
+ if (other_fd == -1) {
62
+ fprintf(stderr, "eventfd errno=%d\n", errno);
63
+ return 1;
64
+ }
65
+
66
+ if (use_sqpoll)
67
+ p.flags = IORING_SETUP_SQPOLL;
68
+
69
+ /* Setup the ring with a registered event fd to be notified on events */
70
+ ret = t_create_ring_params(8, &ring, &p);
71
+ if (ret == T_SETUP_SKIP)
72
+ return 0;
73
+ else if (ret < 0)
74
+ return ret;
75
+
76
+ ret = io_uring_register_eventfd(&ring, loop_fd);
77
+ if (ret < 0) {
78
+ fprintf(stderr, "register_eventfd=%d\n", ret);
79
+ return 1;
80
+ }
81
+
82
+ if (use_sqpoll) {
83
+ ret = io_uring_register_files(&ring, &other_fd, 1);
84
+ if (ret < 0) {
85
+ fprintf(stderr, "register_files=%d\n", ret);
86
+ return 1;
87
+ }
88
+ use_fd = 0;
89
+ }
90
+
91
+ /* Submit a poll operation to wait on an event in other_fd */
92
+ sqe = io_uring_get_sqe(&ring);
93
+ io_uring_prep_poll_add(sqe, use_fd, POLLIN);
94
+ sqe->user_data = 1;
95
+ if (use_sqpoll)
96
+ sqe->flags |= IOSQE_FIXED_FILE;
97
+ ret = io_uring_submit(&ring);
98
+ if (ret != 1) {
99
+ fprintf(stderr, "submit=%d\n", ret);
100
+ return 1;
101
+ }
102
+
103
+ /*
104
+ * CASE 3: Hangs forever in Linux 5.7.5; Works in Linux 5.6.0 When this
105
+ * code is uncommented, we don't se a notification on other_fd until
106
+ * _after_ we have started the read on loop_fd. In that case, the read() on
107
+ * loop_fd seems to hang forever.
108
+ */
109
+ pthread_create(&tid, NULL, delay_set_fd_from_thread,
110
+ (void*) (intptr_t) other_fd);
111
+
112
+ /* Wait on the event fd for an event to be ready */
113
+ ret = read(loop_fd, buf, 8);
114
+ if (ret < 0) {
115
+ perror("read");
116
+ return 1;
117
+ } else if (ret != 8) {
118
+ fprintf(stderr, "Odd-sized eventfd read: %d\n", ret);
119
+ return 1;
120
+ }
121
+
122
+
123
+ ret = io_uring_wait_cqe(&ring, &cqe);
124
+ if (ret) {
125
+ fprintf(stderr, "wait_cqe=%d\n", ret);
126
+ return ret;
127
+ }
128
+ if (cqe->res < 0) {
129
+ fprintf(stderr, "cqe->res=%d\n", cqe->res);
130
+ return 1;
131
+ }
132
+
133
+ io_uring_cqe_seen(&ring, cqe);
134
+ return 0;
135
+ }
@@ -0,0 +1,122 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ #define _GNU_SOURCE 1
4
+ #define _FILE_OFFSET_BITS 64
5
+
6
+ // Test program for io_uring IORING_OP_CLOSE with O_PATH file.
7
+ // Author: Clayton Harris <bugs@claycon.org>, 2020-06-07
8
+
9
+ // linux 5.6.14-300.fc32.x86_64
10
+ // gcc 10.1.1-1.fc32
11
+ // liburing.x86_64 0.5-1.fc32
12
+
13
+ // gcc -O2 -Wall -Wextra -std=c11 -o close_opath close_opath.c -luring
14
+ // ./close_opath testfilepath
15
+
16
+ #include <errno.h>
17
+ #include <fcntl.h>
18
+ #include <liburing.h>
19
+ #include <sys/stat.h>
20
+ #include <stdio.h>
21
+ #include <string.h>
22
+ #include <unistd.h>
23
+
24
+ typedef struct
25
+ {
26
+ const char *const flnames;
27
+ const int oflags;
28
+ } oflgs_t;
29
+
30
+ static int test_io_uring_close(struct io_uring *ring, int fd)
31
+ {
32
+ struct io_uring_sqe *sqe;
33
+ struct io_uring_cqe *cqe;
34
+ int ret;
35
+
36
+ sqe = io_uring_get_sqe(ring);
37
+ if (!sqe) {
38
+ fprintf(stderr, "io_uring_get_sqe() failed\n");
39
+ return -ENOENT;
40
+ }
41
+
42
+ io_uring_prep_close(sqe, fd);
43
+
44
+ ret = io_uring_submit(ring);
45
+ if (ret < 0) {
46
+ fprintf(stderr, "io_uring_submit() failed, errno %d: %s\n",
47
+ -ret, strerror(-ret));
48
+ return ret;
49
+ }
50
+
51
+ ret = io_uring_wait_cqe(ring, &cqe);
52
+ if (ret < 0) {
53
+ fprintf(stderr, "io_uring_wait_cqe() failed, errno %d: %s\n",
54
+ -ret, strerror(-ret));
55
+ return ret;
56
+ }
57
+
58
+ ret = cqe->res;
59
+ io_uring_cqe_seen(ring, cqe);
60
+
61
+ if (ret < 0 && ret != -EOPNOTSUPP && ret != -EINVAL && ret != -EBADF) {
62
+ fprintf(stderr, "io_uring close() failed, errno %d: %s\n",
63
+ -ret, strerror(-ret));
64
+ return ret;
65
+ }
66
+
67
+ return 0;
68
+ }
69
+
70
+ static int open_file(const char *path, const oflgs_t *oflgs)
71
+ {
72
+ int fd;
73
+
74
+ fd = openat(AT_FDCWD, path, oflgs->oflags, 0);
75
+ if (fd < 0) {
76
+ int err = errno;
77
+ fprintf(stderr, "openat(%s, %s) failed, errno %d: %s\n",
78
+ path, oflgs->flnames, err, strerror(err));
79
+ return -err;
80
+ }
81
+
82
+ return fd;
83
+ }
84
+
85
+ int main(int argc, char *argv[])
86
+ {
87
+ const char *fname = ".";
88
+ struct io_uring ring;
89
+ int ret, i;
90
+ static const oflgs_t oflgs[] = {
91
+ { "O_RDONLY", O_RDONLY },
92
+ { "O_PATH", O_PATH }
93
+ };
94
+
95
+ ret = io_uring_queue_init(2, &ring, 0);
96
+ if (ret < 0) {
97
+ fprintf(stderr, "io_uring_queue_init() failed, errno %d: %s\n",
98
+ -ret, strerror(-ret));
99
+ return 0x02;
100
+ }
101
+
102
+ #define OFLGS_SIZE (sizeof(oflgs) / sizeof(oflgs[0]))
103
+
104
+ ret = 0;
105
+ for (i = 0; i < OFLGS_SIZE; i++) {
106
+ int fd;
107
+
108
+ fd = open_file(fname, &oflgs[i]);
109
+ if (fd < 0) {
110
+ ret |= 0x02;
111
+ break;
112
+ }
113
+
114
+ /* Should always succeed */
115
+ if (test_io_uring_close(&ring, fd) < 0)
116
+ ret |= 0x04 << i;
117
+ }
118
+ #undef OFLGS_SIZE
119
+
120
+ io_uring_queue_exit(&ring);
121
+ return ret;
122
+ }
@@ -0,0 +1,10 @@
1
+ # Copy this to config.local, uncomment and define values
2
+ #
3
+ # Define tests to exclude from running
4
+ # TEST_EXCLUDE=""
5
+ #
6
+ # Define raw test devices (or files) for test cases, if any
7
+ # declare -A TEST_MAP=()
8
+ #
9
+ # If no TEST_MAP entry exists for a test, use the ones given in TEST_FILES
10
+ # TEST_FILES="/dev/somedevice /data/somefile"