@nxtedition/rocksdb 6.0.2 → 6.0.3
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/BUILDING.md +12 -4
- package/binding.cc +2 -0
- package/deps/rocksdb/rocksdb/CMakeLists.txt +9 -0
- package/deps/rocksdb/rocksdb/Makefile +16 -5
- package/deps/rocksdb/rocksdb/TARGETS +23 -2
- package/deps/rocksdb/rocksdb/cmake/modules/CxxFlags.cmake +7 -0
- package/deps/rocksdb/rocksdb/cmake/modules/FindJeMalloc.cmake +29 -0
- package/deps/rocksdb/rocksdb/cmake/modules/FindNUMA.cmake +29 -0
- package/deps/rocksdb/rocksdb/cmake/modules/FindSnappy.cmake +29 -0
- package/deps/rocksdb/rocksdb/cmake/modules/FindTBB.cmake +33 -0
- package/deps/rocksdb/rocksdb/cmake/modules/Findgflags.cmake +29 -0
- package/deps/rocksdb/rocksdb/cmake/modules/Findlz4.cmake +29 -0
- package/deps/rocksdb/rocksdb/cmake/modules/Finduring.cmake +26 -0
- package/deps/rocksdb/rocksdb/cmake/modules/Findzstd.cmake +29 -0
- package/deps/rocksdb/rocksdb/cmake/modules/ReadVersion.cmake +10 -0
- package/deps/rocksdb/rocksdb/db/builder.cc +12 -4
- package/deps/rocksdb/rocksdb/db/c.cc +26 -0
- package/deps/rocksdb/rocksdb/db/c_test.c +3 -0
- package/deps/rocksdb/rocksdb/db/column_family.cc +8 -2
- package/deps/rocksdb/rocksdb/db/compaction/compaction_job.cc +29 -6
- package/deps/rocksdb/rocksdb/db/compaction/compaction_job.h +8 -2
- package/deps/rocksdb/rocksdb/db/compaction/compaction_job_test.cc +16 -4
- package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_test.cc +2 -1
- package/deps/rocksdb/rocksdb/db/compaction/compaction_service_test.cc +16 -0
- package/deps/rocksdb/rocksdb/db/db_basic_test.cc +402 -30
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl.cc +2 -12
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl.h +14 -0
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_compaction_flush.cc +7 -5
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_experimental.cc +1 -1
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_open.cc +33 -7
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_readonly.cc +54 -23
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_readonly.h +3 -0
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_secondary.cc +8 -1
- package/deps/rocksdb/rocksdb/db/db_options_test.cc +16 -0
- package/deps/rocksdb/rocksdb/db/db_rate_limiter_test.cc +14 -15
- package/deps/rocksdb/rocksdb/db/db_readonly_with_timestamp_test.cc +331 -0
- package/deps/rocksdb/rocksdb/db/db_secondary_test.cc +5 -0
- package/deps/rocksdb/rocksdb/db/db_test.cc +16 -0
- package/deps/rocksdb/rocksdb/db/db_test2.cc +221 -92
- package/deps/rocksdb/rocksdb/db/db_test_util.cc +6 -2
- package/deps/rocksdb/rocksdb/db/db_test_util.h +4 -2
- package/deps/rocksdb/rocksdb/db/db_with_timestamp_basic_test.cc +1 -171
- package/deps/rocksdb/rocksdb/db/db_with_timestamp_test_util.cc +96 -0
- package/deps/rocksdb/rocksdb/db/db_with_timestamp_test_util.h +126 -0
- package/deps/rocksdb/rocksdb/db/experimental.cc +1 -1
- package/deps/rocksdb/rocksdb/db/external_sst_file_basic_test.cc +57 -0
- package/deps/rocksdb/rocksdb/db/external_sst_file_ingestion_job.cc +13 -2
- package/deps/rocksdb/rocksdb/db/external_sst_file_ingestion_job.h +2 -0
- package/deps/rocksdb/rocksdb/db/flush_job.cc +10 -11
- package/deps/rocksdb/rocksdb/db/import_column_family_job.cc +11 -1
- package/deps/rocksdb/rocksdb/db/import_column_family_test.cc +6 -0
- package/deps/rocksdb/rocksdb/db/repair.cc +12 -1
- package/deps/rocksdb/rocksdb/db/repair_test.cc +32 -10
- package/deps/rocksdb/rocksdb/db/snapshot_impl.h +3 -1
- package/deps/rocksdb/rocksdb/db/table_cache.cc +19 -127
- package/deps/rocksdb/rocksdb/db/table_cache.h +3 -2
- package/deps/rocksdb/rocksdb/db/table_cache_sync_and_async.h +140 -0
- package/deps/rocksdb/rocksdb/db/version_builder_test.cc +130 -128
- package/deps/rocksdb/rocksdb/db/version_edit.cc +20 -0
- package/deps/rocksdb/rocksdb/db/version_edit.h +13 -4
- package/deps/rocksdb/rocksdb/db/version_edit_test.cc +14 -14
- package/deps/rocksdb/rocksdb/db/version_set.cc +205 -212
- package/deps/rocksdb/rocksdb/db/version_set.h +11 -0
- package/deps/rocksdb/rocksdb/db/version_set_sync_and_async.h +154 -0
- package/deps/rocksdb/rocksdb/db/version_set_test.cc +10 -9
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_common.h +2 -0
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_gflags.cc +13 -0
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_test_base.cc +15 -0
- package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.cc +159 -65
- package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.h +43 -21
- package/deps/rocksdb/rocksdb/file/prefetch_test.cc +142 -17
- package/deps/rocksdb/rocksdb/file/writable_file_writer.cc +23 -27
- package/deps/rocksdb/rocksdb/file/writable_file_writer.h +2 -3
- package/deps/rocksdb/rocksdb/include/rocksdb/advanced_options.h +23 -5
- package/deps/rocksdb/rocksdb/include/rocksdb/c.h +14 -1
- package/deps/rocksdb/rocksdb/include/rocksdb/file_system.h +2 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/options.h +17 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/perf_context.h +2 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/snapshot.h +4 -1
- package/deps/rocksdb/rocksdb/include/rocksdb/statistics.h +3 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/utilities/options_type.h +189 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/version.h +1 -1
- package/deps/rocksdb/rocksdb/monitoring/perf_context.cc +5 -0
- package/deps/rocksdb/rocksdb/monitoring/statistics.cc +1 -1
- package/deps/rocksdb/rocksdb/options/cf_options.cc +13 -0
- package/deps/rocksdb/rocksdb/options/db_options.cc +8 -0
- package/deps/rocksdb/rocksdb/options/db_options.h +1 -0
- package/deps/rocksdb/rocksdb/options/options.cc +7 -0
- package/deps/rocksdb/rocksdb/options/options_helper.cc +4 -0
- package/deps/rocksdb/rocksdb/options/options_settable_test.cc +6 -4
- package/deps/rocksdb/rocksdb/options/options_test.cc +107 -9
- package/deps/rocksdb/rocksdb/src.mk +4 -1
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_builder.cc +9 -4
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_iterator.cc +80 -6
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_iterator.h +8 -2
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.cc +81 -757
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.h +21 -15
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_impl.h +9 -3
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_sync_and_async.h +754 -0
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_test.cc +2 -1
- package/deps/rocksdb/rocksdb/table/block_based/block_prefetcher.cc +8 -0
- package/deps/rocksdb/rocksdb/table/block_based/filter_block.h +1 -10
- package/deps/rocksdb/rocksdb/table/block_based/filter_block_reader_common.cc +59 -1
- package/deps/rocksdb/rocksdb/table/block_based/filter_block_reader_common.h +18 -0
- package/deps/rocksdb/rocksdb/table/block_based/full_filter_block.cc +0 -61
- package/deps/rocksdb/rocksdb/table/block_based/full_filter_block.h +0 -13
- package/deps/rocksdb/rocksdb/table/block_based/index_reader_common.cc +1 -1
- package/deps/rocksdb/rocksdb/table/block_based/partitioned_filter_block.cc +3 -2
- package/deps/rocksdb/rocksdb/table/block_based/partitioned_index_iterator.cc +2 -2
- package/deps/rocksdb/rocksdb/table/block_based/partitioned_index_reader.cc +2 -1
- package/deps/rocksdb/rocksdb/table/block_based/uncompression_dict_reader.cc +2 -1
- package/deps/rocksdb/rocksdb/table/block_fetcher.cc +60 -2
- package/deps/rocksdb/rocksdb/table/block_fetcher.h +2 -0
- package/deps/rocksdb/rocksdb/table/merging_iterator.cc +39 -0
- package/deps/rocksdb/rocksdb/table/multiget_context.h +46 -2
- package/deps/rocksdb/rocksdb/table/sst_file_dumper.cc +2 -1
- package/deps/rocksdb/rocksdb/table/sst_file_dumper.h +1 -1
- package/deps/rocksdb/rocksdb/table/table_reader.h +13 -0
- package/deps/rocksdb/rocksdb/table/unique_id.cc +27 -0
- package/deps/rocksdb/rocksdb/table/unique_id_impl.h +3 -0
- package/deps/rocksdb/rocksdb/test_util/testutil.cc +2 -0
- package/deps/rocksdb/rocksdb/tools/db_bench_tool.cc +23 -7
- package/deps/rocksdb/rocksdb/tools/sst_dump_tool.cc +9 -1
- package/deps/rocksdb/rocksdb/util/async_file_reader.cc +72 -0
- package/deps/rocksdb/rocksdb/util/async_file_reader.h +144 -0
- package/deps/rocksdb/rocksdb/util/compression.h +49 -0
- package/deps/rocksdb/rocksdb/util/coro_utils.h +111 -0
- package/deps/rocksdb/rocksdb/util/single_thread_executor.h +55 -0
- package/deps/rocksdb/rocksdb.gyp +16 -15
- package/package-lock.json +23687 -0
- package/package.json +2 -30
- 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/liburing/liburing/README +0 -46
- package/deps/liburing/liburing/test/232c93d07b74-test.c +0 -305
- package/deps/liburing/liburing/test/35fa71a030ca-test.c +0 -329
- package/deps/liburing/liburing/test/500f9fbadef8-test.c +0 -89
- package/deps/liburing/liburing/test/7ad0e4b2f83c-test.c +0 -93
- package/deps/liburing/liburing/test/8a9973408177-test.c +0 -106
- package/deps/liburing/liburing/test/917257daa0fe-test.c +0 -53
- package/deps/liburing/liburing/test/Makefile +0 -312
- package/deps/liburing/liburing/test/a0908ae19763-test.c +0 -58
- package/deps/liburing/liburing/test/a4c0b3decb33-test.c +0 -180
- package/deps/liburing/liburing/test/accept-link.c +0 -251
- package/deps/liburing/liburing/test/accept-reuse.c +0 -164
- package/deps/liburing/liburing/test/accept-test.c +0 -79
- package/deps/liburing/liburing/test/accept.c +0 -476
- package/deps/liburing/liburing/test/across-fork.c +0 -283
- package/deps/liburing/liburing/test/b19062a56726-test.c +0 -53
- package/deps/liburing/liburing/test/b5837bd5311d-test.c +0 -77
- package/deps/liburing/liburing/test/ce593a6c480a-test.c +0 -135
- package/deps/liburing/liburing/test/close-opath.c +0 -122
- package/deps/liburing/liburing/test/config +0 -10
- package/deps/liburing/liburing/test/connect.c +0 -398
- package/deps/liburing/liburing/test/cq-full.c +0 -96
- package/deps/liburing/liburing/test/cq-overflow.c +0 -294
- package/deps/liburing/liburing/test/cq-peek-batch.c +0 -102
- package/deps/liburing/liburing/test/cq-ready.c +0 -94
- package/deps/liburing/liburing/test/cq-size.c +0 -58
- package/deps/liburing/liburing/test/d4ae271dfaae-test.c +0 -96
- package/deps/liburing/liburing/test/d77a67ed5f27-test.c +0 -65
- package/deps/liburing/liburing/test/defer.c +0 -307
- package/deps/liburing/liburing/test/double-poll-crash.c +0 -186
- package/deps/liburing/liburing/test/eeed8b54e0df-test.c +0 -114
- package/deps/liburing/liburing/test/empty-eownerdead.c +0 -42
- package/deps/liburing/liburing/test/eventfd-disable.c +0 -151
- package/deps/liburing/liburing/test/eventfd-ring.c +0 -97
- package/deps/liburing/liburing/test/eventfd.c +0 -112
- package/deps/liburing/liburing/test/fadvise.c +0 -202
- package/deps/liburing/liburing/test/fallocate.c +0 -249
- package/deps/liburing/liburing/test/fc2a85cb02ef-test.c +0 -138
- package/deps/liburing/liburing/test/file-register.c +0 -843
- package/deps/liburing/liburing/test/file-update.c +0 -173
- package/deps/liburing/liburing/test/files-exit-hang-poll.c +0 -128
- package/deps/liburing/liburing/test/files-exit-hang-timeout.c +0 -134
- package/deps/liburing/liburing/test/fixed-link.c +0 -90
- package/deps/liburing/liburing/test/fsync.c +0 -224
- package/deps/liburing/liburing/test/hardlink.c +0 -136
- package/deps/liburing/liburing/test/helpers.c +0 -135
- package/deps/liburing/liburing/test/helpers.h +0 -67
- package/deps/liburing/liburing/test/io-cancel.c +0 -537
- package/deps/liburing/liburing/test/io_uring_enter.c +0 -296
- package/deps/liburing/liburing/test/io_uring_register.c +0 -664
- package/deps/liburing/liburing/test/io_uring_setup.c +0 -192
- package/deps/liburing/liburing/test/iopoll.c +0 -366
- package/deps/liburing/liburing/test/lfs-openat-write.c +0 -117
- package/deps/liburing/liburing/test/lfs-openat.c +0 -273
- package/deps/liburing/liburing/test/link-timeout.c +0 -1107
- package/deps/liburing/liburing/test/link.c +0 -496
- package/deps/liburing/liburing/test/link_drain.c +0 -229
- package/deps/liburing/liburing/test/madvise.c +0 -195
- package/deps/liburing/liburing/test/mkdir.c +0 -108
- package/deps/liburing/liburing/test/multicqes_drain.c +0 -383
- package/deps/liburing/liburing/test/nop-all-sizes.c +0 -107
- package/deps/liburing/liburing/test/nop.c +0 -115
- package/deps/liburing/liburing/test/open-close.c +0 -146
- package/deps/liburing/liburing/test/openat2.c +0 -240
- package/deps/liburing/liburing/test/personality.c +0 -204
- package/deps/liburing/liburing/test/pipe-eof.c +0 -81
- package/deps/liburing/liburing/test/pipe-reuse.c +0 -105
- package/deps/liburing/liburing/test/poll-cancel-ton.c +0 -139
- package/deps/liburing/liburing/test/poll-cancel.c +0 -135
- package/deps/liburing/liburing/test/poll-link.c +0 -227
- package/deps/liburing/liburing/test/poll-many.c +0 -208
- package/deps/liburing/liburing/test/poll-mshot-update.c +0 -273
- package/deps/liburing/liburing/test/poll-ring.c +0 -48
- package/deps/liburing/liburing/test/poll-v-poll.c +0 -353
- package/deps/liburing/liburing/test/poll.c +0 -109
- package/deps/liburing/liburing/test/probe.c +0 -137
- package/deps/liburing/liburing/test/read-write.c +0 -876
- package/deps/liburing/liburing/test/register-restrictions.c +0 -633
- package/deps/liburing/liburing/test/rename.c +0 -134
- package/deps/liburing/liburing/test/ring-leak.c +0 -173
- package/deps/liburing/liburing/test/ring-leak2.c +0 -249
- package/deps/liburing/liburing/test/rsrc_tags.c +0 -449
- package/deps/liburing/liburing/test/runtests-loop.sh +0 -16
- package/deps/liburing/liburing/test/runtests.sh +0 -170
- package/deps/liburing/liburing/test/rw_merge_test.c +0 -97
- package/deps/liburing/liburing/test/self.c +0 -91
- package/deps/liburing/liburing/test/send_recv.c +0 -291
- package/deps/liburing/liburing/test/send_recvmsg.c +0 -345
- package/deps/liburing/liburing/test/sendmsg_fs_cve.c +0 -198
- package/deps/liburing/liburing/test/shared-wq.c +0 -84
- package/deps/liburing/liburing/test/short-read.c +0 -75
- package/deps/liburing/liburing/test/shutdown.c +0 -163
- package/deps/liburing/liburing/test/sigfd-deadlock.c +0 -74
- package/deps/liburing/liburing/test/socket-rw-eagain.c +0 -156
- package/deps/liburing/liburing/test/socket-rw.c +0 -147
- package/deps/liburing/liburing/test/splice.c +0 -511
- package/deps/liburing/liburing/test/sq-full-cpp.cc +0 -45
- package/deps/liburing/liburing/test/sq-full.c +0 -45
- package/deps/liburing/liburing/test/sq-poll-dup.c +0 -200
- package/deps/liburing/liburing/test/sq-poll-kthread.c +0 -168
- package/deps/liburing/liburing/test/sq-poll-share.c +0 -137
- package/deps/liburing/liburing/test/sq-space_left.c +0 -159
- package/deps/liburing/liburing/test/sqpoll-cancel-hang.c +0 -159
- package/deps/liburing/liburing/test/sqpoll-disable-exit.c +0 -195
- package/deps/liburing/liburing/test/sqpoll-exit-hang.c +0 -77
- package/deps/liburing/liburing/test/sqpoll-sleep.c +0 -68
- package/deps/liburing/liburing/test/statx.c +0 -172
- package/deps/liburing/liburing/test/stdout.c +0 -232
- package/deps/liburing/liburing/test/submit-link-fail.c +0 -154
- package/deps/liburing/liburing/test/submit-reuse.c +0 -239
- package/deps/liburing/liburing/test/symlink.c +0 -116
- package/deps/liburing/liburing/test/teardowns.c +0 -58
- package/deps/liburing/liburing/test/thread-exit.c +0 -131
- package/deps/liburing/liburing/test/timeout-new.c +0 -246
- package/deps/liburing/liburing/test/timeout-overflow.c +0 -204
- package/deps/liburing/liburing/test/timeout.c +0 -1354
- package/deps/liburing/liburing/test/unlink.c +0 -111
- package/deps/liburing/liburing/test/wakeup-hang.c +0 -162
- package/deps/rocksdb/rocksdb/README.md +0 -32
- package/deps/rocksdb/rocksdb/microbench/README.md +0 -60
- package/deps/rocksdb/rocksdb/plugin/README.md +0 -43
- package/deps/rocksdb/rocksdb/port/README +0 -10
- package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/README +0 -13
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
/* SPDX-License-Identifier: MIT */
|
|
2
|
-
/*
|
|
3
|
-
* Description: run various nop tests
|
|
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_rename(struct io_uring *ring, const char *old, const char *new)
|
|
16
|
-
{
|
|
17
|
-
struct io_uring_cqe *cqe;
|
|
18
|
-
struct io_uring_sqe *sqe;
|
|
19
|
-
int ret;
|
|
20
|
-
|
|
21
|
-
sqe = io_uring_get_sqe(ring);
|
|
22
|
-
if (!sqe) {
|
|
23
|
-
fprintf(stderr, "get sqe failed\n");
|
|
24
|
-
goto err;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
memset(sqe, 0, sizeof(*sqe));
|
|
28
|
-
sqe->opcode = IORING_OP_RENAMEAT;
|
|
29
|
-
sqe->fd = AT_FDCWD;
|
|
30
|
-
sqe->addr2 = (unsigned long) new;
|
|
31
|
-
sqe->addr = (unsigned long) old;
|
|
32
|
-
sqe->len = AT_FDCWD;
|
|
33
|
-
|
|
34
|
-
ret = io_uring_submit(ring);
|
|
35
|
-
if (ret <= 0) {
|
|
36
|
-
fprintf(stderr, "sqe submit failed: %d\n", ret);
|
|
37
|
-
goto err;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
ret = io_uring_wait_cqe(ring, &cqe);
|
|
41
|
-
if (ret < 0) {
|
|
42
|
-
fprintf(stderr, "wait completion %d\n", ret);
|
|
43
|
-
goto err;
|
|
44
|
-
}
|
|
45
|
-
ret = cqe->res;
|
|
46
|
-
io_uring_cqe_seen(ring, cqe);
|
|
47
|
-
return ret;
|
|
48
|
-
err:
|
|
49
|
-
return 1;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
static int stat_file(const char *buf)
|
|
53
|
-
{
|
|
54
|
-
struct stat sb;
|
|
55
|
-
|
|
56
|
-
if (!stat(buf, &sb))
|
|
57
|
-
return 0;
|
|
58
|
-
|
|
59
|
-
return errno;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
int main(int argc, char *argv[])
|
|
63
|
-
{
|
|
64
|
-
struct io_uring ring;
|
|
65
|
-
char src[32] = "./XXXXXX";
|
|
66
|
-
char dst[32] = "./XXXXXX";
|
|
67
|
-
int ret;
|
|
68
|
-
|
|
69
|
-
if (argc > 1)
|
|
70
|
-
return 0;
|
|
71
|
-
|
|
72
|
-
ret = io_uring_queue_init(1, &ring, 0);
|
|
73
|
-
if (ret) {
|
|
74
|
-
fprintf(stderr, "ring setup failed: %d\n", ret);
|
|
75
|
-
return 1;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
ret = mkstemp(src);
|
|
79
|
-
if (ret < 0) {
|
|
80
|
-
perror("mkstemp");
|
|
81
|
-
return 1;
|
|
82
|
-
}
|
|
83
|
-
close(ret);
|
|
84
|
-
|
|
85
|
-
ret = mkstemp(dst);
|
|
86
|
-
if (ret < 0) {
|
|
87
|
-
perror("mkstemp");
|
|
88
|
-
return 1;
|
|
89
|
-
}
|
|
90
|
-
close(ret);
|
|
91
|
-
|
|
92
|
-
if (stat_file(src) != 0) {
|
|
93
|
-
perror("stat");
|
|
94
|
-
return 1;
|
|
95
|
-
}
|
|
96
|
-
if (stat_file(dst) != 0) {
|
|
97
|
-
perror("stat");
|
|
98
|
-
return 1;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
ret = test_rename(&ring, src, dst);
|
|
102
|
-
if (ret < 0) {
|
|
103
|
-
if (ret == -EBADF || ret == -EINVAL) {
|
|
104
|
-
fprintf(stdout, "Rename not supported, skipping\n");
|
|
105
|
-
goto out;
|
|
106
|
-
}
|
|
107
|
-
fprintf(stderr, "rename: %s\n", strerror(-ret));
|
|
108
|
-
goto err;
|
|
109
|
-
} else if (ret)
|
|
110
|
-
goto err;
|
|
111
|
-
|
|
112
|
-
if (stat_file(src) != ENOENT) {
|
|
113
|
-
fprintf(stderr, "stat got %s\n", strerror(ret));
|
|
114
|
-
return 1;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (stat_file(dst) != 0) {
|
|
118
|
-
perror("stat");
|
|
119
|
-
return 1;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
ret = test_rename(&ring, "/x/y/1/2", "/2/1/y/x");
|
|
123
|
-
if (ret != -ENOENT) {
|
|
124
|
-
fprintf(stderr, "test_rename invalid failed: %d\n", ret);
|
|
125
|
-
return ret;
|
|
126
|
-
}
|
|
127
|
-
out:
|
|
128
|
-
unlink(dst);
|
|
129
|
-
return 0;
|
|
130
|
-
err:
|
|
131
|
-
unlink(src);
|
|
132
|
-
unlink(dst);
|
|
133
|
-
return 1;
|
|
134
|
-
}
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
/* SPDX-License-Identifier: MIT */
|
|
2
|
-
/*
|
|
3
|
-
* Based on description from Al Viro - this demonstrates a leak of the
|
|
4
|
-
* io_uring instance, by sending the io_uring fd over a UNIX socket.
|
|
5
|
-
*
|
|
6
|
-
* See:
|
|
7
|
-
*
|
|
8
|
-
* https://lore.kernel.org/linux-block/20190129192702.3605-1-axboe@kernel.dk/T/#m6c87fc64e4d063786af6ec6fadce3ac1e95d3184
|
|
9
|
-
*
|
|
10
|
-
*/
|
|
11
|
-
#include <stdio.h>
|
|
12
|
-
#include <stdlib.h>
|
|
13
|
-
#include <stddef.h>
|
|
14
|
-
#include <signal.h>
|
|
15
|
-
#include <inttypes.h>
|
|
16
|
-
#include <sys/types.h>
|
|
17
|
-
#include <sys/syscall.h>
|
|
18
|
-
#include <sys/socket.h>
|
|
19
|
-
#include <sys/wait.h>
|
|
20
|
-
#include <fcntl.h>
|
|
21
|
-
#include <unistd.h>
|
|
22
|
-
#include <string.h>
|
|
23
|
-
#include <linux/fs.h>
|
|
24
|
-
|
|
25
|
-
#include "liburing.h"
|
|
26
|
-
#include "../src/syscall.h"
|
|
27
|
-
|
|
28
|
-
static int __io_uring_register_files(int ring_fd, int fd1, int fd2)
|
|
29
|
-
{
|
|
30
|
-
__s32 fds[2] = { fd1, fd2 };
|
|
31
|
-
|
|
32
|
-
return __sys_io_uring_register(ring_fd, IORING_REGISTER_FILES, fds, 2);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
static int get_ring_fd(void)
|
|
36
|
-
{
|
|
37
|
-
struct io_uring_params p;
|
|
38
|
-
int fd;
|
|
39
|
-
|
|
40
|
-
memset(&p, 0, sizeof(p));
|
|
41
|
-
|
|
42
|
-
fd = __sys_io_uring_setup(2, &p);
|
|
43
|
-
if (fd < 0) {
|
|
44
|
-
perror("io_uring_setup");
|
|
45
|
-
return -1;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return fd;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
static void send_fd(int socket, int fd)
|
|
52
|
-
{
|
|
53
|
-
char buf[CMSG_SPACE(sizeof(fd))];
|
|
54
|
-
struct cmsghdr *cmsg;
|
|
55
|
-
struct msghdr msg;
|
|
56
|
-
|
|
57
|
-
memset(buf, 0, sizeof(buf));
|
|
58
|
-
memset(&msg, 0, sizeof(msg));
|
|
59
|
-
|
|
60
|
-
msg.msg_control = buf;
|
|
61
|
-
msg.msg_controllen = sizeof(buf);
|
|
62
|
-
|
|
63
|
-
cmsg = CMSG_FIRSTHDR(&msg);
|
|
64
|
-
cmsg->cmsg_level = SOL_SOCKET;
|
|
65
|
-
cmsg->cmsg_type = SCM_RIGHTS;
|
|
66
|
-
cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
|
|
67
|
-
|
|
68
|
-
memmove(CMSG_DATA(cmsg), &fd, sizeof(fd));
|
|
69
|
-
|
|
70
|
-
msg.msg_controllen = CMSG_SPACE(sizeof(fd));
|
|
71
|
-
|
|
72
|
-
if (sendmsg(socket, &msg, 0) < 0)
|
|
73
|
-
perror("sendmsg");
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
static int test_iowq_request_cancel(void)
|
|
77
|
-
{
|
|
78
|
-
char buffer[128];
|
|
79
|
-
struct io_uring ring;
|
|
80
|
-
struct io_uring_sqe *sqe;
|
|
81
|
-
int ret, fds[2];
|
|
82
|
-
|
|
83
|
-
ret = io_uring_queue_init(8, &ring, 0);
|
|
84
|
-
if (ret < 0) {
|
|
85
|
-
fprintf(stderr, "failed to init io_uring: %s\n", strerror(-ret));
|
|
86
|
-
return ret;
|
|
87
|
-
}
|
|
88
|
-
if (pipe(fds)) {
|
|
89
|
-
perror("pipe");
|
|
90
|
-
return -1;
|
|
91
|
-
}
|
|
92
|
-
ret = io_uring_register_files(&ring, fds, 2);
|
|
93
|
-
if (ret) {
|
|
94
|
-
fprintf(stderr, "file_register: %d\n", ret);
|
|
95
|
-
return ret;
|
|
96
|
-
}
|
|
97
|
-
close(fds[1]);
|
|
98
|
-
|
|
99
|
-
sqe = io_uring_get_sqe(&ring);
|
|
100
|
-
if (!sqe) {
|
|
101
|
-
fprintf(stderr, "%s: failed to get sqe\n", __FUNCTION__);
|
|
102
|
-
return 1;
|
|
103
|
-
}
|
|
104
|
-
/* potentially sitting in internal polling */
|
|
105
|
-
io_uring_prep_read(sqe, 0, buffer, 10, 0);
|
|
106
|
-
sqe->flags |= IOSQE_FIXED_FILE;
|
|
107
|
-
|
|
108
|
-
sqe = io_uring_get_sqe(&ring);
|
|
109
|
-
if (!sqe) {
|
|
110
|
-
fprintf(stderr, "%s: failed to get sqe\n", __FUNCTION__);
|
|
111
|
-
return 1;
|
|
112
|
-
}
|
|
113
|
-
/* staying in io-wq */
|
|
114
|
-
io_uring_prep_read(sqe, 0, buffer, 10, 0);
|
|
115
|
-
sqe->flags |= IOSQE_FIXED_FILE | IOSQE_ASYNC;
|
|
116
|
-
|
|
117
|
-
ret = io_uring_submit(&ring);
|
|
118
|
-
if (ret != 2) {
|
|
119
|
-
fprintf(stderr, "%s: got %d, wanted 1\n", __FUNCTION__, ret);
|
|
120
|
-
return 1;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/* should unregister files and close the write fd */
|
|
124
|
-
io_uring_queue_exit(&ring);
|
|
125
|
-
|
|
126
|
-
/*
|
|
127
|
-
* We're trying to wait for the ring to "really" exit, that will be
|
|
128
|
-
* done async. For that rely on the registered write end to be closed
|
|
129
|
-
* after ring quiesce, so failing read from the other pipe end.
|
|
130
|
-
*/
|
|
131
|
-
ret = read(fds[0], buffer, 10);
|
|
132
|
-
if (ret < 0)
|
|
133
|
-
perror("read");
|
|
134
|
-
return 0;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
int main(int argc, char *argv[])
|
|
138
|
-
{
|
|
139
|
-
int sp[2], pid, ring_fd, ret;
|
|
140
|
-
|
|
141
|
-
if (argc > 1)
|
|
142
|
-
return 0;
|
|
143
|
-
|
|
144
|
-
ret = test_iowq_request_cancel();
|
|
145
|
-
if (ret) {
|
|
146
|
-
fprintf(stderr, "test_iowq_request_cancel() failed\n");
|
|
147
|
-
return 1;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (socketpair(AF_UNIX, SOCK_DGRAM, 0, sp) != 0) {
|
|
151
|
-
perror("Failed to create Unix-domain socket pair\n");
|
|
152
|
-
return 1;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
ring_fd = get_ring_fd();
|
|
156
|
-
if (ring_fd < 0)
|
|
157
|
-
return 1;
|
|
158
|
-
|
|
159
|
-
ret = __io_uring_register_files(ring_fd, sp[0], sp[1]);
|
|
160
|
-
if (ret < 0) {
|
|
161
|
-
perror("register files");
|
|
162
|
-
return 1;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
pid = fork();
|
|
166
|
-
if (pid)
|
|
167
|
-
send_fd(sp[0], ring_fd);
|
|
168
|
-
|
|
169
|
-
close(ring_fd);
|
|
170
|
-
close(sp[0]);
|
|
171
|
-
close(sp[1]);
|
|
172
|
-
return 0;
|
|
173
|
-
}
|
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
/* SPDX-License-Identifier: MIT */
|
|
2
|
-
/*
|
|
3
|
-
* Description: Test two ring deadlock. A buggy kernel will end up
|
|
4
|
-
* having io_wq_* workers pending, as the circular reference
|
|
5
|
-
* will prevent full exit.
|
|
6
|
-
*
|
|
7
|
-
* Based on a test case from Josef <josef.grieb@gmail.com>
|
|
8
|
-
*
|
|
9
|
-
*/
|
|
10
|
-
#include <errno.h>
|
|
11
|
-
#include <fcntl.h>
|
|
12
|
-
#include <netinet/in.h>
|
|
13
|
-
#include <stdio.h>
|
|
14
|
-
#include <stdlib.h>
|
|
15
|
-
#include <string.h>
|
|
16
|
-
#include <strings.h>
|
|
17
|
-
#include <sys/poll.h>
|
|
18
|
-
#include <sys/socket.h>
|
|
19
|
-
#include <unistd.h>
|
|
20
|
-
#include <sys/eventfd.h>
|
|
21
|
-
#include <pthread.h>
|
|
22
|
-
|
|
23
|
-
#include "liburing.h"
|
|
24
|
-
#include "../src/syscall.h"
|
|
25
|
-
|
|
26
|
-
enum {
|
|
27
|
-
ACCEPT,
|
|
28
|
-
READ,
|
|
29
|
-
WRITE,
|
|
30
|
-
POLLING_IN,
|
|
31
|
-
POLLING_RDHUP,
|
|
32
|
-
CLOSE,
|
|
33
|
-
EVENTFD_READ,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
typedef struct conn_info {
|
|
37
|
-
__u32 fd;
|
|
38
|
-
__u16 type;
|
|
39
|
-
__u16 bid;
|
|
40
|
-
} conn_info;
|
|
41
|
-
|
|
42
|
-
static char read_eventfd_buffer[8];
|
|
43
|
-
|
|
44
|
-
static pthread_mutex_t lock;
|
|
45
|
-
static struct io_uring *client_ring;
|
|
46
|
-
|
|
47
|
-
static int client_eventfd = -1;
|
|
48
|
-
|
|
49
|
-
int setup_io_uring(struct io_uring *ring)
|
|
50
|
-
{
|
|
51
|
-
struct io_uring_params p = { };
|
|
52
|
-
int ret;
|
|
53
|
-
|
|
54
|
-
ret = io_uring_queue_init_params(8, ring, &p);
|
|
55
|
-
if (ret) {
|
|
56
|
-
fprintf(stderr, "Unable to setup io_uring: %s\n",
|
|
57
|
-
strerror(-ret));
|
|
58
|
-
return 1;
|
|
59
|
-
}
|
|
60
|
-
return 0;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
static void add_socket_eventfd_read(struct io_uring *ring, int fd)
|
|
64
|
-
{
|
|
65
|
-
struct io_uring_sqe *sqe;
|
|
66
|
-
conn_info conn_i = {
|
|
67
|
-
.fd = fd,
|
|
68
|
-
.type = EVENTFD_READ,
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
sqe = io_uring_get_sqe(ring);
|
|
72
|
-
io_uring_prep_read(sqe, fd, &read_eventfd_buffer, 8, 0);
|
|
73
|
-
io_uring_sqe_set_flags(sqe, IOSQE_ASYNC);
|
|
74
|
-
|
|
75
|
-
memcpy(&sqe->user_data, &conn_i, sizeof(conn_i));
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
static void add_socket_pollin(struct io_uring *ring, int fd)
|
|
79
|
-
{
|
|
80
|
-
struct io_uring_sqe *sqe;
|
|
81
|
-
conn_info conn_i = {
|
|
82
|
-
.fd = fd,
|
|
83
|
-
.type = POLLING_IN,
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
sqe = io_uring_get_sqe(ring);
|
|
87
|
-
io_uring_prep_poll_add(sqe, fd, POLL_IN);
|
|
88
|
-
|
|
89
|
-
memcpy(&sqe->user_data, &conn_i, sizeof(conn_i));
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
static void *server_thread(void *arg)
|
|
93
|
-
{
|
|
94
|
-
struct sockaddr_in serv_addr;
|
|
95
|
-
int port = 0;
|
|
96
|
-
int sock_listen_fd, evfd;
|
|
97
|
-
const int val = 1;
|
|
98
|
-
struct io_uring ring;
|
|
99
|
-
|
|
100
|
-
sock_listen_fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0);
|
|
101
|
-
setsockopt(sock_listen_fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
|
|
102
|
-
|
|
103
|
-
memset(&serv_addr, 0, sizeof(serv_addr));
|
|
104
|
-
serv_addr.sin_family = AF_INET;
|
|
105
|
-
serv_addr.sin_port = htons(port);
|
|
106
|
-
serv_addr.sin_addr.s_addr = INADDR_ANY;
|
|
107
|
-
|
|
108
|
-
evfd = eventfd(0, EFD_CLOEXEC);
|
|
109
|
-
|
|
110
|
-
// bind and listen
|
|
111
|
-
if (bind(sock_listen_fd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {
|
|
112
|
-
perror("Error binding socket...\n");
|
|
113
|
-
exit(1);
|
|
114
|
-
}
|
|
115
|
-
if (listen(sock_listen_fd, 1) < 0) {
|
|
116
|
-
perror("Error listening on socket...\n");
|
|
117
|
-
exit(1);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
setup_io_uring(&ring);
|
|
121
|
-
add_socket_eventfd_read(&ring, evfd);
|
|
122
|
-
add_socket_pollin(&ring, sock_listen_fd);
|
|
123
|
-
|
|
124
|
-
while (1) {
|
|
125
|
-
struct io_uring_cqe *cqe;
|
|
126
|
-
unsigned head;
|
|
127
|
-
unsigned count = 0;
|
|
128
|
-
|
|
129
|
-
io_uring_submit_and_wait(&ring, 1);
|
|
130
|
-
|
|
131
|
-
io_uring_for_each_cqe(&ring, head, cqe) {
|
|
132
|
-
struct conn_info conn_i;
|
|
133
|
-
|
|
134
|
-
count++;
|
|
135
|
-
memcpy(&conn_i, &cqe->user_data, sizeof(conn_i));
|
|
136
|
-
|
|
137
|
-
if (conn_i.type == ACCEPT) {
|
|
138
|
-
int sock_conn_fd = cqe->res;
|
|
139
|
-
// only read when there is no error, >= 0
|
|
140
|
-
if (sock_conn_fd > 0) {
|
|
141
|
-
add_socket_pollin(&ring, sock_listen_fd);
|
|
142
|
-
|
|
143
|
-
pthread_mutex_lock(&lock);
|
|
144
|
-
io_uring_submit(client_ring);
|
|
145
|
-
pthread_mutex_unlock(&lock);
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
} else if (conn_i.type == POLLING_IN) {
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
io_uring_cq_advance(&ring, count);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
static void *client_thread(void *arg)
|
|
157
|
-
{
|
|
158
|
-
struct io_uring ring;
|
|
159
|
-
int ret;
|
|
160
|
-
|
|
161
|
-
setup_io_uring(&ring);
|
|
162
|
-
client_ring = ˚
|
|
163
|
-
|
|
164
|
-
client_eventfd = eventfd(0, EFD_CLOEXEC);
|
|
165
|
-
pthread_mutex_lock(&lock);
|
|
166
|
-
add_socket_eventfd_read(&ring, client_eventfd);
|
|
167
|
-
pthread_mutex_unlock(&lock);
|
|
168
|
-
|
|
169
|
-
while (1) {
|
|
170
|
-
struct io_uring_cqe *cqe;
|
|
171
|
-
unsigned head;
|
|
172
|
-
unsigned count = 0;
|
|
173
|
-
|
|
174
|
-
pthread_mutex_lock(&lock);
|
|
175
|
-
io_uring_submit(&ring);
|
|
176
|
-
pthread_mutex_unlock(&lock);
|
|
177
|
-
|
|
178
|
-
ret = __sys_io_uring_enter(ring.ring_fd, 0, 1, IORING_ENTER_GETEVENTS, NULL);
|
|
179
|
-
if (ret < 0) {
|
|
180
|
-
perror("Error io_uring_enter...\n");
|
|
181
|
-
exit(1);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// go through all CQEs
|
|
185
|
-
io_uring_for_each_cqe(&ring, head, cqe) {
|
|
186
|
-
struct conn_info conn_i;
|
|
187
|
-
int type;
|
|
188
|
-
|
|
189
|
-
count++;
|
|
190
|
-
memcpy(&conn_i, &cqe->user_data, sizeof(conn_i));
|
|
191
|
-
|
|
192
|
-
type = conn_i.type;
|
|
193
|
-
if (type == READ) {
|
|
194
|
-
pthread_mutex_lock(&lock);
|
|
195
|
-
|
|
196
|
-
if (cqe->res <= 0) {
|
|
197
|
-
// connection closed or error
|
|
198
|
-
shutdown(conn_i.fd, SHUT_RDWR);
|
|
199
|
-
} else {
|
|
200
|
-
pthread_mutex_unlock(&lock);
|
|
201
|
-
break;
|
|
202
|
-
}
|
|
203
|
-
add_socket_pollin(&ring, conn_i.fd);
|
|
204
|
-
pthread_mutex_unlock(&lock);
|
|
205
|
-
} else if (type == WRITE) {
|
|
206
|
-
} else if (type == POLLING_IN) {
|
|
207
|
-
break;
|
|
208
|
-
} else if (type == POLLING_RDHUP) {
|
|
209
|
-
break;
|
|
210
|
-
} else if (type == CLOSE) {
|
|
211
|
-
} else if (type == EVENTFD_READ) {
|
|
212
|
-
add_socket_eventfd_read(&ring, client_eventfd);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
io_uring_cq_advance(&ring, count);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
static void sig_alrm(int sig)
|
|
221
|
-
{
|
|
222
|
-
exit(0);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
int main(int argc, char *argv[])
|
|
226
|
-
{
|
|
227
|
-
pthread_t server_thread_t, client_thread_t;
|
|
228
|
-
struct sigaction act;
|
|
229
|
-
|
|
230
|
-
if (argc > 1)
|
|
231
|
-
return 0;
|
|
232
|
-
|
|
233
|
-
if (pthread_mutex_init(&lock, NULL) != 0) {
|
|
234
|
-
printf("\n mutex init failed\n");
|
|
235
|
-
return 1;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
pthread_create(&server_thread_t, NULL, &server_thread, NULL);
|
|
239
|
-
pthread_create(&client_thread_t, NULL, &client_thread, NULL);
|
|
240
|
-
|
|
241
|
-
memset(&act, 0, sizeof(act));
|
|
242
|
-
act.sa_handler = sig_alrm;
|
|
243
|
-
act.sa_flags = SA_RESTART;
|
|
244
|
-
sigaction(SIGALRM, &act, NULL);
|
|
245
|
-
alarm(1);
|
|
246
|
-
|
|
247
|
-
pthread_join(server_thread_t, NULL);
|
|
248
|
-
return 0;
|
|
249
|
-
}
|