@nxtedition/rocksdb 7.0.5 → 7.0.6
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 +320 -324
- package/chained-batch.js +6 -1
- package/deps/rocksdb/rocksdb/CMakeLists.txt +8 -3
- package/deps/rocksdb/rocksdb/Makefile +10 -4
- package/deps/rocksdb/rocksdb/TARGETS +6 -4
- package/deps/rocksdb/rocksdb/cache/cache_bench_tool.cc +9 -0
- package/deps/rocksdb/rocksdb/cache/cache_test.cc +14 -0
- package/deps/rocksdb/rocksdb/cache/clock_cache.cc +8 -8
- package/deps/rocksdb/rocksdb/cache/fast_lru_cache.cc +272 -174
- package/deps/rocksdb/rocksdb/cache/fast_lru_cache.h +201 -57
- package/deps/rocksdb/rocksdb/cache/lru_cache.cc +19 -19
- package/deps/rocksdb/rocksdb/cache/lru_cache.h +2 -1
- 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/blob/blob_source.cc +170 -0
- package/deps/rocksdb/rocksdb/db/blob/blob_source.h +95 -0
- package/deps/rocksdb/rocksdb/db/blob/blob_source_test.cc +298 -0
- package/deps/rocksdb/rocksdb/db/blob/db_blob_basic_test.cc +172 -0
- package/deps/rocksdb/rocksdb/db/column_family.cc +8 -3
- package/deps/rocksdb/rocksdb/db/column_family.h +6 -3
- package/deps/rocksdb/rocksdb/db/compaction/compaction_job.cc +10 -0
- package/deps/rocksdb/rocksdb/db/compaction/compaction_job_test.cc +6 -6
- package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_level.cc +22 -2
- package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_test.cc +38 -0
- package/deps/rocksdb/rocksdb/db/db_basic_test.cc +17 -5
- package/deps/rocksdb/rocksdb/db/db_block_cache_test.cc +4 -7
- package/deps/rocksdb/rocksdb/db/db_bloom_filter_test.cc +74 -71
- package/deps/rocksdb/rocksdb/db/db_compaction_test.cc +70 -1
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl.cc +13 -12
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl.h +36 -0
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_compaction_flush.cc +11 -4
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_files.cc +1 -1
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_open.cc +139 -91
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_write.cc +48 -14
- package/deps/rocksdb/rocksdb/db/db_kv_checksum_test.cc +90 -55
- package/deps/rocksdb/rocksdb/db/db_rate_limiter_test.cc +9 -4
- package/deps/rocksdb/rocksdb/db/db_test.cc +3 -1
- package/deps/rocksdb/rocksdb/db/db_wal_test.cc +12 -7
- package/deps/rocksdb/rocksdb/db/db_write_test.cc +35 -0
- package/deps/rocksdb/rocksdb/db/dbformat.cc +3 -1
- package/deps/rocksdb/rocksdb/db/dbformat.h +5 -3
- package/deps/rocksdb/rocksdb/db/flush_job_test.cc +1 -1
- package/deps/rocksdb/rocksdb/db/memtable.cc +1 -0
- package/deps/rocksdb/rocksdb/db/memtable_list_test.cc +4 -2
- package/deps/rocksdb/rocksdb/db/repair.cc +1 -1
- package/deps/rocksdb/rocksdb/db/version_builder.cc +43 -1
- package/deps/rocksdb/rocksdb/db/version_edit.cc +13 -5
- package/deps/rocksdb/rocksdb/db/version_edit.h +22 -1
- package/deps/rocksdb/rocksdb/db/version_edit_handler.cc +4 -5
- package/deps/rocksdb/rocksdb/db/version_set.cc +109 -41
- package/deps/rocksdb/rocksdb/db/version_set.h +36 -3
- package/deps/rocksdb/rocksdb/db/version_set_sync_and_async.h +1 -4
- package/deps/rocksdb/rocksdb/db/version_set_test.cc +10 -10
- package/deps/rocksdb/rocksdb/db/version_util.h +1 -1
- package/deps/rocksdb/rocksdb/db/wal_manager_test.cc +1 -1
- package/deps/rocksdb/rocksdb/db/write_batch.cc +34 -10
- package/deps/rocksdb/rocksdb/db/write_batch_internal.h +2 -0
- package/deps/rocksdb/rocksdb/db/write_callback_test.cc +4 -0
- package/deps/rocksdb/rocksdb/db_stress_tool/batched_ops_stress.cc +2 -0
- package/deps/rocksdb/rocksdb/db_stress_tool/cf_consistency_stress.cc +4 -1
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_common.h +1 -1
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_gflags.cc +7 -5
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_test_base.cc +5 -10
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_tool.cc +0 -7
- package/deps/rocksdb/rocksdb/db_stress_tool/no_batched_ops_stress.cc +2 -0
- package/deps/rocksdb/rocksdb/file/random_access_file_reader.cc +24 -3
- package/deps/rocksdb/rocksdb/file/writable_file_writer.cc +8 -0
- package/deps/rocksdb/rocksdb/file/writable_file_writer.h +10 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/advanced_options.h +5 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/cache.h +4 -4
- package/deps/rocksdb/rocksdb/include/rocksdb/options.h +9 -5
- package/deps/rocksdb/rocksdb/include/rocksdb/statistics.h +5 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/types.h +1 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/utilities/write_batch_with_index.h +1 -1
- package/deps/rocksdb/rocksdb/include/rocksdb/version.h +1 -1
- package/deps/rocksdb/rocksdb/include/rocksdb/write_batch.h +0 -3
- package/deps/rocksdb/rocksdb/microbench/ribbon_bench.cc +8 -6
- package/deps/rocksdb/rocksdb/monitoring/statistics.cc +3 -1
- package/deps/rocksdb/rocksdb/options/options_helper.cc +4 -2
- package/deps/rocksdb/rocksdb/options/options_test.cc +1 -11
- package/deps/rocksdb/rocksdb/port/port_posix.h +7 -0
- package/deps/rocksdb/rocksdb/port/win/port_win.h +11 -3
- package/deps/rocksdb/rocksdb/src.mk +6 -2
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_builder.cc +4 -33
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_iterator.h +3 -3
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.cc +38 -118
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.h +6 -8
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_sync_and_async.h +10 -13
- package/deps/rocksdb/rocksdb/table/block_based/block_like_traits.h +4 -9
- package/deps/rocksdb/rocksdb/table/block_based/block_type.h +0 -1
- package/deps/rocksdb/rocksdb/table/block_based/filter_block.h +10 -28
- package/deps/rocksdb/rocksdb/table/block_based/filter_block_reader_common.cc +2 -3
- package/deps/rocksdb/rocksdb/table/block_based/filter_policy.cc +0 -91
- package/deps/rocksdb/rocksdb/table/block_based/filter_policy_internal.h +2 -30
- package/deps/rocksdb/rocksdb/table/block_based/full_filter_block.cc +6 -27
- package/deps/rocksdb/rocksdb/table/block_based/full_filter_block.h +11 -13
- package/deps/rocksdb/rocksdb/table/block_based/full_filter_block_test.cc +28 -40
- package/deps/rocksdb/rocksdb/table/block_based/mock_block_based_table.h +0 -1
- package/deps/rocksdb/rocksdb/table/block_based/partitioned_filter_block.cc +22 -43
- package/deps/rocksdb/rocksdb/table/block_based/partitioned_filter_block.h +11 -22
- package/deps/rocksdb/rocksdb/table/block_based/partitioned_filter_block_test.cc +24 -25
- package/deps/rocksdb/rocksdb/table/block_fetcher.cc +0 -1
- package/deps/rocksdb/rocksdb/table/get_context.h +0 -1
- package/deps/rocksdb/rocksdb/table/table_test.cc +3 -18
- package/deps/rocksdb/rocksdb/tools/db_bench_tool.cc +3 -16
- package/deps/rocksdb/rocksdb/tools/ldb_cmd.cc +3 -3
- package/deps/rocksdb/rocksdb/tools/ldb_cmd_test.cc +1 -1
- package/deps/rocksdb/rocksdb/util/bloom_test.cc +0 -201
- package/deps/rocksdb/rocksdb/util/distributed_mutex.h +48 -0
- package/deps/rocksdb/rocksdb/util/filter_bench.cc +5 -11
- package/deps/rocksdb/rocksdb/utilities/backup/backup_engine.cc +3 -0
- package/deps/rocksdb/rocksdb/utilities/cache_dump_load_impl.cc +7 -21
- package/deps/rocksdb/rocksdb/utilities/cache_dump_load_impl.h +1 -1
- package/deps/rocksdb/rocksdb/utilities/checkpoint/checkpoint_test.cc +45 -0
- package/deps/rocksdb/rocksdb/utilities/transactions/pessimistic_transaction_db.h +21 -14
- package/deps/rocksdb/rocksdb/utilities/transactions/transaction_base.cc +10 -1
- package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_txn.cc +3 -1
- package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_txn_db.cc +9 -0
- package/deps/rocksdb/rocksdb/utilities/transactions/write_unprepared_txn.cc +3 -2
- package/deps/rocksdb/rocksdb/utilities/transactions/write_unprepared_txn_db.cc +3 -1
- package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index.cc +5 -4
- package/deps/rocksdb/rocksdb.gyp +1 -1
- package/index.js +36 -14
- package/package-lock.json +23687 -0
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/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/table/block_based/block_based_filter_block.cc +0 -358
- package/deps/rocksdb/rocksdb/table/block_based/block_based_filter_block.h +0 -127
- package/deps/rocksdb/rocksdb/table/block_based/block_based_filter_block_test.cc +0 -219
- package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/README +0 -13
|
@@ -1,511 +0,0 @@
|
|
|
1
|
-
#include <errno.h>
|
|
2
|
-
#include <stdio.h>
|
|
3
|
-
#include <unistd.h>
|
|
4
|
-
#include <stdlib.h>
|
|
5
|
-
#include <string.h>
|
|
6
|
-
#include <fcntl.h>
|
|
7
|
-
#include <sys/mman.h>
|
|
8
|
-
|
|
9
|
-
#include "helpers.h"
|
|
10
|
-
#include "liburing.h"
|
|
11
|
-
|
|
12
|
-
#define BUF_SIZE (16 * 4096)
|
|
13
|
-
|
|
14
|
-
struct test_ctx {
|
|
15
|
-
int real_pipe1[2];
|
|
16
|
-
int real_pipe2[2];
|
|
17
|
-
int real_fd_in;
|
|
18
|
-
int real_fd_out;
|
|
19
|
-
|
|
20
|
-
/* fds or for registered files */
|
|
21
|
-
int pipe1[2];
|
|
22
|
-
int pipe2[2];
|
|
23
|
-
int fd_in;
|
|
24
|
-
int fd_out;
|
|
25
|
-
|
|
26
|
-
void *buf_in;
|
|
27
|
-
void *buf_out;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
static unsigned int splice_flags = 0;
|
|
31
|
-
static unsigned int sqe_flags = 0;
|
|
32
|
-
static int has_splice = 0;
|
|
33
|
-
static int has_tee = 0;
|
|
34
|
-
|
|
35
|
-
static int read_buf(int fd, void *buf, int len)
|
|
36
|
-
{
|
|
37
|
-
int ret;
|
|
38
|
-
|
|
39
|
-
while (len) {
|
|
40
|
-
ret = read(fd, buf, len);
|
|
41
|
-
if (ret < 0)
|
|
42
|
-
return ret;
|
|
43
|
-
len -= ret;
|
|
44
|
-
buf += ret;
|
|
45
|
-
}
|
|
46
|
-
return 0;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
static int write_buf(int fd, const void *buf, int len)
|
|
50
|
-
{
|
|
51
|
-
int ret;
|
|
52
|
-
|
|
53
|
-
while (len) {
|
|
54
|
-
ret = write(fd, buf, len);
|
|
55
|
-
if (ret < 0)
|
|
56
|
-
return ret;
|
|
57
|
-
len -= ret;
|
|
58
|
-
buf += ret;
|
|
59
|
-
}
|
|
60
|
-
return 0;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
static int check_content(int fd, void *buf, int len, const void *src)
|
|
64
|
-
{
|
|
65
|
-
int ret;
|
|
66
|
-
|
|
67
|
-
ret = read_buf(fd, buf, len);
|
|
68
|
-
if (ret)
|
|
69
|
-
return ret;
|
|
70
|
-
|
|
71
|
-
ret = memcmp(buf, src, len);
|
|
72
|
-
return (ret != 0) ? -1 : 0;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
static int create_file(const char *filename)
|
|
76
|
-
{
|
|
77
|
-
int fd, save_errno;
|
|
78
|
-
|
|
79
|
-
fd = open(filename, O_RDWR | O_CREAT, 0644);
|
|
80
|
-
save_errno = errno;
|
|
81
|
-
unlink(filename);
|
|
82
|
-
errno = save_errno;
|
|
83
|
-
return fd;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
static int init_splice_ctx(struct test_ctx *ctx)
|
|
87
|
-
{
|
|
88
|
-
int ret, rnd_fd;
|
|
89
|
-
|
|
90
|
-
ctx->buf_in = t_calloc(BUF_SIZE, 1);
|
|
91
|
-
ctx->buf_out = t_calloc(BUF_SIZE, 1);
|
|
92
|
-
|
|
93
|
-
ctx->fd_in = create_file(".splice-test-in");
|
|
94
|
-
if (ctx->fd_in < 0) {
|
|
95
|
-
perror("file open");
|
|
96
|
-
return 1;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
ctx->fd_out = create_file(".splice-test-out");
|
|
100
|
-
if (ctx->fd_out < 0) {
|
|
101
|
-
perror("file open");
|
|
102
|
-
return 1;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/* get random data */
|
|
106
|
-
rnd_fd = open("/dev/urandom", O_RDONLY);
|
|
107
|
-
if (rnd_fd < 0)
|
|
108
|
-
return 1;
|
|
109
|
-
|
|
110
|
-
ret = read_buf(rnd_fd, ctx->buf_in, BUF_SIZE);
|
|
111
|
-
if (ret != 0)
|
|
112
|
-
return 1;
|
|
113
|
-
close(rnd_fd);
|
|
114
|
-
|
|
115
|
-
/* populate file */
|
|
116
|
-
ret = write_buf(ctx->fd_in, ctx->buf_in, BUF_SIZE);
|
|
117
|
-
if (ret)
|
|
118
|
-
return ret;
|
|
119
|
-
|
|
120
|
-
if (pipe(ctx->pipe1) < 0)
|
|
121
|
-
return 1;
|
|
122
|
-
if (pipe(ctx->pipe2) < 0)
|
|
123
|
-
return 1;
|
|
124
|
-
|
|
125
|
-
ctx->real_pipe1[0] = ctx->pipe1[0];
|
|
126
|
-
ctx->real_pipe1[1] = ctx->pipe1[1];
|
|
127
|
-
ctx->real_pipe2[0] = ctx->pipe2[0];
|
|
128
|
-
ctx->real_pipe2[1] = ctx->pipe2[1];
|
|
129
|
-
ctx->real_fd_in = ctx->fd_in;
|
|
130
|
-
ctx->real_fd_out = ctx->fd_out;
|
|
131
|
-
return 0;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
static int do_splice_op(struct io_uring *ring,
|
|
135
|
-
int fd_in, loff_t off_in,
|
|
136
|
-
int fd_out, loff_t off_out,
|
|
137
|
-
unsigned int len,
|
|
138
|
-
__u8 opcode)
|
|
139
|
-
{
|
|
140
|
-
struct io_uring_cqe *cqe;
|
|
141
|
-
struct io_uring_sqe *sqe;
|
|
142
|
-
int ret = -1;
|
|
143
|
-
|
|
144
|
-
do {
|
|
145
|
-
sqe = io_uring_get_sqe(ring);
|
|
146
|
-
if (!sqe) {
|
|
147
|
-
fprintf(stderr, "get sqe failed\n");
|
|
148
|
-
return -1;
|
|
149
|
-
}
|
|
150
|
-
io_uring_prep_splice(sqe, fd_in, off_in, fd_out, off_out,
|
|
151
|
-
len, splice_flags);
|
|
152
|
-
sqe->flags |= sqe_flags;
|
|
153
|
-
sqe->user_data = 42;
|
|
154
|
-
sqe->opcode = opcode;
|
|
155
|
-
|
|
156
|
-
ret = io_uring_submit(ring);
|
|
157
|
-
if (ret != 1) {
|
|
158
|
-
fprintf(stderr, "sqe submit failed: %d\n", ret);
|
|
159
|
-
return ret;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
ret = io_uring_wait_cqe(ring, &cqe);
|
|
163
|
-
if (ret < 0) {
|
|
164
|
-
fprintf(stderr, "wait completion %d\n", cqe->res);
|
|
165
|
-
return ret;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
if (cqe->res <= 0) {
|
|
169
|
-
io_uring_cqe_seen(ring, cqe);
|
|
170
|
-
return cqe->res;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
len -= cqe->res;
|
|
174
|
-
if (off_in != -1)
|
|
175
|
-
off_in += cqe->res;
|
|
176
|
-
if (off_out != -1)
|
|
177
|
-
off_out += cqe->res;
|
|
178
|
-
io_uring_cqe_seen(ring, cqe);
|
|
179
|
-
} while (len);
|
|
180
|
-
|
|
181
|
-
return 0;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
static int do_splice(struct io_uring *ring,
|
|
185
|
-
int fd_in, loff_t off_in,
|
|
186
|
-
int fd_out, loff_t off_out,
|
|
187
|
-
unsigned int len)
|
|
188
|
-
{
|
|
189
|
-
return do_splice_op(ring, fd_in, off_in, fd_out, off_out, len,
|
|
190
|
-
IORING_OP_SPLICE);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
static int do_tee(struct io_uring *ring, int fd_in, int fd_out,
|
|
194
|
-
unsigned int len)
|
|
195
|
-
{
|
|
196
|
-
return do_splice_op(ring, fd_in, 0, fd_out, 0, len, IORING_OP_TEE);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
static void check_splice_support(struct io_uring *ring, struct test_ctx *ctx)
|
|
200
|
-
{
|
|
201
|
-
int ret;
|
|
202
|
-
|
|
203
|
-
ret = do_splice(ring, -1, 0, -1, 0, BUF_SIZE);
|
|
204
|
-
has_splice = (ret == -EBADF);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
static void check_tee_support(struct io_uring *ring, struct test_ctx *ctx)
|
|
208
|
-
{
|
|
209
|
-
int ret;
|
|
210
|
-
|
|
211
|
-
ret = do_tee(ring, -1, -1, BUF_SIZE);
|
|
212
|
-
has_tee = (ret == -EBADF);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
static int check_zero_splice(struct io_uring *ring, struct test_ctx *ctx)
|
|
216
|
-
{
|
|
217
|
-
int ret;
|
|
218
|
-
|
|
219
|
-
ret = do_splice(ring, ctx->fd_in, -1, ctx->pipe1[1], -1, 0);
|
|
220
|
-
if (ret)
|
|
221
|
-
return ret;
|
|
222
|
-
|
|
223
|
-
ret = do_splice(ring, ctx->pipe2[0], -1, ctx->pipe1[1], -1, 0);
|
|
224
|
-
if (ret)
|
|
225
|
-
return ret;
|
|
226
|
-
|
|
227
|
-
return 0;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
static int splice_to_pipe(struct io_uring *ring, struct test_ctx *ctx)
|
|
231
|
-
{
|
|
232
|
-
int ret;
|
|
233
|
-
|
|
234
|
-
ret = lseek(ctx->real_fd_in, 0, SEEK_SET);
|
|
235
|
-
if (ret)
|
|
236
|
-
return ret;
|
|
237
|
-
|
|
238
|
-
/* implicit file offset */
|
|
239
|
-
ret = do_splice(ring, ctx->fd_in, -1, ctx->pipe1[1], -1, BUF_SIZE);
|
|
240
|
-
if (ret)
|
|
241
|
-
return ret;
|
|
242
|
-
|
|
243
|
-
ret = check_content(ctx->real_pipe1[0], ctx->buf_out, BUF_SIZE,
|
|
244
|
-
ctx->buf_in);
|
|
245
|
-
if (ret)
|
|
246
|
-
return ret;
|
|
247
|
-
|
|
248
|
-
/* explicit file offset */
|
|
249
|
-
ret = do_splice(ring, ctx->fd_in, 0, ctx->pipe1[1], -1, BUF_SIZE);
|
|
250
|
-
if (ret)
|
|
251
|
-
return ret;
|
|
252
|
-
|
|
253
|
-
return check_content(ctx->real_pipe1[0], ctx->buf_out, BUF_SIZE,
|
|
254
|
-
ctx->buf_in);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
static int splice_from_pipe(struct io_uring *ring, struct test_ctx *ctx)
|
|
258
|
-
{
|
|
259
|
-
int ret;
|
|
260
|
-
|
|
261
|
-
ret = write_buf(ctx->real_pipe1[1], ctx->buf_in, BUF_SIZE);
|
|
262
|
-
if (ret)
|
|
263
|
-
return ret;
|
|
264
|
-
ret = do_splice(ring, ctx->pipe1[0], -1, ctx->fd_out, 0, BUF_SIZE);
|
|
265
|
-
if (ret)
|
|
266
|
-
return ret;
|
|
267
|
-
ret = check_content(ctx->real_fd_out, ctx->buf_out, BUF_SIZE,
|
|
268
|
-
ctx->buf_in);
|
|
269
|
-
if (ret)
|
|
270
|
-
return ret;
|
|
271
|
-
|
|
272
|
-
ret = ftruncate(ctx->real_fd_out, 0);
|
|
273
|
-
if (ret)
|
|
274
|
-
return ret;
|
|
275
|
-
return lseek(ctx->real_fd_out, 0, SEEK_SET);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
static int splice_pipe_to_pipe(struct io_uring *ring, struct test_ctx *ctx)
|
|
279
|
-
{
|
|
280
|
-
int ret;
|
|
281
|
-
|
|
282
|
-
ret = do_splice(ring, ctx->fd_in, 0, ctx->pipe1[1], -1, BUF_SIZE);
|
|
283
|
-
if (ret)
|
|
284
|
-
return ret;
|
|
285
|
-
ret = do_splice(ring, ctx->pipe1[0], -1, ctx->pipe2[1], -1, BUF_SIZE);
|
|
286
|
-
if (ret)
|
|
287
|
-
return ret;
|
|
288
|
-
|
|
289
|
-
return check_content(ctx->real_pipe2[0], ctx->buf_out, BUF_SIZE,
|
|
290
|
-
ctx->buf_in);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
static int fail_splice_pipe_offset(struct io_uring *ring, struct test_ctx *ctx)
|
|
294
|
-
{
|
|
295
|
-
int ret;
|
|
296
|
-
|
|
297
|
-
ret = do_splice(ring, ctx->fd_in, 0, ctx->pipe1[1], 0, BUF_SIZE);
|
|
298
|
-
if (ret != -ESPIPE && ret != -EINVAL)
|
|
299
|
-
return ret;
|
|
300
|
-
|
|
301
|
-
ret = do_splice(ring, ctx->pipe1[0], 0, ctx->fd_out, 0, BUF_SIZE);
|
|
302
|
-
if (ret != -ESPIPE && ret != -EINVAL)
|
|
303
|
-
return ret;
|
|
304
|
-
|
|
305
|
-
return 0;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
static int fail_tee_nonpipe(struct io_uring *ring, struct test_ctx *ctx)
|
|
309
|
-
{
|
|
310
|
-
int ret;
|
|
311
|
-
|
|
312
|
-
ret = do_tee(ring, ctx->fd_in, ctx->pipe1[1], BUF_SIZE);
|
|
313
|
-
if (ret != -ESPIPE && ret != -EINVAL)
|
|
314
|
-
return ret;
|
|
315
|
-
|
|
316
|
-
return 0;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
static int fail_tee_offset(struct io_uring *ring, struct test_ctx *ctx)
|
|
320
|
-
{
|
|
321
|
-
int ret;
|
|
322
|
-
|
|
323
|
-
ret = do_splice_op(ring, ctx->pipe2[0], -1, ctx->pipe1[1], 0,
|
|
324
|
-
BUF_SIZE, IORING_OP_TEE);
|
|
325
|
-
if (ret != -ESPIPE && ret != -EINVAL)
|
|
326
|
-
return ret;
|
|
327
|
-
|
|
328
|
-
ret = do_splice_op(ring, ctx->pipe2[0], 0, ctx->pipe1[1], -1,
|
|
329
|
-
BUF_SIZE, IORING_OP_TEE);
|
|
330
|
-
if (ret != -ESPIPE && ret != -EINVAL)
|
|
331
|
-
return ret;
|
|
332
|
-
|
|
333
|
-
return 0;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
static int check_tee(struct io_uring *ring, struct test_ctx *ctx)
|
|
337
|
-
{
|
|
338
|
-
int ret;
|
|
339
|
-
|
|
340
|
-
ret = write_buf(ctx->real_pipe1[1], ctx->buf_in, BUF_SIZE);
|
|
341
|
-
if (ret)
|
|
342
|
-
return ret;
|
|
343
|
-
ret = do_tee(ring, ctx->pipe1[0], ctx->pipe2[1], BUF_SIZE);
|
|
344
|
-
if (ret)
|
|
345
|
-
return ret;
|
|
346
|
-
|
|
347
|
-
ret = check_content(ctx->real_pipe1[0], ctx->buf_out, BUF_SIZE,
|
|
348
|
-
ctx->buf_in);
|
|
349
|
-
if (ret) {
|
|
350
|
-
fprintf(stderr, "tee(), invalid src data\n");
|
|
351
|
-
return ret;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
ret = check_content(ctx->real_pipe2[0], ctx->buf_out, BUF_SIZE,
|
|
355
|
-
ctx->buf_in);
|
|
356
|
-
if (ret) {
|
|
357
|
-
fprintf(stderr, "tee(), invalid dst data\n");
|
|
358
|
-
return ret;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
return 0;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
static int check_zero_tee(struct io_uring *ring, struct test_ctx *ctx)
|
|
365
|
-
{
|
|
366
|
-
return do_tee(ring, ctx->pipe2[0], ctx->pipe1[1], 0);
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
static int test_splice(struct io_uring *ring, struct test_ctx *ctx)
|
|
370
|
-
{
|
|
371
|
-
int ret;
|
|
372
|
-
|
|
373
|
-
if (has_splice) {
|
|
374
|
-
ret = check_zero_splice(ring, ctx);
|
|
375
|
-
if (ret) {
|
|
376
|
-
fprintf(stderr, "check_zero_splice failed %i %i\n",
|
|
377
|
-
ret, errno);
|
|
378
|
-
return ret;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
ret = splice_to_pipe(ring, ctx);
|
|
382
|
-
if (ret) {
|
|
383
|
-
fprintf(stderr, "splice_to_pipe failed %i %i\n",
|
|
384
|
-
ret, errno);
|
|
385
|
-
return ret;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
ret = splice_from_pipe(ring, ctx);
|
|
389
|
-
if (ret) {
|
|
390
|
-
fprintf(stderr, "splice_from_pipe failed %i %i\n",
|
|
391
|
-
ret, errno);
|
|
392
|
-
return ret;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
ret = splice_pipe_to_pipe(ring, ctx);
|
|
396
|
-
if (ret) {
|
|
397
|
-
fprintf(stderr, "splice_pipe_to_pipe failed %i %i\n",
|
|
398
|
-
ret, errno);
|
|
399
|
-
return ret;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
ret = fail_splice_pipe_offset(ring, ctx);
|
|
403
|
-
if (ret) {
|
|
404
|
-
fprintf(stderr, "fail_splice_pipe_offset failed %i %i\n",
|
|
405
|
-
ret, errno);
|
|
406
|
-
return ret;
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
if (has_tee) {
|
|
411
|
-
ret = check_zero_tee(ring, ctx);
|
|
412
|
-
if (ret) {
|
|
413
|
-
fprintf(stderr, "check_zero_tee() failed %i %i\n",
|
|
414
|
-
ret, errno);
|
|
415
|
-
return ret;
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
ret = fail_tee_nonpipe(ring, ctx);
|
|
419
|
-
if (ret) {
|
|
420
|
-
fprintf(stderr, "fail_tee_nonpipe() failed %i %i\n",
|
|
421
|
-
ret, errno);
|
|
422
|
-
return ret;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
ret = fail_tee_offset(ring, ctx);
|
|
426
|
-
if (ret) {
|
|
427
|
-
fprintf(stderr, "fail_tee_offset failed %i %i\n",
|
|
428
|
-
ret, errno);
|
|
429
|
-
return ret;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
ret = check_tee(ring, ctx);
|
|
433
|
-
if (ret) {
|
|
434
|
-
fprintf(stderr, "check_tee() failed %i %i\n",
|
|
435
|
-
ret, errno);
|
|
436
|
-
return ret;
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
return 0;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
int main(int argc, char *argv[])
|
|
444
|
-
{
|
|
445
|
-
struct io_uring ring;
|
|
446
|
-
struct io_uring_params p = { };
|
|
447
|
-
struct test_ctx ctx;
|
|
448
|
-
int ret;
|
|
449
|
-
int reg_fds[6];
|
|
450
|
-
|
|
451
|
-
if (argc > 1)
|
|
452
|
-
return 0;
|
|
453
|
-
|
|
454
|
-
ret = io_uring_queue_init_params(8, &ring, &p);
|
|
455
|
-
if (ret) {
|
|
456
|
-
fprintf(stderr, "ring setup failed\n");
|
|
457
|
-
return 1;
|
|
458
|
-
}
|
|
459
|
-
if (!(p.features & IORING_FEAT_FAST_POLL)) {
|
|
460
|
-
fprintf(stdout, "No splice support, skipping\n");
|
|
461
|
-
return 0;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
ret = init_splice_ctx(&ctx);
|
|
465
|
-
if (ret) {
|
|
466
|
-
fprintf(stderr, "init failed %i %i\n", ret, errno);
|
|
467
|
-
return 1;
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
check_splice_support(&ring, &ctx);
|
|
471
|
-
if (!has_splice)
|
|
472
|
-
fprintf(stdout, "skip, doesn't support splice()\n");
|
|
473
|
-
check_tee_support(&ring, &ctx);
|
|
474
|
-
if (!has_tee)
|
|
475
|
-
fprintf(stdout, "skip, doesn't support tee()\n");
|
|
476
|
-
|
|
477
|
-
ret = test_splice(&ring, &ctx);
|
|
478
|
-
if (ret) {
|
|
479
|
-
fprintf(stderr, "basic splice tests failed\n");
|
|
480
|
-
return ret;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
reg_fds[0] = ctx.real_pipe1[0];
|
|
484
|
-
reg_fds[1] = ctx.real_pipe1[1];
|
|
485
|
-
reg_fds[2] = ctx.real_pipe2[0];
|
|
486
|
-
reg_fds[3] = ctx.real_pipe2[1];
|
|
487
|
-
reg_fds[4] = ctx.real_fd_in;
|
|
488
|
-
reg_fds[5] = ctx.real_fd_out;
|
|
489
|
-
ret = io_uring_register_files(&ring, reg_fds, 6);
|
|
490
|
-
if (ret) {
|
|
491
|
-
fprintf(stderr, "%s: register ret=%d\n", __FUNCTION__, ret);
|
|
492
|
-
return 1;
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
/* remap fds to registered */
|
|
496
|
-
ctx.pipe1[0] = 0;
|
|
497
|
-
ctx.pipe1[1] = 1;
|
|
498
|
-
ctx.pipe2[0] = 2;
|
|
499
|
-
ctx.pipe2[1] = 3;
|
|
500
|
-
ctx.fd_in = 4;
|
|
501
|
-
ctx.fd_out = 5;
|
|
502
|
-
|
|
503
|
-
splice_flags = SPLICE_F_FD_IN_FIXED;
|
|
504
|
-
sqe_flags = IOSQE_FIXED_FILE;
|
|
505
|
-
ret = test_splice(&ring, &ctx);
|
|
506
|
-
if (ret) {
|
|
507
|
-
fprintf(stderr, "registered fds splice tests failed\n");
|
|
508
|
-
return ret;
|
|
509
|
-
}
|
|
510
|
-
return 0;
|
|
511
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/* SPDX-License-Identifier: MIT */
|
|
2
|
-
/*
|
|
3
|
-
* Description: test SQ queue full condition
|
|
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
|
-
int main(int argc, char *argv[])
|
|
16
|
-
{
|
|
17
|
-
struct io_uring_sqe *sqe;
|
|
18
|
-
struct io_uring ring;
|
|
19
|
-
int ret, i;
|
|
20
|
-
|
|
21
|
-
if (argc > 1)
|
|
22
|
-
return 0;
|
|
23
|
-
|
|
24
|
-
ret = io_uring_queue_init(8, &ring, 0);
|
|
25
|
-
if (ret) {
|
|
26
|
-
fprintf(stderr, "ring setup failed: %d\n", ret);
|
|
27
|
-
return 1;
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
i = 0;
|
|
32
|
-
while ((sqe = io_uring_get_sqe(&ring)) != NULL)
|
|
33
|
-
i++;
|
|
34
|
-
|
|
35
|
-
if (i != 8) {
|
|
36
|
-
fprintf(stderr, "Got %d SQEs, wanted 8\n", i);
|
|
37
|
-
goto err;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
io_uring_queue_exit(&ring);
|
|
41
|
-
return 0;
|
|
42
|
-
err:
|
|
43
|
-
io_uring_queue_exit(&ring);
|
|
44
|
-
return 1;
|
|
45
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/* SPDX-License-Identifier: MIT */
|
|
2
|
-
/*
|
|
3
|
-
* Description: test SQ queue full condition
|
|
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
|
-
int main(int argc, char *argv[])
|
|
16
|
-
{
|
|
17
|
-
struct io_uring_sqe *sqe;
|
|
18
|
-
struct io_uring ring;
|
|
19
|
-
int ret, i;
|
|
20
|
-
|
|
21
|
-
if (argc > 1)
|
|
22
|
-
return 0;
|
|
23
|
-
|
|
24
|
-
ret = io_uring_queue_init(8, &ring, 0);
|
|
25
|
-
if (ret) {
|
|
26
|
-
fprintf(stderr, "ring setup failed: %d\n", ret);
|
|
27
|
-
return 1;
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
i = 0;
|
|
32
|
-
while ((sqe = io_uring_get_sqe(&ring)) != NULL)
|
|
33
|
-
i++;
|
|
34
|
-
|
|
35
|
-
if (i != 8) {
|
|
36
|
-
fprintf(stderr, "Got %d SQEs, wanted 8\n", i);
|
|
37
|
-
goto err;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
io_uring_queue_exit(&ring);
|
|
41
|
-
return 0;
|
|
42
|
-
err:
|
|
43
|
-
io_uring_queue_exit(&ring);
|
|
44
|
-
return 1;
|
|
45
|
-
}
|