@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,273 @@
|
|
|
1
|
+
#define _LARGEFILE_SOURCE
|
|
2
|
+
#define _FILE_OFFSET_BITS 64
|
|
3
|
+
|
|
4
|
+
#include <string.h>
|
|
5
|
+
#include <stdio.h>
|
|
6
|
+
#include <stdlib.h>
|
|
7
|
+
#include <sys/types.h>
|
|
8
|
+
#include <sys/stat.h>
|
|
9
|
+
#include <fcntl.h>
|
|
10
|
+
#include <errno.h>
|
|
11
|
+
#include <sys/resource.h>
|
|
12
|
+
#include <unistd.h>
|
|
13
|
+
|
|
14
|
+
#include "liburing.h"
|
|
15
|
+
|
|
16
|
+
#define DIE(...) do {\
|
|
17
|
+
fprintf(stderr, __VA_ARGS__);\
|
|
18
|
+
abort();\
|
|
19
|
+
} while(0);
|
|
20
|
+
|
|
21
|
+
static const int RSIZE = 2;
|
|
22
|
+
static const int OPEN_FLAGS = O_RDWR | O_CREAT;
|
|
23
|
+
static const mode_t OPEN_MODE = S_IRUSR | S_IWUSR;
|
|
24
|
+
|
|
25
|
+
static int open_io_uring(struct io_uring *ring, int dfd, const char *fn)
|
|
26
|
+
{
|
|
27
|
+
struct io_uring_sqe *sqe;
|
|
28
|
+
struct io_uring_cqe *cqe;
|
|
29
|
+
int ret, fd;
|
|
30
|
+
|
|
31
|
+
sqe = io_uring_get_sqe(ring);
|
|
32
|
+
if (!sqe) {
|
|
33
|
+
fprintf(stderr, "failed to get sqe\n");
|
|
34
|
+
return 1;
|
|
35
|
+
}
|
|
36
|
+
io_uring_prep_openat(sqe, dfd, fn, OPEN_FLAGS, OPEN_MODE);
|
|
37
|
+
|
|
38
|
+
ret = io_uring_submit(ring);
|
|
39
|
+
if (ret < 0) {
|
|
40
|
+
fprintf(stderr, "failed to submit openat: %s\n", strerror(-ret));
|
|
41
|
+
return 1;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
ret = io_uring_wait_cqe(ring, &cqe);
|
|
45
|
+
fd = cqe->res;
|
|
46
|
+
io_uring_cqe_seen(ring, cqe);
|
|
47
|
+
if (ret < 0) {
|
|
48
|
+
fprintf(stderr, "wait_cqe failed: %s\n", strerror(-ret));
|
|
49
|
+
return 1;
|
|
50
|
+
} else if (fd < 0) {
|
|
51
|
+
fprintf(stderr, "io_uring openat failed: %s\n", strerror(-fd));
|
|
52
|
+
return 1;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
close(fd);
|
|
56
|
+
return 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static int prepare_file(int dfd, const char* fn)
|
|
60
|
+
{
|
|
61
|
+
const char buf[] = "foo";
|
|
62
|
+
int fd, res;
|
|
63
|
+
|
|
64
|
+
fd = openat(dfd, fn, OPEN_FLAGS, OPEN_MODE);
|
|
65
|
+
if (fd < 0) {
|
|
66
|
+
fprintf(stderr, "prepare/open: %s\n", strerror(errno));
|
|
67
|
+
return -1;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
res = pwrite(fd, buf, sizeof(buf), 1ull << 32);
|
|
71
|
+
if (res < 0)
|
|
72
|
+
fprintf(stderr, "prepare/pwrite: %s\n", strerror(errno));
|
|
73
|
+
|
|
74
|
+
close(fd);
|
|
75
|
+
return res < 0 ? res : 0;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
static int test_linked_files(int dfd, const char *fn, bool async)
|
|
79
|
+
{
|
|
80
|
+
struct io_uring ring;
|
|
81
|
+
struct io_uring_sqe *sqe;
|
|
82
|
+
char buffer[128];
|
|
83
|
+
struct iovec iov = {.iov_base = buffer, .iov_len = sizeof(buffer), };
|
|
84
|
+
int ret, fd;
|
|
85
|
+
int fds[2];
|
|
86
|
+
|
|
87
|
+
ret = io_uring_queue_init(10, &ring, 0);
|
|
88
|
+
if (ret < 0)
|
|
89
|
+
DIE("failed to init io_uring: %s\n", strerror(-ret));
|
|
90
|
+
|
|
91
|
+
if (pipe(fds)) {
|
|
92
|
+
perror("pipe");
|
|
93
|
+
return 1;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
sqe = io_uring_get_sqe(&ring);
|
|
97
|
+
if (!sqe) {
|
|
98
|
+
printf("get sqe failed\n");
|
|
99
|
+
return -1;
|
|
100
|
+
}
|
|
101
|
+
io_uring_prep_readv(sqe, fds[0], &iov, 1, 0);
|
|
102
|
+
sqe->flags |= IOSQE_IO_LINK;
|
|
103
|
+
if (async)
|
|
104
|
+
sqe->flags |= IOSQE_ASYNC;
|
|
105
|
+
|
|
106
|
+
sqe = io_uring_get_sqe(&ring);
|
|
107
|
+
if (!sqe) {
|
|
108
|
+
fprintf(stderr, "failed to get sqe\n");
|
|
109
|
+
return 1;
|
|
110
|
+
}
|
|
111
|
+
io_uring_prep_openat(sqe, dfd, fn, OPEN_FLAGS, OPEN_MODE);
|
|
112
|
+
|
|
113
|
+
ret = io_uring_submit(&ring);
|
|
114
|
+
if (ret != 2) {
|
|
115
|
+
fprintf(stderr, "failed to submit openat: %s\n", strerror(-ret));
|
|
116
|
+
return 1;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
fd = dup(ring.ring_fd);
|
|
120
|
+
if (fd < 0) {
|
|
121
|
+
fprintf(stderr, "dup() failed: %s\n", strerror(-fd));
|
|
122
|
+
return 1;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/* io_uring->flush() */
|
|
126
|
+
close(fd);
|
|
127
|
+
|
|
128
|
+
io_uring_queue_exit(&ring);
|
|
129
|
+
return 0;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
static int test_drained_files(int dfd, const char *fn, bool linked, bool prepend)
|
|
133
|
+
{
|
|
134
|
+
struct io_uring ring;
|
|
135
|
+
struct io_uring_sqe *sqe;
|
|
136
|
+
char buffer[128];
|
|
137
|
+
struct iovec iov = {.iov_base = buffer, .iov_len = sizeof(buffer), };
|
|
138
|
+
int ret, fd, fds[2], to_cancel = 0;
|
|
139
|
+
|
|
140
|
+
ret = io_uring_queue_init(10, &ring, 0);
|
|
141
|
+
if (ret < 0)
|
|
142
|
+
DIE("failed to init io_uring: %s\n", strerror(-ret));
|
|
143
|
+
|
|
144
|
+
if (pipe(fds)) {
|
|
145
|
+
perror("pipe");
|
|
146
|
+
return 1;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
sqe = io_uring_get_sqe(&ring);
|
|
150
|
+
if (!sqe) {
|
|
151
|
+
printf("get sqe failed\n");
|
|
152
|
+
return -1;
|
|
153
|
+
}
|
|
154
|
+
io_uring_prep_readv(sqe, fds[0], &iov, 1, 0);
|
|
155
|
+
sqe->user_data = 0;
|
|
156
|
+
|
|
157
|
+
if (prepend) {
|
|
158
|
+
sqe = io_uring_get_sqe(&ring);
|
|
159
|
+
if (!sqe) {
|
|
160
|
+
fprintf(stderr, "failed to get sqe\n");
|
|
161
|
+
return 1;
|
|
162
|
+
}
|
|
163
|
+
io_uring_prep_nop(sqe);
|
|
164
|
+
sqe->flags |= IOSQE_IO_DRAIN;
|
|
165
|
+
to_cancel++;
|
|
166
|
+
sqe->user_data = to_cancel;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (linked) {
|
|
170
|
+
sqe = io_uring_get_sqe(&ring);
|
|
171
|
+
if (!sqe) {
|
|
172
|
+
fprintf(stderr, "failed to get sqe\n");
|
|
173
|
+
return 1;
|
|
174
|
+
}
|
|
175
|
+
io_uring_prep_nop(sqe);
|
|
176
|
+
sqe->flags |= IOSQE_IO_DRAIN | IOSQE_IO_LINK;
|
|
177
|
+
to_cancel++;
|
|
178
|
+
sqe->user_data = to_cancel;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
sqe = io_uring_get_sqe(&ring);
|
|
182
|
+
if (!sqe) {
|
|
183
|
+
fprintf(stderr, "failed to get sqe\n");
|
|
184
|
+
return 1;
|
|
185
|
+
}
|
|
186
|
+
io_uring_prep_openat(sqe, dfd, fn, OPEN_FLAGS, OPEN_MODE);
|
|
187
|
+
sqe->flags |= IOSQE_IO_DRAIN;
|
|
188
|
+
to_cancel++;
|
|
189
|
+
sqe->user_data = to_cancel;
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
ret = io_uring_submit(&ring);
|
|
193
|
+
if (ret != 1 + to_cancel) {
|
|
194
|
+
fprintf(stderr, "failed to submit openat: %s\n", strerror(-ret));
|
|
195
|
+
return 1;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
fd = dup(ring.ring_fd);
|
|
199
|
+
if (fd < 0) {
|
|
200
|
+
fprintf(stderr, "dup() failed: %s\n", strerror(-fd));
|
|
201
|
+
return 1;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/*
|
|
205
|
+
* close(), which triggers ->flush(), and io_uring_queue_exit()
|
|
206
|
+
* should successfully return and not hang.
|
|
207
|
+
*/
|
|
208
|
+
close(fd);
|
|
209
|
+
io_uring_queue_exit(&ring);
|
|
210
|
+
return 0;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
int main(int argc, char *argv[])
|
|
214
|
+
{
|
|
215
|
+
const char *fn = "io_uring_openat_test";
|
|
216
|
+
struct io_uring ring;
|
|
217
|
+
int ret, dfd;
|
|
218
|
+
|
|
219
|
+
if (argc > 1)
|
|
220
|
+
return 0;
|
|
221
|
+
|
|
222
|
+
dfd = open("/tmp", O_PATH);
|
|
223
|
+
if (dfd < 0)
|
|
224
|
+
DIE("open /tmp: %s\n", strerror(errno));
|
|
225
|
+
|
|
226
|
+
ret = io_uring_queue_init(RSIZE, &ring, 0);
|
|
227
|
+
if (ret < 0)
|
|
228
|
+
DIE("failed to init io_uring: %s\n", strerror(-ret));
|
|
229
|
+
|
|
230
|
+
if (prepare_file(dfd, fn))
|
|
231
|
+
return 1;
|
|
232
|
+
|
|
233
|
+
ret = open_io_uring(&ring, dfd, fn);
|
|
234
|
+
if (ret) {
|
|
235
|
+
fprintf(stderr, "open_io_uring() failed\n");
|
|
236
|
+
goto out;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
ret = test_linked_files(dfd, fn, false);
|
|
240
|
+
if (ret) {
|
|
241
|
+
fprintf(stderr, "test_linked_files() !async failed\n");
|
|
242
|
+
goto out;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
ret = test_linked_files(dfd, fn, true);
|
|
246
|
+
if (ret) {
|
|
247
|
+
fprintf(stderr, "test_linked_files() async failed\n");
|
|
248
|
+
goto out;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
ret = test_drained_files(dfd, fn, false, false);
|
|
252
|
+
if (ret) {
|
|
253
|
+
fprintf(stderr, "test_drained_files() failed\n");
|
|
254
|
+
goto out;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
ret = test_drained_files(dfd, fn, false, true);
|
|
258
|
+
if (ret) {
|
|
259
|
+
fprintf(stderr, "test_drained_files() middle failed\n");
|
|
260
|
+
goto out;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
ret = test_drained_files(dfd, fn, true, false);
|
|
264
|
+
if (ret) {
|
|
265
|
+
fprintf(stderr, "test_drained_files() linked failed\n");
|
|
266
|
+
goto out;
|
|
267
|
+
}
|
|
268
|
+
out:
|
|
269
|
+
io_uring_queue_exit(&ring);
|
|
270
|
+
close(dfd);
|
|
271
|
+
unlink("/tmp/io_uring_openat_test");
|
|
272
|
+
return ret;
|
|
273
|
+
}
|