polyphony 0.94 → 0.95
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +2 -2
- data/.gitignore +3 -3
- data/CHANGELOG.md +14 -0
- data/docs/api-reference/fiber.md +2 -2
- data/docs/api-reference/object.md +3 -3
- data/docs/main-concepts/exception-handling.md +2 -2
- data/ext/polyphony/backend_common.c +3 -3
- data/ext/polyphony/backend_io_uring.c +18 -16
- data/ext/polyphony/event.c +1 -1
- data/ext/polyphony/extconf.rb +5 -3
- data/ext/polyphony/fiber.c +5 -13
- data/ext/polyphony/io_extensions.c +1 -1
- data/ext/polyphony/pipe.c +1 -1
- data/ext/polyphony/polyphony.c +1 -1
- data/ext/polyphony/polyphony_ext.c +1 -1
- data/ext/polyphony/queue.c +1 -1
- data/ext/polyphony/ring_buffer.c +1 -0
- data/ext/polyphony/socket_extensions.c +1 -1
- data/ext/polyphony/thread.c +1 -1
- data/lib/polyphony/extensions/enumerator.rb +16 -0
- data/lib/polyphony/extensions/socket.rb +2 -0
- data/lib/polyphony/extensions.rb +1 -0
- data/lib/polyphony/version.rb +1 -1
- data/polyphony.gemspec +2 -2
- data/test/test_backend.rb +5 -1
- data/test/test_enumerator.rb +46 -0
- data/test/test_io.rb +241 -216
- data/test/test_socket.rb +1 -1
- data/test/test_thread_pool.rb +3 -3
- data/vendor/liburing/.github/workflows/build.yml +51 -5
- data/vendor/liburing/.github/workflows/shellcheck.yml +1 -1
- data/vendor/liburing/.gitignore +6 -123
- data/vendor/liburing/CHANGELOG +35 -0
- data/vendor/liburing/CITATION.cff +11 -0
- data/vendor/liburing/LICENSE +16 -3
- data/vendor/liburing/Makefile +3 -1
- data/vendor/liburing/Makefile.common +1 -0
- data/vendor/liburing/README +14 -2
- data/vendor/liburing/SECURITY.md +6 -0
- data/vendor/liburing/configure +16 -15
- data/vendor/liburing/examples/Makefile +4 -1
- data/vendor/liburing/examples/io_uring-udp.c +395 -0
- data/vendor/liburing/examples/poll-bench.c +101 -0
- data/vendor/liburing/examples/send-zerocopy.c +339 -0
- data/vendor/liburing/liburing.spec +1 -1
- data/vendor/liburing/man/io_uring.7 +38 -11
- data/vendor/liburing/man/io_uring_buf_ring_add.3 +53 -0
- data/vendor/liburing/man/io_uring_buf_ring_advance.3 +31 -0
- data/vendor/liburing/man/io_uring_buf_ring_cq_advance.3 +41 -0
- data/vendor/liburing/man/io_uring_buf_ring_init.3 +30 -0
- data/vendor/liburing/man/io_uring_buf_ring_mask.3 +27 -0
- data/vendor/liburing/man/io_uring_cq_advance.3 +29 -15
- data/vendor/liburing/man/io_uring_cq_has_overflow.3 +25 -0
- data/vendor/liburing/man/io_uring_cq_ready.3 +9 -8
- data/vendor/liburing/man/io_uring_cqe_get_data.3 +32 -13
- data/vendor/liburing/man/io_uring_cqe_get_data64.3 +1 -0
- data/vendor/liburing/man/io_uring_cqe_seen.3 +22 -12
- data/vendor/liburing/man/io_uring_enter.2 +249 -32
- data/vendor/liburing/man/io_uring_enter2.2 +1 -0
- data/vendor/liburing/man/io_uring_free_probe.3 +11 -8
- data/vendor/liburing/man/io_uring_get_events.3 +33 -0
- data/vendor/liburing/man/io_uring_get_probe.3 +9 -8
- data/vendor/liburing/man/io_uring_get_sqe.3 +29 -10
- data/vendor/liburing/man/io_uring_opcode_supported.3 +11 -10
- data/vendor/liburing/man/io_uring_peek_cqe.3 +38 -0
- data/vendor/liburing/man/io_uring_prep_accept.3 +197 -0
- data/vendor/liburing/man/io_uring_prep_accept_direct.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_cancel.3 +118 -0
- data/vendor/liburing/man/io_uring_prep_cancel64.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_close.3 +59 -0
- data/vendor/liburing/man/io_uring_prep_close_direct.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_connect.3 +66 -0
- data/vendor/liburing/man/io_uring_prep_fadvise.3 +59 -0
- data/vendor/liburing/man/io_uring_prep_fallocate.3 +59 -0
- data/vendor/liburing/man/io_uring_prep_files_update.3 +92 -0
- data/vendor/liburing/man/io_uring_prep_fsync.3 +70 -0
- data/vendor/liburing/man/io_uring_prep_link.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_linkat.3 +91 -0
- data/vendor/liburing/man/io_uring_prep_madvise.3 +56 -0
- data/vendor/liburing/man/io_uring_prep_mkdir.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_mkdirat.3 +83 -0
- data/vendor/liburing/man/io_uring_prep_msg_ring.3 +39 -25
- data/vendor/liburing/man/io_uring_prep_multishot_accept.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_multishot_accept_direct.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_nop.3 +28 -0
- data/vendor/liburing/man/io_uring_prep_openat.3 +117 -0
- data/vendor/liburing/man/io_uring_prep_openat2.3 +117 -0
- data/vendor/liburing/man/io_uring_prep_openat2_direct.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_openat_direct.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_poll_add.3 +72 -0
- data/vendor/liburing/man/io_uring_prep_poll_multishot.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_poll_remove.3 +55 -0
- data/vendor/liburing/man/io_uring_prep_poll_update.3 +89 -0
- data/vendor/liburing/man/io_uring_prep_provide_buffers.3 +131 -0
- data/vendor/liburing/man/io_uring_prep_read.3 +33 -14
- data/vendor/liburing/man/io_uring_prep_read_fixed.3 +39 -21
- data/vendor/liburing/man/io_uring_prep_readv.3 +49 -15
- data/vendor/liburing/man/io_uring_prep_readv2.3 +49 -17
- data/vendor/liburing/man/io_uring_prep_recv.3 +105 -0
- data/vendor/liburing/man/io_uring_prep_recv_multishot.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_recvmsg.3 +124 -0
- data/vendor/liburing/man/io_uring_prep_recvmsg_multishot.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_remove_buffers.3 +52 -0
- data/vendor/liburing/man/io_uring_prep_rename.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_renameat.3 +96 -0
- data/vendor/liburing/man/io_uring_prep_send.3 +57 -0
- data/vendor/liburing/man/io_uring_prep_send_zc.3 +64 -0
- data/vendor/liburing/man/io_uring_prep_sendmsg.3 +69 -0
- data/vendor/liburing/man/io_uring_prep_shutdown.3 +53 -0
- data/vendor/liburing/man/io_uring_prep_socket.3 +118 -0
- data/vendor/liburing/man/io_uring_prep_socket_direct.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_socket_direct_alloc.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_splice.3 +80 -0
- data/vendor/liburing/man/io_uring_prep_statx.3 +74 -0
- data/vendor/liburing/man/io_uring_prep_symlink.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_symlinkat.3 +85 -0
- data/vendor/liburing/man/io_uring_prep_sync_file_range.3 +59 -0
- data/vendor/liburing/man/io_uring_prep_tee.3 +74 -0
- data/vendor/liburing/man/io_uring_prep_timeout.3 +95 -0
- data/vendor/liburing/man/io_uring_prep_timeout_remove.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_timeout_update.3 +98 -0
- data/vendor/liburing/man/io_uring_prep_unlink.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_unlinkat.3 +82 -0
- data/vendor/liburing/man/io_uring_prep_write.3 +32 -15
- data/vendor/liburing/man/io_uring_prep_write_fixed.3 +39 -21
- data/vendor/liburing/man/io_uring_prep_writev.3 +50 -16
- data/vendor/liburing/man/io_uring_prep_writev2.3 +50 -17
- data/vendor/liburing/man/io_uring_queue_exit.3 +3 -4
- data/vendor/liburing/man/io_uring_queue_init.3 +58 -13
- data/vendor/liburing/man/io_uring_queue_init_params.3 +1 -0
- data/vendor/liburing/man/io_uring_recvmsg_cmsg_firsthdr.3 +1 -0
- data/vendor/liburing/man/io_uring_recvmsg_cmsg_nexthdr.3 +1 -0
- data/vendor/liburing/man/io_uring_recvmsg_name.3 +1 -0
- data/vendor/liburing/man/io_uring_recvmsg_out.3 +78 -0
- data/vendor/liburing/man/io_uring_recvmsg_payload.3 +1 -0
- data/vendor/liburing/man/io_uring_recvmsg_payload_length.3 +1 -0
- data/vendor/liburing/man/io_uring_recvmsg_validate.3 +1 -0
- data/vendor/liburing/man/io_uring_register.2 +153 -13
- data/vendor/liburing/man/io_uring_register_buf_ring.3 +140 -0
- data/vendor/liburing/man/io_uring_register_buffers.3 +32 -12
- data/vendor/liburing/man/io_uring_register_eventfd.3 +51 -0
- data/vendor/liburing/man/io_uring_register_eventfd_async.3 +1 -0
- data/vendor/liburing/man/io_uring_register_file_alloc_range.3 +52 -0
- data/vendor/liburing/man/io_uring_register_files.3 +33 -11
- data/vendor/liburing/man/io_uring_register_files_sparse.3 +1 -0
- data/vendor/liburing/man/io_uring_register_iowq_aff.3 +61 -0
- data/vendor/liburing/man/io_uring_register_iowq_max_workers.3 +71 -0
- data/vendor/liburing/man/io_uring_register_ring_fd.3 +49 -0
- data/vendor/liburing/man/io_uring_register_sync_cancel.3 +71 -0
- data/vendor/liburing/man/io_uring_setup.2 +119 -13
- data/vendor/liburing/man/io_uring_sq_ready.3 +14 -8
- data/vendor/liburing/man/io_uring_sq_space_left.3 +9 -9
- data/vendor/liburing/man/io_uring_sqe_set_data.3 +29 -11
- data/vendor/liburing/man/io_uring_sqe_set_data64.3 +1 -0
- data/vendor/liburing/man/io_uring_sqe_set_flags.3 +38 -11
- data/vendor/liburing/man/io_uring_sqring_wait.3 +13 -9
- data/vendor/liburing/man/io_uring_submit.3 +29 -12
- data/vendor/liburing/man/io_uring_submit_and_get_events.3 +31 -0
- data/vendor/liburing/man/io_uring_submit_and_wait.3 +16 -12
- data/vendor/liburing/man/io_uring_submit_and_wait_timeout.3 +30 -23
- data/vendor/liburing/man/io_uring_unregister_buf_ring.3 +30 -0
- data/vendor/liburing/man/io_uring_unregister_buffers.3 +11 -10
- data/vendor/liburing/man/io_uring_unregister_eventfd.3 +1 -0
- data/vendor/liburing/man/io_uring_unregister_files.3 +11 -10
- data/vendor/liburing/man/io_uring_unregister_iowq_aff.3 +1 -0
- data/vendor/liburing/man/io_uring_unregister_ring_fd.3 +32 -0
- data/vendor/liburing/man/io_uring_wait_cqe.3 +19 -12
- data/vendor/liburing/man/io_uring_wait_cqe_nr.3 +21 -14
- data/vendor/liburing/man/io_uring_wait_cqe_timeout.3 +27 -13
- data/vendor/liburing/man/io_uring_wait_cqes.3 +24 -14
- data/vendor/liburing/src/Makefile +8 -7
- data/vendor/liburing/src/arch/aarch64/lib.h +48 -0
- data/vendor/liburing/src/arch/aarch64/syscall.h +0 -4
- data/vendor/liburing/src/arch/generic/lib.h +0 -4
- data/vendor/liburing/src/arch/generic/syscall.h +29 -16
- data/vendor/liburing/src/arch/syscall-defs.h +41 -14
- data/vendor/liburing/src/arch/x86/lib.h +0 -21
- data/vendor/liburing/src/arch/x86/syscall.h +146 -10
- data/vendor/liburing/src/include/liburing/io_uring.h +245 -5
- data/vendor/liburing/src/include/liburing.h +468 -35
- data/vendor/liburing/src/int_flags.h +1 -0
- data/vendor/liburing/src/lib.h +20 -16
- data/vendor/liburing/src/liburing.map +16 -0
- data/vendor/liburing/src/nolibc.c +1 -1
- data/vendor/liburing/src/queue.c +87 -55
- data/vendor/liburing/src/register.c +129 -53
- data/vendor/liburing/src/setup.c +65 -28
- data/vendor/liburing/src/syscall.c +14 -32
- data/vendor/liburing/src/syscall.h +12 -64
- data/vendor/liburing/test/{232c93d07b74-test.c → 232c93d07b74.c} +8 -9
- data/vendor/liburing/test/{35fa71a030ca-test.c → 35fa71a030ca.c} +4 -4
- data/vendor/liburing/test/{500f9fbadef8-test.c → 500f9fbadef8.c} +7 -7
- data/vendor/liburing/test/{7ad0e4b2f83c-test.c → 7ad0e4b2f83c.c} +8 -7
- data/vendor/liburing/test/{8a9973408177-test.c → 8a9973408177.c} +4 -3
- data/vendor/liburing/test/{917257daa0fe-test.c → 917257daa0fe.c} +3 -2
- data/vendor/liburing/test/Makefile +60 -62
- data/vendor/liburing/test/{a0908ae19763-test.c → a0908ae19763.c} +3 -2
- data/vendor/liburing/test/{a4c0b3decb33-test.c → a4c0b3decb33.c} +3 -2
- data/vendor/liburing/test/accept-link.c +5 -4
- data/vendor/liburing/test/accept-reuse.c +17 -16
- data/vendor/liburing/test/accept-test.c +14 -10
- data/vendor/liburing/test/accept.c +529 -107
- data/vendor/liburing/test/across-fork.c +7 -6
- data/vendor/liburing/test/{b19062a56726-test.c → b19062a56726.c} +3 -2
- data/vendor/liburing/test/{b5837bd5311d-test.c → b5837bd5311d.c} +10 -9
- data/vendor/liburing/test/buf-ring.c +420 -0
- data/vendor/liburing/test/{ce593a6c480a-test.c → ce593a6c480a.c} +15 -12
- data/vendor/liburing/test/connect.c +8 -7
- data/vendor/liburing/test/cq-full.c +5 -4
- data/vendor/liburing/test/cq-overflow.c +242 -12
- data/vendor/liburing/test/cq-peek-batch.c +5 -4
- data/vendor/liburing/test/cq-ready.c +5 -4
- data/vendor/liburing/test/cq-size.c +5 -4
- data/vendor/liburing/test/{d4ae271dfaae-test.c → d4ae271dfaae.c} +2 -2
- data/vendor/liburing/test/{d77a67ed5f27-test.c → d77a67ed5f27.c} +6 -6
- data/vendor/liburing/test/defer-taskrun.c +336 -0
- data/vendor/liburing/test/defer.c +26 -14
- data/vendor/liburing/test/double-poll-crash.c +15 -5
- data/vendor/liburing/test/drop-submit.c +5 -3
- data/vendor/liburing/test/{eeed8b54e0df-test.c → eeed8b54e0df.c} +7 -6
- data/vendor/liburing/test/empty-eownerdead.c +4 -4
- data/vendor/liburing/test/eventfd-disable.c +48 -20
- data/vendor/liburing/test/eventfd-reg.c +10 -9
- data/vendor/liburing/test/eventfd-ring.c +13 -12
- data/vendor/liburing/test/eventfd.c +13 -12
- data/vendor/liburing/test/exit-no-cleanup.c +1 -1
- data/vendor/liburing/test/fadvise.c +3 -3
- data/vendor/liburing/test/fallocate.c +16 -9
- data/vendor/liburing/test/{fc2a85cb02ef-test.c → fc2a85cb02ef.c} +4 -3
- data/vendor/liburing/test/fd-pass.c +187 -0
- data/vendor/liburing/test/file-register.c +302 -36
- data/vendor/liburing/test/file-update.c +62 -4
- data/vendor/liburing/test/file-verify.c +6 -2
- data/vendor/liburing/test/files-exit-hang-poll.c +11 -25
- data/vendor/liburing/test/files-exit-hang-timeout.c +13 -10
- data/vendor/liburing/test/fixed-buf-iter.c +115 -0
- data/vendor/liburing/test/fixed-link.c +10 -10
- data/vendor/liburing/test/fixed-reuse.c +160 -0
- data/vendor/liburing/test/fpos.c +6 -3
- data/vendor/liburing/test/fsync.c +3 -3
- data/vendor/liburing/test/hardlink.c +10 -6
- data/vendor/liburing/test/helpers.c +137 -4
- data/vendor/liburing/test/helpers.h +27 -0
- data/vendor/liburing/test/io-cancel.c +16 -11
- data/vendor/liburing/test/io_uring_enter.c +46 -81
- data/vendor/liburing/test/io_uring_passthrough.c +451 -0
- data/vendor/liburing/test/io_uring_register.c +59 -229
- data/vendor/liburing/test/io_uring_setup.c +24 -29
- data/vendor/liburing/test/iopoll-leak.c +85 -0
- data/vendor/liburing/test/iopoll.c +16 -9
- data/vendor/liburing/test/lfs-openat-write.c +3 -1
- data/vendor/liburing/test/link-timeout.c +4 -3
- data/vendor/liburing/test/link.c +8 -7
- data/vendor/liburing/test/madvise.c +2 -2
- data/vendor/liburing/test/mkdir.c +9 -5
- data/vendor/liburing/test/msg-ring.c +46 -20
- data/vendor/liburing/test/multicqes_drain.c +51 -12
- data/vendor/liburing/test/nolibc.c +60 -0
- data/vendor/liburing/test/nop.c +78 -16
- data/vendor/liburing/test/nvme.h +168 -0
- data/vendor/liburing/test/open-direct-link.c +188 -0
- data/vendor/liburing/test/open-direct-pick.c +180 -0
- data/vendor/liburing/test/openat2.c +3 -3
- data/vendor/liburing/test/poll-cancel-all.c +472 -0
- data/vendor/liburing/test/poll-link.c +9 -18
- data/vendor/liburing/test/poll-mshot-overflow.c +162 -0
- data/vendor/liburing/test/poll-mshot-update.c +83 -33
- data/vendor/liburing/test/pollfree.c +2 -2
- data/vendor/liburing/test/read-before-exit.c +112 -0
- data/vendor/liburing/test/read-write.c +83 -1
- data/vendor/liburing/test/recv-msgall-stream.c +398 -0
- data/vendor/liburing/test/recv-msgall.c +265 -0
- data/vendor/liburing/test/recv-multishot.c +505 -0
- data/vendor/liburing/test/rename.c +2 -5
- data/vendor/liburing/test/ring-leak.c +97 -0
- data/vendor/liburing/test/ringbuf-read.c +200 -0
- data/vendor/liburing/test/rsrc_tags.c +25 -13
- data/vendor/liburing/test/runtests-quiet.sh +11 -0
- data/vendor/liburing/test/runtests.sh +18 -20
- data/vendor/liburing/test/rw_merge_test.c +3 -2
- data/vendor/liburing/test/send-zerocopy.c +684 -0
- data/vendor/liburing/test/send_recv.c +49 -2
- data/vendor/liburing/test/send_recvmsg.c +165 -55
- data/vendor/liburing/test/shutdown.c +3 -4
- data/vendor/liburing/test/sigfd-deadlock.c +22 -8
- data/vendor/liburing/test/single-issuer.c +171 -0
- data/vendor/liburing/test/socket-rw-eagain.c +2 -12
- data/vendor/liburing/test/socket-rw-offset.c +2 -11
- data/vendor/liburing/test/socket-rw.c +2 -11
- data/vendor/liburing/test/socket.c +409 -0
- data/vendor/liburing/test/sq-poll-dup.c +1 -1
- data/vendor/liburing/test/sq-poll-share.c +1 -1
- data/vendor/liburing/test/statx.c +2 -2
- data/vendor/liburing/test/submit-and-wait.c +108 -0
- data/vendor/liburing/test/submit-link-fail.c +5 -3
- data/vendor/liburing/test/submit-reuse.c +0 -2
- data/vendor/liburing/test/sync-cancel.c +235 -0
- data/vendor/liburing/test/test.h +35 -0
- data/vendor/liburing/test/timeout-overflow.c +11 -11
- data/vendor/liburing/test/timeout.c +7 -7
- data/vendor/liburing/test/tty-write-dpoll.c +60 -0
- data/vendor/liburing/test/unlink.c +1 -1
- data/vendor/liburing/test/xattr.c +425 -0
- metadata +143 -22
- data/Gemfile.lock +0 -78
@@ -0,0 +1,187 @@
|
|
1
|
+
/* SPDX-License-Identifier: MIT */
|
2
|
+
/*
|
3
|
+
* Description: run various fixed file fd passing 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
|
+
#include "helpers.h"
|
15
|
+
|
16
|
+
#define FSIZE 128
|
17
|
+
#define PAT 0x9a
|
18
|
+
|
19
|
+
static int no_fd_pass;
|
20
|
+
|
21
|
+
static int verify_fixed_read(struct io_uring *ring, int fixed_fd, int fail)
|
22
|
+
{
|
23
|
+
struct io_uring_sqe *sqe;
|
24
|
+
struct io_uring_cqe *cqe;
|
25
|
+
unsigned char buf[FSIZE];
|
26
|
+
int i;
|
27
|
+
|
28
|
+
sqe = io_uring_get_sqe(ring);
|
29
|
+
io_uring_prep_read(sqe, fixed_fd, buf, FSIZE, 0);
|
30
|
+
sqe->flags |= IOSQE_FIXED_FILE;
|
31
|
+
io_uring_submit(ring);
|
32
|
+
|
33
|
+
io_uring_wait_cqe(ring, &cqe);
|
34
|
+
if (cqe->res != FSIZE) {
|
35
|
+
if (fail && cqe->res == -EBADF)
|
36
|
+
return 0;
|
37
|
+
fprintf(stderr, "Read: %d\n", cqe->res);
|
38
|
+
return 1;
|
39
|
+
}
|
40
|
+
io_uring_cqe_seen(ring, cqe);
|
41
|
+
|
42
|
+
for (i = 0; i < FSIZE; i++) {
|
43
|
+
if (buf[i] != PAT) {
|
44
|
+
fprintf(stderr, "got %x, wanted %x\n", buf[i], PAT);
|
45
|
+
return 1;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
return 0;
|
50
|
+
}
|
51
|
+
|
52
|
+
static int test(const char *filename)
|
53
|
+
{
|
54
|
+
struct io_uring sring, dring;
|
55
|
+
struct io_uring_sqe *sqe;
|
56
|
+
struct io_uring_cqe *cqe;
|
57
|
+
int ret;
|
58
|
+
|
59
|
+
ret = io_uring_queue_init(8, &sring, 0);
|
60
|
+
if (ret) {
|
61
|
+
fprintf(stderr, "ring setup failed: %d\n", ret);
|
62
|
+
return T_EXIT_FAIL;
|
63
|
+
}
|
64
|
+
ret = io_uring_queue_init(8, &dring, 0);
|
65
|
+
if (ret) {
|
66
|
+
fprintf(stderr, "ring setup failed: %d\n", ret);
|
67
|
+
return T_EXIT_FAIL;
|
68
|
+
}
|
69
|
+
|
70
|
+
ret = io_uring_register_files_sparse(&sring, 8);
|
71
|
+
if (ret) {
|
72
|
+
if (ret == -EINVAL)
|
73
|
+
return T_EXIT_SKIP;
|
74
|
+
fprintf(stderr, "register files failed %d\n", ret);
|
75
|
+
return T_EXIT_FAIL;
|
76
|
+
}
|
77
|
+
ret = io_uring_register_files_sparse(&dring, 8);
|
78
|
+
if (ret) {
|
79
|
+
fprintf(stderr, "register files failed %d\n", ret);
|
80
|
+
return T_EXIT_FAIL;
|
81
|
+
}
|
82
|
+
|
83
|
+
/* open direct descriptor */
|
84
|
+
sqe = io_uring_get_sqe(&sring);
|
85
|
+
io_uring_prep_openat_direct(sqe, AT_FDCWD, filename, 0, 0644, 0);
|
86
|
+
io_uring_submit(&sring);
|
87
|
+
ret = io_uring_wait_cqe(&sring, &cqe);
|
88
|
+
if (ret) {
|
89
|
+
fprintf(stderr, "wait cqe failed %d\n", ret);
|
90
|
+
return T_EXIT_FAIL;
|
91
|
+
}
|
92
|
+
if (cqe->res) {
|
93
|
+
fprintf(stderr, "cqe res %d\n", cqe->res);
|
94
|
+
return T_EXIT_FAIL;
|
95
|
+
}
|
96
|
+
io_uring_cqe_seen(&sring, cqe);
|
97
|
+
|
98
|
+
/* verify data is sane for source ring */
|
99
|
+
if (verify_fixed_read(&sring, 0, 0))
|
100
|
+
return T_EXIT_FAIL;
|
101
|
+
|
102
|
+
/* send direct descriptor to destination ring */
|
103
|
+
sqe = io_uring_get_sqe(&sring);
|
104
|
+
io_uring_prep_msg_ring(sqe, dring.ring_fd, 0, 0x89, 0);
|
105
|
+
sqe->addr = 1;
|
106
|
+
sqe->addr3 = 0;
|
107
|
+
sqe->file_index = 1;
|
108
|
+
io_uring_submit(&sring);
|
109
|
+
|
110
|
+
ret = io_uring_wait_cqe(&sring, &cqe);
|
111
|
+
if (ret) {
|
112
|
+
fprintf(stderr, "wait cqe failed %d\n", ret);
|
113
|
+
return T_EXIT_FAIL;
|
114
|
+
}
|
115
|
+
if (cqe->res) {
|
116
|
+
if (cqe->res == -EINVAL && !no_fd_pass) {
|
117
|
+
no_fd_pass = 1;
|
118
|
+
return T_EXIT_SKIP;
|
119
|
+
}
|
120
|
+
fprintf(stderr, "msg_ring failed %d\n", cqe->res);
|
121
|
+
return T_EXIT_FAIL;
|
122
|
+
}
|
123
|
+
io_uring_cqe_seen(&sring, cqe);
|
124
|
+
|
125
|
+
/* get posted completion for the passing */
|
126
|
+
ret = io_uring_wait_cqe(&dring, &cqe);
|
127
|
+
if (ret) {
|
128
|
+
fprintf(stderr, "wait cqe failed %d\n", ret);
|
129
|
+
return T_EXIT_FAIL;
|
130
|
+
}
|
131
|
+
if (cqe->user_data != 0x89) {
|
132
|
+
fprintf(stderr, "bad user_data %ld\n", (long) cqe->res);
|
133
|
+
return T_EXIT_FAIL;
|
134
|
+
}
|
135
|
+
io_uring_cqe_seen(&dring, cqe);
|
136
|
+
|
137
|
+
/* now verify we can read the sane data from the destination ring */
|
138
|
+
if (verify_fixed_read(&dring, 0, 0))
|
139
|
+
return T_EXIT_FAIL;
|
140
|
+
|
141
|
+
/* close descriptor in source ring */
|
142
|
+
sqe = io_uring_get_sqe(&sring);
|
143
|
+
io_uring_prep_close_direct(sqe, 0);
|
144
|
+
io_uring_submit(&sring);
|
145
|
+
|
146
|
+
ret = io_uring_wait_cqe(&sring, &cqe);
|
147
|
+
if (ret) {
|
148
|
+
fprintf(stderr, "wait cqe failed %d\n", ret);
|
149
|
+
return T_EXIT_FAIL;
|
150
|
+
}
|
151
|
+
if (cqe->res) {
|
152
|
+
fprintf(stderr, "direct close failed %d\n", cqe->res);
|
153
|
+
return T_EXIT_FAIL;
|
154
|
+
}
|
155
|
+
io_uring_cqe_seen(&sring, cqe);
|
156
|
+
|
157
|
+
/* check that source ring fails after close */
|
158
|
+
if (verify_fixed_read(&sring, 0, 1))
|
159
|
+
return T_EXIT_FAIL;
|
160
|
+
|
161
|
+
/* check we can still read from destination ring */
|
162
|
+
if (verify_fixed_read(&dring, 0, 0))
|
163
|
+
return T_EXIT_FAIL;
|
164
|
+
|
165
|
+
return T_EXIT_PASS;
|
166
|
+
}
|
167
|
+
|
168
|
+
int main(int argc, char *argv[])
|
169
|
+
{
|
170
|
+
char fname[80];
|
171
|
+
int ret;
|
172
|
+
|
173
|
+
if (argc > 1)
|
174
|
+
return T_EXIT_SKIP;
|
175
|
+
|
176
|
+
sprintf(fname, ".fd-pass.%d", getpid());
|
177
|
+
t_create_file_pattern(fname, FSIZE, PAT);
|
178
|
+
|
179
|
+
ret = test(fname);
|
180
|
+
if (ret == T_EXIT_FAIL) {
|
181
|
+
fprintf(stderr, "test failed\n");
|
182
|
+
ret = T_EXIT_FAIL;
|
183
|
+
}
|
184
|
+
|
185
|
+
unlink(fname);
|
186
|
+
return ret;
|
187
|
+
}
|
@@ -9,6 +9,7 @@
|
|
9
9
|
#include <stdlib.h>
|
10
10
|
#include <string.h>
|
11
11
|
#include <fcntl.h>
|
12
|
+
#include <limits.h>
|
12
13
|
#include <sys/resource.h>
|
13
14
|
|
14
15
|
#include "helpers.h"
|
@@ -305,7 +306,7 @@ static int test_sparse(struct io_uring *ring)
|
|
305
306
|
ret = io_uring_register_files(ring, files, 200);
|
306
307
|
if (ret) {
|
307
308
|
if (ret == -EBADF) {
|
308
|
-
fprintf(stdout, "Sparse files not supported\n");
|
309
|
+
fprintf(stdout, "Sparse files not supported, skipping\n");
|
309
310
|
no_update = 1;
|
310
311
|
goto done;
|
311
312
|
}
|
@@ -745,7 +746,254 @@ static int test_fixed_removal_ordering(void)
|
|
745
746
|
return 0;
|
746
747
|
}
|
747
748
|
|
749
|
+
/* mix files requiring SCM-accounting and not in a single register */
|
750
|
+
static int test_mixed_af_unix(void)
|
751
|
+
{
|
752
|
+
struct io_uring ring;
|
753
|
+
int i, ret, fds[2];
|
754
|
+
int reg_fds[32];
|
755
|
+
int sp[2];
|
756
|
+
|
757
|
+
ret = io_uring_queue_init(8, &ring, 0);
|
758
|
+
if (ret < 0) {
|
759
|
+
fprintf(stderr, "failed to init io_uring: %s\n", strerror(-ret));
|
760
|
+
return ret;
|
761
|
+
}
|
762
|
+
if (pipe(fds)) {
|
763
|
+
perror("pipe");
|
764
|
+
return -1;
|
765
|
+
}
|
766
|
+
if (socketpair(AF_UNIX, SOCK_DGRAM, 0, sp) != 0) {
|
767
|
+
perror("Failed to create Unix-domain socket pair\n");
|
768
|
+
return 1;
|
769
|
+
}
|
770
|
+
|
771
|
+
for (i = 0; i < 16; i++) {
|
772
|
+
reg_fds[i * 2] = fds[0];
|
773
|
+
reg_fds[i * 2 + 1] = sp[0];
|
774
|
+
}
|
775
|
+
|
776
|
+
ret = io_uring_register_files(&ring, reg_fds, 32);
|
777
|
+
if (ret) {
|
778
|
+
fprintf(stderr, "file_register: %d\n", ret);
|
779
|
+
return ret;
|
780
|
+
}
|
781
|
+
|
782
|
+
close(fds[0]);
|
783
|
+
close(fds[1]);
|
784
|
+
close(sp[0]);
|
785
|
+
close(sp[1]);
|
786
|
+
io_uring_queue_exit(&ring);
|
787
|
+
return 0;
|
788
|
+
}
|
789
|
+
|
790
|
+
static int test_partial_register_fail(void)
|
791
|
+
{
|
792
|
+
char buffer[128];
|
793
|
+
struct io_uring ring;
|
794
|
+
int ret, fds[2];
|
795
|
+
int reg_fds[5];
|
748
796
|
|
797
|
+
ret = io_uring_queue_init(8, &ring, 0);
|
798
|
+
if (ret < 0) {
|
799
|
+
fprintf(stderr, "failed to init io_uring: %s\n", strerror(-ret));
|
800
|
+
return ret;
|
801
|
+
}
|
802
|
+
if (pipe(fds)) {
|
803
|
+
perror("pipe");
|
804
|
+
return -1;
|
805
|
+
}
|
806
|
+
|
807
|
+
/*
|
808
|
+
* Expect register to fail as it doesn't support io_uring fds, shouldn't
|
809
|
+
* leave any fds referenced afterwards.
|
810
|
+
*/
|
811
|
+
reg_fds[0] = fds[0];
|
812
|
+
reg_fds[1] = fds[1];
|
813
|
+
reg_fds[2] = -1;
|
814
|
+
reg_fds[3] = ring.ring_fd;
|
815
|
+
reg_fds[4] = -1;
|
816
|
+
ret = io_uring_register_files(&ring, reg_fds, 5);
|
817
|
+
if (!ret) {
|
818
|
+
fprintf(stderr, "file_register unexpectedly succeeded\n");
|
819
|
+
return 1;
|
820
|
+
}
|
821
|
+
|
822
|
+
/* ring should have fds referenced, can close them */
|
823
|
+
close(fds[1]);
|
824
|
+
|
825
|
+
/* confirm that fds[1] is actually close and to ref'ed by io_uring */
|
826
|
+
ret = read(fds[0], buffer, 10);
|
827
|
+
if (ret < 0)
|
828
|
+
perror("read");
|
829
|
+
close(fds[0]);
|
830
|
+
io_uring_queue_exit(&ring);
|
831
|
+
return 0;
|
832
|
+
}
|
833
|
+
|
834
|
+
static int file_update_alloc(struct io_uring *ring, int *fd)
|
835
|
+
{
|
836
|
+
struct io_uring_sqe *sqe;
|
837
|
+
struct io_uring_cqe *cqe;
|
838
|
+
int ret;
|
839
|
+
|
840
|
+
sqe = io_uring_get_sqe(ring);
|
841
|
+
io_uring_prep_files_update(sqe, fd, 1, IORING_FILE_INDEX_ALLOC);
|
842
|
+
|
843
|
+
ret = io_uring_submit(ring);
|
844
|
+
if (ret != 1) {
|
845
|
+
fprintf(stderr, "%s: got %d, wanted 1\n", __FUNCTION__, ret);
|
846
|
+
return -1;
|
847
|
+
}
|
848
|
+
|
849
|
+
ret = io_uring_wait_cqe(ring, &cqe);
|
850
|
+
if (ret < 0) {
|
851
|
+
fprintf(stderr, "%s: io_uring_wait_cqe=%d\n", __FUNCTION__, ret);
|
852
|
+
return -1;
|
853
|
+
}
|
854
|
+
ret = cqe->res;
|
855
|
+
io_uring_cqe_seen(ring, cqe);
|
856
|
+
return ret;
|
857
|
+
}
|
858
|
+
|
859
|
+
static int test_out_of_range_file_ranges(struct io_uring *ring)
|
860
|
+
{
|
861
|
+
int ret;
|
862
|
+
|
863
|
+
ret = io_uring_register_file_alloc_range(ring, 8, 3);
|
864
|
+
if (ret != -EINVAL) {
|
865
|
+
fprintf(stderr, "overlapping range %i\n", ret);
|
866
|
+
return 1;
|
867
|
+
}
|
868
|
+
|
869
|
+
ret = io_uring_register_file_alloc_range(ring, 10, 1);
|
870
|
+
if (ret != -EINVAL) {
|
871
|
+
fprintf(stderr, "out of range index %i\n", ret);
|
872
|
+
return 1;
|
873
|
+
}
|
874
|
+
|
875
|
+
ret = io_uring_register_file_alloc_range(ring, 7, ~1U);
|
876
|
+
if (ret != -EOVERFLOW) {
|
877
|
+
fprintf(stderr, "overflow %i\n", ret);
|
878
|
+
return 1;
|
879
|
+
}
|
880
|
+
|
881
|
+
return 0;
|
882
|
+
}
|
883
|
+
|
884
|
+
static int test_overallocating_file_range(struct io_uring *ring, int fds[2])
|
885
|
+
{
|
886
|
+
int roff = 7, rlen = 2;
|
887
|
+
int ret, i, fd;
|
888
|
+
|
889
|
+
ret = io_uring_register_file_alloc_range(ring, roff, rlen);
|
890
|
+
if (ret) {
|
891
|
+
fprintf(stderr, "io_uring_register_file_alloc_range %i\n", ret);
|
892
|
+
return 1;
|
893
|
+
}
|
894
|
+
|
895
|
+
for (i = 0; i < rlen; i++) {
|
896
|
+
fd = fds[0];
|
897
|
+
ret = file_update_alloc(ring, &fd);
|
898
|
+
if (ret != 1) {
|
899
|
+
fprintf(stderr, "file_update_alloc\n");
|
900
|
+
return 1;
|
901
|
+
}
|
902
|
+
|
903
|
+
if (fd < roff || fd >= roff + rlen) {
|
904
|
+
fprintf(stderr, "invalid off result %i\n", fd);
|
905
|
+
return 1;
|
906
|
+
}
|
907
|
+
}
|
908
|
+
|
909
|
+
fd = fds[0];
|
910
|
+
ret = file_update_alloc(ring, &fd);
|
911
|
+
if (ret != -ENFILE) {
|
912
|
+
fprintf(stderr, "overallocated %i, off %i\n", ret, fd);
|
913
|
+
return 1;
|
914
|
+
}
|
915
|
+
|
916
|
+
return 0;
|
917
|
+
}
|
918
|
+
|
919
|
+
static int test_zero_range_alloc(struct io_uring *ring, int fds[2])
|
920
|
+
{
|
921
|
+
int ret, fd;
|
922
|
+
|
923
|
+
ret = io_uring_register_file_alloc_range(ring, 7, 0);
|
924
|
+
if (ret) {
|
925
|
+
fprintf(stderr, "io_uring_register_file_alloc_range failed %i\n", ret);
|
926
|
+
return 1;
|
927
|
+
}
|
928
|
+
|
929
|
+
fd = fds[0];
|
930
|
+
ret = file_update_alloc(ring, &fd);
|
931
|
+
if (ret != -ENFILE) {
|
932
|
+
fprintf(stderr, "zero alloc %i\n", ret);
|
933
|
+
return 1;
|
934
|
+
}
|
935
|
+
return 0;
|
936
|
+
}
|
937
|
+
|
938
|
+
static int test_file_alloc_ranges(void)
|
939
|
+
{
|
940
|
+
struct io_uring ring;
|
941
|
+
int ret, pipe_fds[2];
|
942
|
+
|
943
|
+
if (pipe(pipe_fds)) {
|
944
|
+
fprintf(stderr, "pipes\n");
|
945
|
+
return 1;
|
946
|
+
}
|
947
|
+
ret = io_uring_queue_init(8, &ring, 0);
|
948
|
+
if (ret) {
|
949
|
+
fprintf(stderr, "queue_init: %d\n", ret);
|
950
|
+
return 1;
|
951
|
+
}
|
952
|
+
|
953
|
+
ret = io_uring_register_files_sparse(&ring, 10);
|
954
|
+
if (ret == -EINVAL) {
|
955
|
+
not_supported:
|
956
|
+
close(pipe_fds[0]);
|
957
|
+
close(pipe_fds[1]);
|
958
|
+
io_uring_queue_exit(&ring);
|
959
|
+
printf("file alloc ranges are not supported, skip\n");
|
960
|
+
return 0;
|
961
|
+
} else if (ret) {
|
962
|
+
fprintf(stderr, "io_uring_register_files_sparse %i\n", ret);
|
963
|
+
return ret;
|
964
|
+
}
|
965
|
+
|
966
|
+
ret = io_uring_register_file_alloc_range(&ring, 0, 1);
|
967
|
+
if (ret) {
|
968
|
+
if (ret == -EINVAL)
|
969
|
+
goto not_supported;
|
970
|
+
fprintf(stderr, "io_uring_register_file_alloc_range %i\n", ret);
|
971
|
+
return 1;
|
972
|
+
}
|
973
|
+
|
974
|
+
ret = test_overallocating_file_range(&ring, pipe_fds);
|
975
|
+
if (ret) {
|
976
|
+
fprintf(stderr, "test_overallocating_file_range() failed\n");
|
977
|
+
return 1;
|
978
|
+
}
|
979
|
+
|
980
|
+
ret = test_out_of_range_file_ranges(&ring);
|
981
|
+
if (ret) {
|
982
|
+
fprintf(stderr, "test_out_of_range_file_ranges() failed\n");
|
983
|
+
return 1;
|
984
|
+
}
|
985
|
+
|
986
|
+
ret = test_zero_range_alloc(&ring, pipe_fds);
|
987
|
+
if (ret) {
|
988
|
+
fprintf(stderr, "test_zero_range_alloc() failed\n");
|
989
|
+
return 1;
|
990
|
+
}
|
991
|
+
|
992
|
+
close(pipe_fds[0]);
|
993
|
+
close(pipe_fds[1]);
|
994
|
+
io_uring_queue_exit(&ring);
|
995
|
+
return 0;
|
996
|
+
}
|
749
997
|
|
750
998
|
int main(int argc, char *argv[])
|
751
999
|
{
|
@@ -753,106 +1001,124 @@ int main(int argc, char *argv[])
|
|
753
1001
|
int ret;
|
754
1002
|
|
755
1003
|
if (argc > 1)
|
756
|
-
return
|
1004
|
+
return T_EXIT_SKIP;
|
757
1005
|
|
758
1006
|
ret = io_uring_queue_init(8, &ring, 0);
|
759
1007
|
if (ret) {
|
760
|
-
|
761
|
-
return
|
1008
|
+
fprintf(stderr, "ring setup failed\n");
|
1009
|
+
return T_EXIT_FAIL;
|
762
1010
|
}
|
763
1011
|
|
764
1012
|
ret = test_basic(&ring, 0);
|
765
1013
|
if (ret) {
|
766
|
-
|
767
|
-
return
|
1014
|
+
fprintf(stderr, "test_basic failed\n");
|
1015
|
+
return T_EXIT_FAIL;
|
768
1016
|
}
|
769
1017
|
|
770
1018
|
ret = test_basic(&ring, 1);
|
771
1019
|
if (ret) {
|
772
|
-
|
773
|
-
return
|
1020
|
+
fprintf(stderr, "test_basic failed\n");
|
1021
|
+
return T_EXIT_FAIL;
|
774
1022
|
}
|
775
1023
|
|
776
1024
|
ret = test_basic_many(&ring);
|
777
1025
|
if (ret) {
|
778
|
-
|
779
|
-
return
|
1026
|
+
fprintf(stderr, "test_basic_many failed\n");
|
1027
|
+
return T_EXIT_FAIL;
|
780
1028
|
}
|
781
1029
|
|
782
1030
|
ret = test_sparse(&ring);
|
783
1031
|
if (ret) {
|
784
|
-
|
785
|
-
return
|
1032
|
+
fprintf(stderr, "test_sparse failed\n");
|
1033
|
+
return T_EXIT_FAIL;
|
786
1034
|
}
|
787
1035
|
|
788
1036
|
if (no_update)
|
789
|
-
return
|
1037
|
+
return T_EXIT_SKIP;
|
790
1038
|
|
791
1039
|
ret = test_additions(&ring);
|
792
1040
|
if (ret) {
|
793
|
-
|
794
|
-
return
|
1041
|
+
fprintf(stderr, "test_additions failed\n");
|
1042
|
+
return T_EXIT_FAIL;
|
795
1043
|
}
|
796
1044
|
|
797
1045
|
ret = test_removals(&ring);
|
798
1046
|
if (ret) {
|
799
|
-
|
800
|
-
return
|
1047
|
+
fprintf(stderr, "test_removals failed\n");
|
1048
|
+
return T_EXIT_FAIL;
|
801
1049
|
}
|
802
1050
|
|
803
1051
|
ret = test_replace(&ring);
|
804
1052
|
if (ret) {
|
805
|
-
|
806
|
-
return
|
1053
|
+
fprintf(stderr, "test_replace failed\n");
|
1054
|
+
return T_EXIT_FAIL;
|
807
1055
|
}
|
808
1056
|
|
809
1057
|
ret = test_replace_all(&ring);
|
810
1058
|
if (ret) {
|
811
|
-
|
812
|
-
return
|
1059
|
+
fprintf(stderr, "test_replace_all failed\n");
|
1060
|
+
return T_EXIT_FAIL;
|
813
1061
|
}
|
814
1062
|
|
815
1063
|
ret = test_grow(&ring);
|
816
1064
|
if (ret) {
|
817
|
-
|
818
|
-
return
|
1065
|
+
fprintf(stderr, "test_grow failed\n");
|
1066
|
+
return T_EXIT_FAIL;
|
819
1067
|
}
|
820
1068
|
|
821
1069
|
ret = test_shrink(&ring);
|
822
1070
|
if (ret) {
|
823
|
-
|
824
|
-
return
|
1071
|
+
fprintf(stderr, "test_shrink failed\n");
|
1072
|
+
return T_EXIT_FAIL;
|
825
1073
|
}
|
826
1074
|
|
827
1075
|
ret = test_zero(&ring);
|
828
1076
|
if (ret) {
|
829
|
-
|
830
|
-
return
|
1077
|
+
fprintf(stderr, "test_zero failed\n");
|
1078
|
+
return T_EXIT_FAIL;
|
831
1079
|
}
|
832
1080
|
|
833
1081
|
ret = test_huge(&ring);
|
834
1082
|
if (ret) {
|
835
|
-
|
836
|
-
return
|
1083
|
+
fprintf(stderr, "test_huge failed\n");
|
1084
|
+
return T_EXIT_FAIL;
|
837
1085
|
}
|
838
1086
|
|
839
1087
|
ret = test_skip(&ring);
|
840
1088
|
if (ret) {
|
841
|
-
|
842
|
-
return
|
1089
|
+
fprintf(stderr, "test_skip failed\n");
|
1090
|
+
return T_EXIT_FAIL;
|
843
1091
|
}
|
844
1092
|
|
845
1093
|
ret = test_sparse_updates();
|
846
1094
|
if (ret) {
|
847
|
-
|
848
|
-
return
|
1095
|
+
fprintf(stderr, "test_sparse_updates failed\n");
|
1096
|
+
return T_EXIT_FAIL;
|
849
1097
|
}
|
850
1098
|
|
851
1099
|
ret = test_fixed_removal_ordering();
|
852
1100
|
if (ret) {
|
853
|
-
|
854
|
-
return
|
1101
|
+
fprintf(stderr, "test_fixed_removal_ordering failed\n");
|
1102
|
+
return T_EXIT_FAIL;
|
855
1103
|
}
|
856
1104
|
|
857
|
-
|
1105
|
+
ret = test_mixed_af_unix();
|
1106
|
+
if (ret) {
|
1107
|
+
fprintf(stderr, "test_mixed_af_unix failed\n");
|
1108
|
+
return T_EXIT_FAIL;
|
1109
|
+
}
|
1110
|
+
|
1111
|
+
ret = test_partial_register_fail();
|
1112
|
+
if (ret) {
|
1113
|
+
fprintf(stderr, "test_partial_register_fail failed\n");
|
1114
|
+
return T_EXIT_FAIL;
|
1115
|
+
}
|
1116
|
+
|
1117
|
+
ret = test_file_alloc_ranges();
|
1118
|
+
if (ret) {
|
1119
|
+
fprintf(stderr, "test_partial_register_fail failed\n");
|
1120
|
+
return T_EXIT_FAIL;
|
1121
|
+
}
|
1122
|
+
|
1123
|
+
return T_EXIT_PASS;
|
858
1124
|
}
|
@@ -131,18 +131,68 @@ static int test_sqe_update(struct io_uring *ring)
|
|
131
131
|
free(fds);
|
132
132
|
if (ret == -EINVAL) {
|
133
133
|
fprintf(stdout, "IORING_OP_FILES_UPDATE not supported, skipping\n");
|
134
|
-
return
|
134
|
+
return T_EXIT_SKIP;
|
135
135
|
}
|
136
136
|
return ret != 10;
|
137
137
|
}
|
138
138
|
|
139
|
+
static int test_update_no_table(void)
|
140
|
+
{
|
141
|
+
int up_fd, fds[4] = {-1, 0, 1, 4};
|
142
|
+
struct io_uring_sqe *sqe;
|
143
|
+
struct io_uring_cqe *cqe;
|
144
|
+
struct io_uring ring;
|
145
|
+
int ret;
|
146
|
+
|
147
|
+
ret = t_create_ring(2, &ring, 0);
|
148
|
+
if (ret == T_SETUP_SKIP)
|
149
|
+
return T_EXIT_SKIP;
|
150
|
+
else if (ret != T_SETUP_OK)
|
151
|
+
return ret;
|
152
|
+
|
153
|
+
ret = io_uring_register_files(&ring, fds, 4);
|
154
|
+
/* ignore other failures */
|
155
|
+
if (ret && ret != -EBADF) {
|
156
|
+
fprintf(stderr, "Failed registering file table: %d\n", ret);
|
157
|
+
goto fail;
|
158
|
+
}
|
159
|
+
|
160
|
+
sqe = io_uring_get_sqe(&ring);
|
161
|
+
up_fd = ring.ring_fd;
|
162
|
+
io_uring_prep_files_update(sqe, &up_fd, 1, -1); //offset = -1
|
163
|
+
ret = io_uring_submit(&ring);
|
164
|
+
if (ret != 1) {
|
165
|
+
fprintf(stderr, "Failed submit: %d\n", ret);
|
166
|
+
goto fail;
|
167
|
+
}
|
168
|
+
|
169
|
+
ret = io_uring_wait_cqe(&ring, &cqe);
|
170
|
+
if (ret) {
|
171
|
+
fprintf(stderr, "Failed wait: %d\n", ret);
|
172
|
+
goto fail;
|
173
|
+
}
|
174
|
+
ret = cqe->res;
|
175
|
+
io_uring_cqe_seen(&ring, cqe);
|
176
|
+
if (ret != -EMFILE && ret != -EINVAL && ret != -EOVERFLOW &&
|
177
|
+
ret != -ENXIO) {
|
178
|
+
fprintf(stderr, "Bad cqe res: %d\n", ret);
|
179
|
+
goto fail;
|
180
|
+
}
|
181
|
+
|
182
|
+
io_uring_queue_exit(&ring);
|
183
|
+
return T_EXIT_PASS;
|
184
|
+
fail:
|
185
|
+
io_uring_queue_exit(&ring);
|
186
|
+
return T_EXIT_FAIL;
|
187
|
+
}
|
188
|
+
|
139
189
|
int main(int argc, char *argv[])
|
140
190
|
{
|
141
191
|
struct io_uring r1, r2, r3;
|
142
192
|
int ret;
|
143
193
|
|
144
194
|
if (argc > 1)
|
145
|
-
return
|
195
|
+
return T_EXIT_SKIP;
|
146
196
|
|
147
197
|
if (io_uring_queue_init(8, &r1, 0) ||
|
148
198
|
io_uring_queue_init(8, &r2, 0) ||
|
@@ -165,9 +215,17 @@ int main(int argc, char *argv[])
|
|
165
215
|
|
166
216
|
ret = test_sqe_update(&r1);
|
167
217
|
if (ret) {
|
168
|
-
|
218
|
+
if (ret != T_EXIT_SKIP)
|
219
|
+
fprintf(stderr, "test_sqe_update failed\n");
|
169
220
|
return ret;
|
170
221
|
}
|
171
222
|
|
172
|
-
|
223
|
+
ret = test_update_no_table();
|
224
|
+
if (ret) {
|
225
|
+
if (ret != T_EXIT_SKIP)
|
226
|
+
fprintf(stderr, "test_sqe_update failed\n");
|
227
|
+
return ret;
|
228
|
+
}
|
229
|
+
|
230
|
+
return T_EXIT_PASS;
|
173
231
|
}
|