@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.
Files changed (261) hide show
  1. package/binding.cc +320 -324
  2. package/chained-batch.js +6 -1
  3. package/deps/rocksdb/rocksdb/CMakeLists.txt +8 -3
  4. package/deps/rocksdb/rocksdb/Makefile +10 -4
  5. package/deps/rocksdb/rocksdb/TARGETS +6 -4
  6. package/deps/rocksdb/rocksdb/cache/cache_bench_tool.cc +9 -0
  7. package/deps/rocksdb/rocksdb/cache/cache_test.cc +14 -0
  8. package/deps/rocksdb/rocksdb/cache/clock_cache.cc +8 -8
  9. package/deps/rocksdb/rocksdb/cache/fast_lru_cache.cc +272 -174
  10. package/deps/rocksdb/rocksdb/cache/fast_lru_cache.h +201 -57
  11. package/deps/rocksdb/rocksdb/cache/lru_cache.cc +19 -19
  12. package/deps/rocksdb/rocksdb/cache/lru_cache.h +2 -1
  13. package/deps/rocksdb/rocksdb/cmake/modules/CxxFlags.cmake +7 -0
  14. package/deps/rocksdb/rocksdb/cmake/modules/FindJeMalloc.cmake +29 -0
  15. package/deps/rocksdb/rocksdb/cmake/modules/FindNUMA.cmake +29 -0
  16. package/deps/rocksdb/rocksdb/cmake/modules/FindSnappy.cmake +29 -0
  17. package/deps/rocksdb/rocksdb/cmake/modules/FindTBB.cmake +33 -0
  18. package/deps/rocksdb/rocksdb/cmake/modules/Findgflags.cmake +29 -0
  19. package/deps/rocksdb/rocksdb/cmake/modules/Findlz4.cmake +29 -0
  20. package/deps/rocksdb/rocksdb/cmake/modules/Finduring.cmake +26 -0
  21. package/deps/rocksdb/rocksdb/cmake/modules/Findzstd.cmake +29 -0
  22. package/deps/rocksdb/rocksdb/cmake/modules/ReadVersion.cmake +10 -0
  23. package/deps/rocksdb/rocksdb/db/blob/blob_source.cc +170 -0
  24. package/deps/rocksdb/rocksdb/db/blob/blob_source.h +95 -0
  25. package/deps/rocksdb/rocksdb/db/blob/blob_source_test.cc +298 -0
  26. package/deps/rocksdb/rocksdb/db/blob/db_blob_basic_test.cc +172 -0
  27. package/deps/rocksdb/rocksdb/db/column_family.cc +8 -3
  28. package/deps/rocksdb/rocksdb/db/column_family.h +6 -3
  29. package/deps/rocksdb/rocksdb/db/compaction/compaction_job.cc +10 -0
  30. package/deps/rocksdb/rocksdb/db/compaction/compaction_job_test.cc +6 -6
  31. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_level.cc +22 -2
  32. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_test.cc +38 -0
  33. package/deps/rocksdb/rocksdb/db/db_basic_test.cc +17 -5
  34. package/deps/rocksdb/rocksdb/db/db_block_cache_test.cc +4 -7
  35. package/deps/rocksdb/rocksdb/db/db_bloom_filter_test.cc +74 -71
  36. package/deps/rocksdb/rocksdb/db/db_compaction_test.cc +70 -1
  37. package/deps/rocksdb/rocksdb/db/db_impl/db_impl.cc +13 -12
  38. package/deps/rocksdb/rocksdb/db/db_impl/db_impl.h +36 -0
  39. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_compaction_flush.cc +11 -4
  40. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_files.cc +1 -1
  41. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_open.cc +139 -91
  42. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_write.cc +48 -14
  43. package/deps/rocksdb/rocksdb/db/db_kv_checksum_test.cc +90 -55
  44. package/deps/rocksdb/rocksdb/db/db_rate_limiter_test.cc +9 -4
  45. package/deps/rocksdb/rocksdb/db/db_test.cc +3 -1
  46. package/deps/rocksdb/rocksdb/db/db_wal_test.cc +12 -7
  47. package/deps/rocksdb/rocksdb/db/db_write_test.cc +35 -0
  48. package/deps/rocksdb/rocksdb/db/dbformat.cc +3 -1
  49. package/deps/rocksdb/rocksdb/db/dbformat.h +5 -3
  50. package/deps/rocksdb/rocksdb/db/flush_job_test.cc +1 -1
  51. package/deps/rocksdb/rocksdb/db/memtable.cc +1 -0
  52. package/deps/rocksdb/rocksdb/db/memtable_list_test.cc +4 -2
  53. package/deps/rocksdb/rocksdb/db/repair.cc +1 -1
  54. package/deps/rocksdb/rocksdb/db/version_builder.cc +43 -1
  55. package/deps/rocksdb/rocksdb/db/version_edit.cc +13 -5
  56. package/deps/rocksdb/rocksdb/db/version_edit.h +22 -1
  57. package/deps/rocksdb/rocksdb/db/version_edit_handler.cc +4 -5
  58. package/deps/rocksdb/rocksdb/db/version_set.cc +109 -41
  59. package/deps/rocksdb/rocksdb/db/version_set.h +36 -3
  60. package/deps/rocksdb/rocksdb/db/version_set_sync_and_async.h +1 -4
  61. package/deps/rocksdb/rocksdb/db/version_set_test.cc +10 -10
  62. package/deps/rocksdb/rocksdb/db/version_util.h +1 -1
  63. package/deps/rocksdb/rocksdb/db/wal_manager_test.cc +1 -1
  64. package/deps/rocksdb/rocksdb/db/write_batch.cc +34 -10
  65. package/deps/rocksdb/rocksdb/db/write_batch_internal.h +2 -0
  66. package/deps/rocksdb/rocksdb/db/write_callback_test.cc +4 -0
  67. package/deps/rocksdb/rocksdb/db_stress_tool/batched_ops_stress.cc +2 -0
  68. package/deps/rocksdb/rocksdb/db_stress_tool/cf_consistency_stress.cc +4 -1
  69. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_common.h +1 -1
  70. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_gflags.cc +7 -5
  71. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_test_base.cc +5 -10
  72. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_tool.cc +0 -7
  73. package/deps/rocksdb/rocksdb/db_stress_tool/no_batched_ops_stress.cc +2 -0
  74. package/deps/rocksdb/rocksdb/file/random_access_file_reader.cc +24 -3
  75. package/deps/rocksdb/rocksdb/file/writable_file_writer.cc +8 -0
  76. package/deps/rocksdb/rocksdb/file/writable_file_writer.h +10 -0
  77. package/deps/rocksdb/rocksdb/include/rocksdb/advanced_options.h +5 -0
  78. package/deps/rocksdb/rocksdb/include/rocksdb/cache.h +4 -4
  79. package/deps/rocksdb/rocksdb/include/rocksdb/options.h +9 -5
  80. package/deps/rocksdb/rocksdb/include/rocksdb/statistics.h +5 -0
  81. package/deps/rocksdb/rocksdb/include/rocksdb/types.h +1 -0
  82. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/write_batch_with_index.h +1 -1
  83. package/deps/rocksdb/rocksdb/include/rocksdb/version.h +1 -1
  84. package/deps/rocksdb/rocksdb/include/rocksdb/write_batch.h +0 -3
  85. package/deps/rocksdb/rocksdb/microbench/ribbon_bench.cc +8 -6
  86. package/deps/rocksdb/rocksdb/monitoring/statistics.cc +3 -1
  87. package/deps/rocksdb/rocksdb/options/options_helper.cc +4 -2
  88. package/deps/rocksdb/rocksdb/options/options_test.cc +1 -11
  89. package/deps/rocksdb/rocksdb/port/port_posix.h +7 -0
  90. package/deps/rocksdb/rocksdb/port/win/port_win.h +11 -3
  91. package/deps/rocksdb/rocksdb/src.mk +6 -2
  92. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_builder.cc +4 -33
  93. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_iterator.h +3 -3
  94. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.cc +38 -118
  95. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.h +6 -8
  96. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_sync_and_async.h +10 -13
  97. package/deps/rocksdb/rocksdb/table/block_based/block_like_traits.h +4 -9
  98. package/deps/rocksdb/rocksdb/table/block_based/block_type.h +0 -1
  99. package/deps/rocksdb/rocksdb/table/block_based/filter_block.h +10 -28
  100. package/deps/rocksdb/rocksdb/table/block_based/filter_block_reader_common.cc +2 -3
  101. package/deps/rocksdb/rocksdb/table/block_based/filter_policy.cc +0 -91
  102. package/deps/rocksdb/rocksdb/table/block_based/filter_policy_internal.h +2 -30
  103. package/deps/rocksdb/rocksdb/table/block_based/full_filter_block.cc +6 -27
  104. package/deps/rocksdb/rocksdb/table/block_based/full_filter_block.h +11 -13
  105. package/deps/rocksdb/rocksdb/table/block_based/full_filter_block_test.cc +28 -40
  106. package/deps/rocksdb/rocksdb/table/block_based/mock_block_based_table.h +0 -1
  107. package/deps/rocksdb/rocksdb/table/block_based/partitioned_filter_block.cc +22 -43
  108. package/deps/rocksdb/rocksdb/table/block_based/partitioned_filter_block.h +11 -22
  109. package/deps/rocksdb/rocksdb/table/block_based/partitioned_filter_block_test.cc +24 -25
  110. package/deps/rocksdb/rocksdb/table/block_fetcher.cc +0 -1
  111. package/deps/rocksdb/rocksdb/table/get_context.h +0 -1
  112. package/deps/rocksdb/rocksdb/table/table_test.cc +3 -18
  113. package/deps/rocksdb/rocksdb/tools/db_bench_tool.cc +3 -16
  114. package/deps/rocksdb/rocksdb/tools/ldb_cmd.cc +3 -3
  115. package/deps/rocksdb/rocksdb/tools/ldb_cmd_test.cc +1 -1
  116. package/deps/rocksdb/rocksdb/util/bloom_test.cc +0 -201
  117. package/deps/rocksdb/rocksdb/util/distributed_mutex.h +48 -0
  118. package/deps/rocksdb/rocksdb/util/filter_bench.cc +5 -11
  119. package/deps/rocksdb/rocksdb/utilities/backup/backup_engine.cc +3 -0
  120. package/deps/rocksdb/rocksdb/utilities/cache_dump_load_impl.cc +7 -21
  121. package/deps/rocksdb/rocksdb/utilities/cache_dump_load_impl.h +1 -1
  122. package/deps/rocksdb/rocksdb/utilities/checkpoint/checkpoint_test.cc +45 -0
  123. package/deps/rocksdb/rocksdb/utilities/transactions/pessimistic_transaction_db.h +21 -14
  124. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_base.cc +10 -1
  125. package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_txn.cc +3 -1
  126. package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_txn_db.cc +9 -0
  127. package/deps/rocksdb/rocksdb/utilities/transactions/write_unprepared_txn.cc +3 -2
  128. package/deps/rocksdb/rocksdb/utilities/transactions/write_unprepared_txn_db.cc +3 -1
  129. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index.cc +5 -4
  130. package/deps/rocksdb/rocksdb.gyp +1 -1
  131. package/index.js +36 -14
  132. package/package-lock.json +23687 -0
  133. package/package.json +1 -1
  134. package/prebuilds/darwin-arm64/node.napi.node +0 -0
  135. package/prebuilds/linux-x64/node.napi.node +0 -0
  136. package/deps/liburing/liburing/README +0 -46
  137. package/deps/liburing/liburing/test/232c93d07b74-test.c +0 -305
  138. package/deps/liburing/liburing/test/35fa71a030ca-test.c +0 -329
  139. package/deps/liburing/liburing/test/500f9fbadef8-test.c +0 -89
  140. package/deps/liburing/liburing/test/7ad0e4b2f83c-test.c +0 -93
  141. package/deps/liburing/liburing/test/8a9973408177-test.c +0 -106
  142. package/deps/liburing/liburing/test/917257daa0fe-test.c +0 -53
  143. package/deps/liburing/liburing/test/Makefile +0 -312
  144. package/deps/liburing/liburing/test/a0908ae19763-test.c +0 -58
  145. package/deps/liburing/liburing/test/a4c0b3decb33-test.c +0 -180
  146. package/deps/liburing/liburing/test/accept-link.c +0 -251
  147. package/deps/liburing/liburing/test/accept-reuse.c +0 -164
  148. package/deps/liburing/liburing/test/accept-test.c +0 -79
  149. package/deps/liburing/liburing/test/accept.c +0 -476
  150. package/deps/liburing/liburing/test/across-fork.c +0 -283
  151. package/deps/liburing/liburing/test/b19062a56726-test.c +0 -53
  152. package/deps/liburing/liburing/test/b5837bd5311d-test.c +0 -77
  153. package/deps/liburing/liburing/test/ce593a6c480a-test.c +0 -135
  154. package/deps/liburing/liburing/test/close-opath.c +0 -122
  155. package/deps/liburing/liburing/test/config +0 -10
  156. package/deps/liburing/liburing/test/connect.c +0 -398
  157. package/deps/liburing/liburing/test/cq-full.c +0 -96
  158. package/deps/liburing/liburing/test/cq-overflow.c +0 -294
  159. package/deps/liburing/liburing/test/cq-peek-batch.c +0 -102
  160. package/deps/liburing/liburing/test/cq-ready.c +0 -94
  161. package/deps/liburing/liburing/test/cq-size.c +0 -58
  162. package/deps/liburing/liburing/test/d4ae271dfaae-test.c +0 -96
  163. package/deps/liburing/liburing/test/d77a67ed5f27-test.c +0 -65
  164. package/deps/liburing/liburing/test/defer.c +0 -307
  165. package/deps/liburing/liburing/test/double-poll-crash.c +0 -186
  166. package/deps/liburing/liburing/test/eeed8b54e0df-test.c +0 -114
  167. package/deps/liburing/liburing/test/empty-eownerdead.c +0 -42
  168. package/deps/liburing/liburing/test/eventfd-disable.c +0 -151
  169. package/deps/liburing/liburing/test/eventfd-ring.c +0 -97
  170. package/deps/liburing/liburing/test/eventfd.c +0 -112
  171. package/deps/liburing/liburing/test/fadvise.c +0 -202
  172. package/deps/liburing/liburing/test/fallocate.c +0 -249
  173. package/deps/liburing/liburing/test/fc2a85cb02ef-test.c +0 -138
  174. package/deps/liburing/liburing/test/file-register.c +0 -843
  175. package/deps/liburing/liburing/test/file-update.c +0 -173
  176. package/deps/liburing/liburing/test/files-exit-hang-poll.c +0 -128
  177. package/deps/liburing/liburing/test/files-exit-hang-timeout.c +0 -134
  178. package/deps/liburing/liburing/test/fixed-link.c +0 -90
  179. package/deps/liburing/liburing/test/fsync.c +0 -224
  180. package/deps/liburing/liburing/test/hardlink.c +0 -136
  181. package/deps/liburing/liburing/test/helpers.c +0 -135
  182. package/deps/liburing/liburing/test/helpers.h +0 -67
  183. package/deps/liburing/liburing/test/io-cancel.c +0 -537
  184. package/deps/liburing/liburing/test/io_uring_enter.c +0 -296
  185. package/deps/liburing/liburing/test/io_uring_register.c +0 -664
  186. package/deps/liburing/liburing/test/io_uring_setup.c +0 -192
  187. package/deps/liburing/liburing/test/iopoll.c +0 -366
  188. package/deps/liburing/liburing/test/lfs-openat-write.c +0 -117
  189. package/deps/liburing/liburing/test/lfs-openat.c +0 -273
  190. package/deps/liburing/liburing/test/link-timeout.c +0 -1107
  191. package/deps/liburing/liburing/test/link.c +0 -496
  192. package/deps/liburing/liburing/test/link_drain.c +0 -229
  193. package/deps/liburing/liburing/test/madvise.c +0 -195
  194. package/deps/liburing/liburing/test/mkdir.c +0 -108
  195. package/deps/liburing/liburing/test/multicqes_drain.c +0 -383
  196. package/deps/liburing/liburing/test/nop-all-sizes.c +0 -107
  197. package/deps/liburing/liburing/test/nop.c +0 -115
  198. package/deps/liburing/liburing/test/open-close.c +0 -146
  199. package/deps/liburing/liburing/test/openat2.c +0 -240
  200. package/deps/liburing/liburing/test/personality.c +0 -204
  201. package/deps/liburing/liburing/test/pipe-eof.c +0 -81
  202. package/deps/liburing/liburing/test/pipe-reuse.c +0 -105
  203. package/deps/liburing/liburing/test/poll-cancel-ton.c +0 -139
  204. package/deps/liburing/liburing/test/poll-cancel.c +0 -135
  205. package/deps/liburing/liburing/test/poll-link.c +0 -227
  206. package/deps/liburing/liburing/test/poll-many.c +0 -208
  207. package/deps/liburing/liburing/test/poll-mshot-update.c +0 -273
  208. package/deps/liburing/liburing/test/poll-ring.c +0 -48
  209. package/deps/liburing/liburing/test/poll-v-poll.c +0 -353
  210. package/deps/liburing/liburing/test/poll.c +0 -109
  211. package/deps/liburing/liburing/test/probe.c +0 -137
  212. package/deps/liburing/liburing/test/read-write.c +0 -876
  213. package/deps/liburing/liburing/test/register-restrictions.c +0 -633
  214. package/deps/liburing/liburing/test/rename.c +0 -134
  215. package/deps/liburing/liburing/test/ring-leak.c +0 -173
  216. package/deps/liburing/liburing/test/ring-leak2.c +0 -249
  217. package/deps/liburing/liburing/test/rsrc_tags.c +0 -449
  218. package/deps/liburing/liburing/test/runtests-loop.sh +0 -16
  219. package/deps/liburing/liburing/test/runtests.sh +0 -170
  220. package/deps/liburing/liburing/test/rw_merge_test.c +0 -97
  221. package/deps/liburing/liburing/test/self.c +0 -91
  222. package/deps/liburing/liburing/test/send_recv.c +0 -291
  223. package/deps/liburing/liburing/test/send_recvmsg.c +0 -345
  224. package/deps/liburing/liburing/test/sendmsg_fs_cve.c +0 -198
  225. package/deps/liburing/liburing/test/shared-wq.c +0 -84
  226. package/deps/liburing/liburing/test/short-read.c +0 -75
  227. package/deps/liburing/liburing/test/shutdown.c +0 -163
  228. package/deps/liburing/liburing/test/sigfd-deadlock.c +0 -74
  229. package/deps/liburing/liburing/test/socket-rw-eagain.c +0 -156
  230. package/deps/liburing/liburing/test/socket-rw.c +0 -147
  231. package/deps/liburing/liburing/test/splice.c +0 -511
  232. package/deps/liburing/liburing/test/sq-full-cpp.cc +0 -45
  233. package/deps/liburing/liburing/test/sq-full.c +0 -45
  234. package/deps/liburing/liburing/test/sq-poll-dup.c +0 -200
  235. package/deps/liburing/liburing/test/sq-poll-kthread.c +0 -168
  236. package/deps/liburing/liburing/test/sq-poll-share.c +0 -137
  237. package/deps/liburing/liburing/test/sq-space_left.c +0 -159
  238. package/deps/liburing/liburing/test/sqpoll-cancel-hang.c +0 -159
  239. package/deps/liburing/liburing/test/sqpoll-disable-exit.c +0 -195
  240. package/deps/liburing/liburing/test/sqpoll-exit-hang.c +0 -77
  241. package/deps/liburing/liburing/test/sqpoll-sleep.c +0 -68
  242. package/deps/liburing/liburing/test/statx.c +0 -172
  243. package/deps/liburing/liburing/test/stdout.c +0 -232
  244. package/deps/liburing/liburing/test/submit-link-fail.c +0 -154
  245. package/deps/liburing/liburing/test/submit-reuse.c +0 -239
  246. package/deps/liburing/liburing/test/symlink.c +0 -116
  247. package/deps/liburing/liburing/test/teardowns.c +0 -58
  248. package/deps/liburing/liburing/test/thread-exit.c +0 -131
  249. package/deps/liburing/liburing/test/timeout-new.c +0 -246
  250. package/deps/liburing/liburing/test/timeout-overflow.c +0 -204
  251. package/deps/liburing/liburing/test/timeout.c +0 -1354
  252. package/deps/liburing/liburing/test/unlink.c +0 -111
  253. package/deps/liburing/liburing/test/wakeup-hang.c +0 -162
  254. package/deps/rocksdb/rocksdb/README.md +0 -32
  255. package/deps/rocksdb/rocksdb/microbench/README.md +0 -60
  256. package/deps/rocksdb/rocksdb/plugin/README.md +0 -43
  257. package/deps/rocksdb/rocksdb/port/README +0 -10
  258. package/deps/rocksdb/rocksdb/table/block_based/block_based_filter_block.cc +0 -358
  259. package/deps/rocksdb/rocksdb/table/block_based/block_based_filter_block.h +0 -127
  260. package/deps/rocksdb/rocksdb/table/block_based/block_based_filter_block_test.cc +0 -219
  261. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/README +0 -13
@@ -1,664 +0,0 @@
1
- /* SPDX-License-Identifier: MIT */
2
- /*
3
- * io_uring_register.c
4
- *
5
- * Description: Unit tests for the io_uring_register system call.
6
- *
7
- * Copyright 2019, Red Hat, Inc.
8
- * Author: Jeff Moyer <jmoyer@redhat.com>
9
- */
10
- #include <stdio.h>
11
- #include <fcntl.h>
12
- #include <string.h>
13
- #include <stdlib.h>
14
- #include <unistd.h>
15
- #include <errno.h>
16
- #include <sys/sysinfo.h>
17
- #include <poll.h>
18
- #include <assert.h>
19
- #include <sys/uio.h>
20
- #include <sys/mman.h>
21
- #include <linux/mman.h>
22
- #include <sys/time.h>
23
- #include <sys/resource.h>
24
- #include <limits.h>
25
-
26
- #include "helpers.h"
27
- #include "liburing.h"
28
- #include "../src/syscall.h"
29
-
30
- static int pagesize;
31
- static rlim_t mlock_limit;
32
- static int devnull;
33
-
34
- int
35
- expect_fail(int fd, unsigned int opcode, void *arg,
36
- unsigned int nr_args, int error)
37
- {
38
- int ret;
39
-
40
- printf("io_uring_register(%d, %u, %p, %u)\n",
41
- fd, opcode, arg, nr_args);
42
- ret = __sys_io_uring_register(fd, opcode, arg, nr_args);
43
- if (ret != -1) {
44
- int ret2 = 0;
45
-
46
- printf("expected %s, but call succeeded\n", strerror(error));
47
- if (opcode == IORING_REGISTER_BUFFERS) {
48
- ret2 = __sys_io_uring_register(fd,
49
- IORING_UNREGISTER_BUFFERS, 0, 0);
50
- } else if (opcode == IORING_REGISTER_FILES) {
51
- ret2 = __sys_io_uring_register(fd,
52
- IORING_UNREGISTER_FILES, 0, 0);
53
- }
54
- if (ret2) {
55
- printf("internal error: failed to unregister\n");
56
- exit(1);
57
- }
58
- return 1;
59
- }
60
-
61
- if (errno != error) {
62
- printf("expected %d, got %d\n", error, errno);
63
- return 1;
64
- }
65
- return 0;
66
- }
67
-
68
- int
69
- new_io_uring(int entries, struct io_uring_params *p)
70
- {
71
- int fd;
72
-
73
- fd = __sys_io_uring_setup(entries, p);
74
- if (fd < 0) {
75
- perror("io_uring_setup");
76
- exit(1);
77
- }
78
- return fd;
79
- }
80
-
81
- #define MAXFDS (UINT_MAX * sizeof(int))
82
-
83
- void *
84
- map_filebacked(size_t size)
85
- {
86
- int fd, ret;
87
- void *addr;
88
- char template[32] = "io_uring_register-test-XXXXXXXX";
89
-
90
- fd = mkstemp(template);
91
- if (fd < 0) {
92
- perror("mkstemp");
93
- return NULL;
94
- }
95
- unlink(template);
96
-
97
- ret = ftruncate(fd, size);
98
- if (ret < 0) {
99
- perror("ftruncate");
100
- close(fd);
101
- return NULL;
102
- }
103
-
104
- addr = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
105
- if (addr == MAP_FAILED) {
106
- perror("mmap");
107
- close(fd);
108
- return NULL;
109
- }
110
-
111
- close(fd);
112
- return addr;
113
- }
114
-
115
- /*
116
- * NOTE: this is now limited by SCM_MAX_FD (253). Keep the code for now,
117
- * but probably should augment it to test 253 and 254, specifically.
118
- */
119
- int
120
- test_max_fds(int uring_fd)
121
- {
122
- int status = 1;
123
- int ret;
124
- void *fd_as; /* file descriptor address space */
125
- int fdtable_fd; /* fd for the file that will be mapped over and over */
126
- int io_fd; /* the valid fd for I/O -- /dev/null */
127
- int *fds; /* used to map the file into the address space */
128
- char template[32] = "io_uring_register-test-XXXXXXXX";
129
- unsigned long long i, nr_maps, nr_fds;
130
-
131
- /*
132
- * First, mmap anonymous the full size. That will guarantee the
133
- * mapping will fit in the memory area selected by mmap. Then,
134
- * over-write that mapping using a file-backed mapping, 128MiB at
135
- * a time using MAP_FIXED.
136
- */
137
- fd_as = mmap(NULL, UINT_MAX * sizeof(int), PROT_READ|PROT_WRITE,
138
- MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
139
- if (fd_as == MAP_FAILED) {
140
- if (errno == ENOMEM) {
141
- printf("Not enough memory for this test, skipping\n");
142
- return 0;
143
- }
144
- perror("mmap fd_as");
145
- exit(1);
146
- }
147
- printf("allocated %zu bytes of address space\n", UINT_MAX * sizeof(int));
148
-
149
- fdtable_fd = mkstemp(template);
150
- if (fdtable_fd < 0) {
151
- perror("mkstemp");
152
- exit(1);
153
- }
154
- unlink(template);
155
- ret = ftruncate(fdtable_fd, 128*1024*1024);
156
- if (ret < 0) {
157
- perror("ftruncate");
158
- exit(1);
159
- }
160
-
161
- io_fd = open("/dev/null", O_RDWR);
162
- if (io_fd < 0) {
163
- perror("open /dev/null");
164
- exit(1);
165
- }
166
- fds = mmap(fd_as, 128*1024*1024, PROT_READ|PROT_WRITE,
167
- MAP_SHARED|MAP_FIXED, fdtable_fd, 0);
168
- if (fds == MAP_FAILED) {
169
- perror("mmap fdtable");
170
- exit(1);
171
- }
172
-
173
- /* fill the fd table */
174
- nr_fds = 128*1024*1024 / sizeof(int);
175
- for (i = 0; i < nr_fds; i++)
176
- fds[i] = io_fd;
177
-
178
- /* map the file through the rest of the address space */
179
- nr_maps = (UINT_MAX * sizeof(int)) / (128*1024*1024);
180
- for (i = 0; i < nr_maps; i++) {
181
- fds = &fds[nr_fds]; /* advance fds by 128MiB */
182
- fds = mmap(fds, 128*1024*1024, PROT_READ|PROT_WRITE,
183
- MAP_SHARED|MAP_FIXED, fdtable_fd, 0);
184
- if (fds == MAP_FAILED) {
185
- printf("mmap failed at offset %lu\n",
186
- (unsigned long)((char *)fd_as - (char *)fds));
187
- exit(1);
188
- }
189
- }
190
-
191
- /* Now fd_as points to the file descriptor array. */
192
- /*
193
- * We may not be able to map all of these files. Let's back off
194
- * until success.
195
- */
196
- nr_fds = UINT_MAX;
197
- while (nr_fds) {
198
- ret = __sys_io_uring_register(uring_fd, IORING_REGISTER_FILES,
199
- fd_as, nr_fds);
200
- if (ret != 0) {
201
- nr_fds /= 2;
202
- continue;
203
- }
204
- printf("io_uring_register(%d, IORING_REGISTER_FILES, %p, %llu)"
205
- "...succeeded\n", uring_fd, fd_as, nr_fds);
206
- status = 0;
207
- printf("io_uring_register(%d, IORING_UNREGISTER_FILES, 0, 0)...",
208
- uring_fd);
209
- ret = __sys_io_uring_register(uring_fd, IORING_UNREGISTER_FILES,
210
- 0, 0);
211
- if (ret < 0) {
212
- ret = errno;
213
- printf("failed\n");
214
- errno = ret;
215
- perror("io_uring_register UNREGISTER_FILES");
216
- exit(1);
217
- }
218
- printf("succeeded\n");
219
- break;
220
- }
221
-
222
- close(io_fd);
223
- close(fdtable_fd);
224
- ret = munmap(fd_as, UINT_MAX * sizeof(int));
225
- if (ret != 0) {
226
- printf("munmap(%zu) failed\n", UINT_MAX * sizeof(int));
227
- exit(1);
228
- }
229
-
230
- return status;
231
- }
232
-
233
- int
234
- test_memlock_exceeded(int fd)
235
- {
236
- int ret;
237
- void *buf;
238
- struct iovec iov;
239
-
240
- /* if limit is larger than 2gb, just skip this test */
241
- if (mlock_limit >= 2 * 1024 * 1024 * 1024ULL)
242
- return 0;
243
-
244
- iov.iov_len = mlock_limit * 2;
245
- buf = t_malloc(iov.iov_len);
246
- iov.iov_base = buf;
247
-
248
- while (iov.iov_len) {
249
- ret = __sys_io_uring_register(fd, IORING_REGISTER_BUFFERS, &iov, 1);
250
- if (ret < 0) {
251
- if (errno == ENOMEM) {
252
- printf("io_uring_register of %zu bytes failed "
253
- "with ENOMEM (expected).\n", iov.iov_len);
254
- iov.iov_len /= 2;
255
- continue;
256
- }
257
- if (errno == EFAULT) {
258
- free(buf);
259
- return 0;
260
- }
261
- printf("expected success or EFAULT, got %d\n", errno);
262
- free(buf);
263
- return 1;
264
- }
265
- printf("successfully registered %zu bytes (%d).\n",
266
- iov.iov_len, ret);
267
- ret = __sys_io_uring_register(fd, IORING_UNREGISTER_BUFFERS,
268
- NULL, 0);
269
- if (ret != 0) {
270
- printf("error: unregister failed with %d\n", errno);
271
- free(buf);
272
- return 1;
273
- }
274
- break;
275
- }
276
- if (!iov.iov_len)
277
- printf("Unable to register buffers. Check memlock rlimit.\n");
278
-
279
- free(buf);
280
- return 0;
281
- }
282
-
283
- int
284
- test_iovec_nr(int fd)
285
- {
286
- int i, ret, status = 0;
287
- unsigned int nr = 1000000;
288
- struct iovec *iovs;
289
- void *buf;
290
-
291
- iovs = malloc(nr * sizeof(struct iovec));
292
- if (!iovs) {
293
- fprintf(stdout, "can't allocate iovecs, skip\n");
294
- return 0;
295
- }
296
- buf = t_malloc(pagesize);
297
-
298
- for (i = 0; i < nr; i++) {
299
- iovs[i].iov_base = buf;
300
- iovs[i].iov_len = pagesize;
301
- }
302
-
303
- status |= expect_fail(fd, IORING_REGISTER_BUFFERS, iovs, nr, EINVAL);
304
-
305
- /* reduce to UIO_MAXIOV */
306
- nr = UIO_MAXIOV;
307
- printf("io_uring_register(%d, %u, %p, %u)\n",
308
- fd, IORING_REGISTER_BUFFERS, iovs, nr);
309
- ret = __sys_io_uring_register(fd, IORING_REGISTER_BUFFERS, iovs, nr);
310
- if (ret && (errno == ENOMEM || errno == EPERM) && geteuid()) {
311
- printf("can't register large iovec for regular users, skip\n");
312
- } else if (ret != 0) {
313
- printf("expected success, got %d\n", errno);
314
- status = 1;
315
- } else {
316
- __sys_io_uring_register(fd, IORING_UNREGISTER_BUFFERS, 0, 0);
317
- }
318
- free(buf);
319
- free(iovs);
320
- return status;
321
- }
322
-
323
- /*
324
- * io_uring limit is 1G. iov_len limit is ~OUL, I think
325
- */
326
- int
327
- test_iovec_size(int fd)
328
- {
329
- unsigned int status = 0;
330
- int ret;
331
- struct iovec iov;
332
- void *buf;
333
-
334
- /* NULL pointer for base */
335
- iov.iov_base = 0;
336
- iov.iov_len = 4096;
337
- status |= expect_fail(fd, IORING_REGISTER_BUFFERS, &iov, 1, EFAULT);
338
-
339
- /* valid base, 0 length */
340
- iov.iov_base = &buf;
341
- iov.iov_len = 0;
342
- status |= expect_fail(fd, IORING_REGISTER_BUFFERS, &iov, 1, EFAULT);
343
-
344
- /* valid base, length exceeds size */
345
- /* this requires an unampped page directly after buf */
346
- buf = mmap(NULL, 2 * pagesize, PROT_READ|PROT_WRITE,
347
- MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
348
- assert(buf != MAP_FAILED);
349
- ret = munmap(buf + pagesize, pagesize);
350
- assert(ret == 0);
351
- iov.iov_base = buf;
352
- iov.iov_len = 2 * pagesize;
353
- status |= expect_fail(fd, IORING_REGISTER_BUFFERS, &iov, 1, EFAULT);
354
- munmap(buf, pagesize);
355
-
356
- /* huge page */
357
- buf = mmap(NULL, 2*1024*1024, PROT_READ|PROT_WRITE,
358
- MAP_PRIVATE | MAP_HUGETLB | MAP_HUGE_2MB | MAP_ANONYMOUS,
359
- -1, 0);
360
- if (buf == MAP_FAILED) {
361
- printf("Unable to map a huge page. Try increasing "
362
- "/proc/sys/vm/nr_hugepages by at least 1.\n");
363
- printf("Skipping the hugepage test\n");
364
- } else {
365
- /*
366
- * This should succeed, so long as RLIMIT_MEMLOCK is
367
- * not exceeded
368
- */
369
- iov.iov_base = buf;
370
- iov.iov_len = 2*1024*1024;
371
- ret = __sys_io_uring_register(fd, IORING_REGISTER_BUFFERS, &iov, 1);
372
- if (ret < 0) {
373
- if (errno == ENOMEM)
374
- printf("Unable to test registering of a huge "
375
- "page. Try increasing the "
376
- "RLIMIT_MEMLOCK resource limit by at "
377
- "least 2MB.");
378
- else {
379
- printf("expected success, got %d\n", errno);
380
- status = 1;
381
- }
382
- } else {
383
- printf("Success!\n");
384
- ret = __sys_io_uring_register(fd,
385
- IORING_UNREGISTER_BUFFERS, 0, 0);
386
- if (ret < 0) {
387
- perror("io_uring_unregister");
388
- status = 1;
389
- }
390
- }
391
- }
392
- ret = munmap(iov.iov_base, iov.iov_len);
393
- assert(ret == 0);
394
-
395
- /* file-backed buffers -- not supported */
396
- buf = map_filebacked(2*1024*1024);
397
- if (!buf)
398
- status = 1;
399
- iov.iov_base = buf;
400
- iov.iov_len = 2*1024*1024;
401
- printf("reserve file-backed buffers\n");
402
- status |= expect_fail(fd, IORING_REGISTER_BUFFERS, &iov, 1, EOPNOTSUPP);
403
- munmap(buf, 2*1024*1024);
404
-
405
- /* bump up against the soft limit and make sure we get EFAULT
406
- * or whatever we're supposed to get. NOTE: this requires
407
- * running the test as non-root. */
408
- if (getuid() != 0)
409
- status |= test_memlock_exceeded(fd);
410
-
411
- return status;
412
- }
413
-
414
- void
415
- dump_sqe(struct io_uring_sqe *sqe)
416
- {
417
- printf("\topcode: %d\n", sqe->opcode);
418
- printf("\tflags: 0x%.8x\n", sqe->flags);
419
- printf("\tfd: %d\n", sqe->fd);
420
- if (sqe->opcode == IORING_OP_POLL_ADD)
421
- printf("\tpoll_events: 0x%.8x\n", sqe->poll_events);
422
- }
423
-
424
- int
425
- ioring_poll(struct io_uring *ring, int fd, int fixed)
426
- {
427
- int ret;
428
- struct io_uring_sqe *sqe;
429
- struct io_uring_cqe *cqe;
430
-
431
- sqe = io_uring_get_sqe(ring);
432
- memset(sqe, 0, sizeof(*sqe));
433
- sqe->opcode = IORING_OP_POLL_ADD;
434
- if (fixed)
435
- sqe->flags = IOSQE_FIXED_FILE;
436
- sqe->fd = fd;
437
- sqe->poll_events = POLLIN|POLLOUT;
438
-
439
- printf("io_uring_submit:\n");
440
- dump_sqe(sqe);
441
- ret = io_uring_submit(ring);
442
- if (ret != 1) {
443
- printf("failed to submit poll sqe: %d.\n", errno);
444
- return 1;
445
- }
446
-
447
- ret = io_uring_wait_cqe(ring, &cqe);
448
- if (ret < 0) {
449
- printf("io_uring_wait_cqe failed with %d\n", ret);
450
- return 1;
451
- }
452
- ret = 0;
453
- if (cqe->res != POLLOUT) {
454
- printf("io_uring_wait_cqe: expected 0x%.8x, got 0x%.8x\n",
455
- POLLOUT, cqe->res);
456
- ret = 1;
457
- }
458
-
459
- io_uring_cqe_seen(ring, cqe);
460
- return ret;
461
- }
462
-
463
- int
464
- test_poll_ringfd(void)
465
- {
466
- int status = 0;
467
- int ret;
468
- int fd;
469
- struct io_uring ring;
470
-
471
- ret = io_uring_queue_init(1, &ring, 0);
472
- if (ret) {
473
- perror("io_uring_queue_init");
474
- return 1;
475
- }
476
- fd = ring.ring_fd;
477
-
478
- /* try polling the ring fd */
479
- status = ioring_poll(&ring, fd, 0);
480
-
481
- /*
482
- * now register the ring fd, and try the poll again. This should
483
- * fail, because the kernel does not allow registering of the
484
- * ring_fd.
485
- */
486
- status |= expect_fail(fd, IORING_REGISTER_FILES, &fd, 1, EBADF);
487
-
488
- /* tear down queue */
489
- io_uring_queue_exit(&ring);
490
-
491
- return status;
492
- }
493
-
494
- static int test_shmem(void)
495
- {
496
- const char pattern = 0xEA;
497
- const int len = 4096;
498
- struct io_uring_sqe *sqe;
499
- struct io_uring_cqe *cqe;
500
- struct io_uring ring;
501
- struct iovec iov;
502
- int memfd, ret, i;
503
- char *mem;
504
- int pipefd[2] = {-1, -1};
505
-
506
- ret = io_uring_queue_init(8, &ring, 0);
507
- if (ret)
508
- return 1;
509
-
510
- if (pipe(pipefd)) {
511
- perror("pipe");
512
- return 1;
513
- }
514
- memfd = memfd_create("uring-shmem-test", 0);
515
- if (memfd < 0) {
516
- fprintf(stderr, "memfd_create() failed %i\n", -errno);
517
- return 1;
518
- }
519
- if (ftruncate(memfd, len)) {
520
- fprintf(stderr, "can't truncate memfd\n");
521
- return 1;
522
- }
523
- mem = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, memfd, 0);
524
- if (!mem) {
525
- fprintf(stderr, "mmap failed\n");
526
- return 1;
527
- }
528
- for (i = 0; i < len; i++)
529
- mem[i] = pattern;
530
-
531
- iov.iov_base = mem;
532
- iov.iov_len = len;
533
- ret = io_uring_register_buffers(&ring, &iov, 1);
534
- if (ret) {
535
- if (ret == -EOPNOTSUPP) {
536
- fprintf(stdout, "memfd registration isn't supported, "
537
- "skip\n");
538
- goto out;
539
- }
540
-
541
- fprintf(stderr, "buffer reg failed: %d\n", ret);
542
- return 1;
543
- }
544
-
545
- /* check that we can read and write from/to shmem reg buffer */
546
- sqe = io_uring_get_sqe(&ring);
547
- io_uring_prep_write_fixed(sqe, pipefd[1], mem, 512, 0, 0);
548
- sqe->user_data = 1;
549
-
550
- ret = io_uring_submit(&ring);
551
- if (ret != 1) {
552
- fprintf(stderr, "submit write failed\n");
553
- return 1;
554
- }
555
- ret = io_uring_wait_cqe(&ring, &cqe);
556
- if (ret < 0 || cqe->user_data != 1 || cqe->res != 512) {
557
- fprintf(stderr, "reading from shmem failed\n");
558
- return 1;
559
- }
560
- io_uring_cqe_seen(&ring, cqe);
561
-
562
- /* clean it, should be populated with the pattern back from the pipe */
563
- memset(mem, 0, 512);
564
- sqe = io_uring_get_sqe(&ring);
565
- io_uring_prep_read_fixed(sqe, pipefd[0], mem, 512, 0, 0);
566
- sqe->user_data = 2;
567
-
568
- ret = io_uring_submit(&ring);
569
- if (ret != 1) {
570
- fprintf(stderr, "submit write failed\n");
571
- return 1;
572
- }
573
- ret = io_uring_wait_cqe(&ring, &cqe);
574
- if (ret < 0 || cqe->user_data != 2 || cqe->res != 512) {
575
- fprintf(stderr, "reading from shmem failed\n");
576
- return 1;
577
- }
578
- io_uring_cqe_seen(&ring, cqe);
579
-
580
- for (i = 0; i < 512; i++) {
581
- if (mem[i] != pattern) {
582
- fprintf(stderr, "data integrity fail\n");
583
- return 1;
584
- }
585
- }
586
-
587
- ret = io_uring_unregister_buffers(&ring);
588
- if (ret) {
589
- fprintf(stderr, "buffer unreg failed: %d\n", ret);
590
- return 1;
591
- }
592
- out:
593
- io_uring_queue_exit(&ring);
594
- close(pipefd[0]);
595
- close(pipefd[1]);
596
- munmap(mem, len);
597
- close(memfd);
598
- return 0;
599
- }
600
-
601
- int
602
- main(int argc, char **argv)
603
- {
604
- int fd, ret;
605
- unsigned int status = 0;
606
- struct io_uring_params p;
607
- struct rlimit rlim;
608
-
609
- if (argc > 1)
610
- return 0;
611
-
612
- /* setup globals */
613
- pagesize = getpagesize();
614
- ret = getrlimit(RLIMIT_MEMLOCK, &rlim);
615
- if (ret < 0) {
616
- perror("getrlimit");
617
- return 1;
618
- }
619
- mlock_limit = rlim.rlim_cur;
620
- printf("RELIMIT_MEMLOCK: %lu (%lu)\n", rlim.rlim_cur, rlim.rlim_max);
621
- devnull = open("/dev/null", O_RDWR);
622
- if (devnull < 0) {
623
- perror("open /dev/null");
624
- exit(1);
625
- }
626
-
627
- /* invalid fd */
628
- status |= expect_fail(-1, 0, NULL, 0, EBADF);
629
- /* valid fd that is not an io_uring fd */
630
- status |= expect_fail(devnull, 0, NULL, 0, EOPNOTSUPP);
631
-
632
- /* invalid opcode */
633
- memset(&p, 0, sizeof(p));
634
- fd = new_io_uring(1, &p);
635
- ret = expect_fail(fd, ~0U, NULL, 0, EINVAL);
636
- if (ret) {
637
- /* if this succeeds, tear down the io_uring instance
638
- * and start clean for the next test. */
639
- close(fd);
640
- fd = new_io_uring(1, &p);
641
- }
642
-
643
- /* IORING_REGISTER_BUFFERS */
644
- status |= test_iovec_size(fd);
645
- status |= test_iovec_nr(fd);
646
- /* IORING_REGISTER_FILES */
647
- status |= test_max_fds(fd);
648
- close(fd);
649
- /* uring poll on the uring fd */
650
- status |= test_poll_ringfd();
651
-
652
- if (!status)
653
- printf("PASS\n");
654
- else
655
- printf("FAIL\n");
656
-
657
- ret = test_shmem();
658
- if (ret) {
659
- fprintf(stderr, "test_shmem() failed\n");
660
- status |= 1;
661
- }
662
-
663
- return status;
664
- }