polyphony 0.97 → 0.99
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/examples/io/https_server_sni_2.rb +14 -8
- data/examples/io/irb.rb +1 -1
- data/ext/polyphony/backend_common.c +30 -0
- data/ext/polyphony/backend_common.h +1 -0
- data/ext/polyphony/backend_io_uring.c +125 -0
- data/ext/polyphony/backend_libev.c +135 -0
- data/ext/polyphony/extconf.rb +6 -5
- data/ext/polyphony/io_extensions.c +2 -0
- data/ext/polyphony/libev.h +0 -2
- data/ext/polyphony/polyphony.c +10 -0
- data/ext/polyphony/polyphony.h +2 -0
- data/lib/polyphony/adapters/irb.rb +0 -2
- data/lib/polyphony/core/sync.rb +53 -0
- data/lib/polyphony/extensions/io.rb +39 -14
- data/lib/polyphony/extensions/openssl.rb +1 -1
- data/lib/polyphony/extensions/socket.rb +30 -1
- data/lib/polyphony/version.rb +1 -1
- data/lib/polyphony.rb +4 -0
- data/test/test_io.rb +14 -7
- data/test/test_socket.rb +131 -10
- data/test/test_sync.rb +42 -1
- data/test/test_thread.rb +2 -1
- data/vendor/liburing/.github/workflows/build.yml +7 -16
- data/vendor/liburing/.gitignore +5 -0
- data/vendor/liburing/CHANGELOG +23 -1
- data/vendor/liburing/Makefile +4 -3
- data/vendor/liburing/Makefile.common +1 -0
- data/vendor/liburing/README +48 -0
- data/vendor/liburing/configure +76 -6
- data/vendor/liburing/debian/changelog +11 -0
- data/vendor/liburing/debian/control +7 -16
- data/vendor/liburing/debian/liburing-dev.manpages +3 -6
- data/vendor/liburing/debian/liburing2.install +1 -0
- data/vendor/liburing/debian/liburing2.symbols +56 -0
- data/vendor/liburing/debian/rules +15 -68
- data/vendor/liburing/examples/Makefile +4 -0
- data/vendor/liburing/examples/io_uring-close-test.c +123 -0
- data/vendor/liburing/examples/io_uring-udp.c +1 -1
- data/vendor/liburing/examples/send-zerocopy.c +315 -56
- data/vendor/liburing/examples/ucontext-cp.c +2 -17
- data/vendor/liburing/liburing-ffi.pc.in +12 -0
- data/vendor/liburing/liburing.pc.in +1 -1
- data/vendor/liburing/liburing.spec +1 -1
- data/vendor/liburing/make-debs.sh +3 -3
- data/vendor/liburing/man/IO_URING_CHECK_VERSION.3 +1 -0
- data/vendor/liburing/man/IO_URING_VERSION_MAJOR.3 +1 -0
- data/vendor/liburing/man/IO_URING_VERSION_MINOR.3 +1 -0
- data/vendor/liburing/man/io_uring_buf_ring_add.3 +6 -6
- data/vendor/liburing/man/io_uring_check_version.3 +72 -0
- data/vendor/liburing/man/io_uring_close_ring_fd.3 +43 -0
- data/vendor/liburing/man/io_uring_major_version.3 +1 -0
- data/vendor/liburing/man/io_uring_minor_version.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_accept.3 +1 -1
- data/vendor/liburing/man/io_uring_prep_fgetxattr.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_fsetxattr.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_getxattr.3 +61 -0
- data/vendor/liburing/man/io_uring_prep_link_timeout.3 +94 -0
- data/vendor/liburing/man/io_uring_prep_msg_ring.3 +22 -2
- data/vendor/liburing/man/io_uring_prep_msg_ring_cqe_flags.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_poll_add.3 +1 -1
- data/vendor/liburing/man/io_uring_prep_provide_buffers.3 +18 -9
- data/vendor/liburing/man/io_uring_prep_readv.3 +3 -3
- data/vendor/liburing/man/io_uring_prep_readv2.3 +3 -3
- data/vendor/liburing/man/io_uring_prep_recv.3 +5 -5
- data/vendor/liburing/man/io_uring_prep_recvmsg.3 +4 -4
- data/vendor/liburing/man/io_uring_prep_send.3 +9 -0
- data/vendor/liburing/man/io_uring_prep_send_set_addr.3 +38 -0
- data/vendor/liburing/man/io_uring_prep_send_zc.3 +39 -7
- data/vendor/liburing/man/io_uring_prep_send_zc_fixed.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_sendmsg.3 +20 -0
- data/vendor/liburing/man/io_uring_prep_sendmsg_zc.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_setxattr.3 +64 -0
- data/vendor/liburing/man/io_uring_prep_splice.3 +40 -0
- data/vendor/liburing/man/io_uring_prep_writev.3 +2 -2
- data/vendor/liburing/man/io_uring_prep_writev2.3 +2 -2
- data/vendor/liburing/man/io_uring_recvmsg_out.3 +13 -9
- data/vendor/liburing/man/io_uring_register.2 +15 -9
- data/vendor/liburing/man/io_uring_register_buf_ring.3 +4 -4
- data/vendor/liburing/man/io_uring_register_buffers.3 +49 -6
- data/vendor/liburing/man/io_uring_register_buffers_sparse.3 +1 -0
- data/vendor/liburing/man/io_uring_register_buffers_tags.3 +1 -0
- data/vendor/liburing/man/io_uring_register_buffers_update_tag.3 +1 -0
- data/vendor/liburing/man/io_uring_register_files.3 +60 -5
- data/vendor/liburing/man/io_uring_register_files_tags.3 +1 -0
- data/vendor/liburing/man/io_uring_register_files_update.3 +1 -0
- data/vendor/liburing/man/io_uring_register_files_update_tag.3 +1 -0
- data/vendor/liburing/man/io_uring_setup.2 +31 -2
- data/vendor/liburing/man/io_uring_wait_cqe_timeout.3 +1 -1
- data/vendor/liburing/src/Makefile +25 -3
- data/vendor/liburing/src/ffi.c +15 -0
- data/vendor/liburing/src/include/liburing/io_uring.h +30 -7
- data/vendor/liburing/src/include/liburing.h +190 -148
- data/vendor/liburing/src/int_flags.h +1 -0
- data/vendor/liburing/src/lib.h +5 -16
- data/vendor/liburing/src/liburing-ffi.map +172 -0
- data/vendor/liburing/src/liburing.map +11 -0
- data/vendor/liburing/src/nolibc.c +9 -2
- data/vendor/liburing/src/queue.c +2 -2
- data/vendor/liburing/src/register.c +66 -96
- data/vendor/liburing/src/setup.c +5 -4
- data/vendor/liburing/src/version.c +21 -0
- data/vendor/liburing/test/232c93d07b74.c +3 -3
- data/vendor/liburing/test/35fa71a030ca.c +3 -3
- data/vendor/liburing/test/500f9fbadef8.c +2 -0
- data/vendor/liburing/test/917257daa0fe.c +1 -1
- data/vendor/liburing/test/Makefile +27 -7
- data/vendor/liburing/test/a0908ae19763.c +2 -2
- data/vendor/liburing/test/a4c0b3decb33.c +2 -2
- data/vendor/liburing/test/accept-link.c +4 -4
- data/vendor/liburing/test/accept-reuse.c +5 -7
- data/vendor/liburing/test/accept.c +34 -31
- data/vendor/liburing/test/b19062a56726.c +1 -1
- data/vendor/liburing/test/buf-ring.c +58 -4
- data/vendor/liburing/test/ce593a6c480a.c +2 -2
- data/vendor/liburing/test/close-opath.c +2 -1
- data/vendor/liburing/test/connect.c +8 -0
- data/vendor/liburing/test/cq-overflow.c +14 -8
- data/vendor/liburing/test/d4ae271dfaae.c +1 -1
- data/vendor/liburing/test/defer-taskrun.c +64 -9
- data/vendor/liburing/test/defer.c +1 -1
- data/vendor/liburing/test/double-poll-crash.c +3 -3
- data/vendor/liburing/test/eeed8b54e0df.c +8 -3
- data/vendor/liburing/test/eploop.c +74 -0
- data/vendor/liburing/test/eventfd-ring.c +1 -1
- data/vendor/liburing/test/eventfd.c +1 -1
- data/vendor/liburing/test/evloop.c +73 -0
- data/vendor/liburing/test/exit-no-cleanup.c +1 -1
- data/vendor/liburing/test/fadvise.c +1 -1
- data/vendor/liburing/test/fc2a85cb02ef.c +3 -3
- data/vendor/liburing/test/fd-pass.c +35 -16
- data/vendor/liburing/test/file-register.c +61 -0
- data/vendor/liburing/test/file-verify.c +2 -2
- data/vendor/liburing/test/files-exit-hang-timeout.c +2 -2
- data/vendor/liburing/test/fixed-link.c +1 -1
- data/vendor/liburing/test/fsnotify.c +118 -0
- data/vendor/liburing/test/hardlink.c +1 -1
- data/vendor/liburing/test/helpers.c +54 -2
- data/vendor/liburing/test/helpers.h +4 -0
- data/vendor/liburing/test/io-cancel.c +3 -1
- data/vendor/liburing/test/io_uring_passthrough.c +39 -8
- data/vendor/liburing/test/io_uring_setup.c +3 -80
- data/vendor/liburing/test/iopoll-overflow.c +118 -0
- data/vendor/liburing/test/iopoll.c +90 -4
- data/vendor/liburing/test/lfs-openat-write.c +7 -9
- data/vendor/liburing/test/lfs-openat.c +6 -8
- data/vendor/liburing/test/link_drain.c +31 -5
- data/vendor/liburing/test/madvise.c +1 -1
- data/vendor/liburing/test/msg-ring-flags.c +192 -0
- data/vendor/liburing/test/msg-ring-overflow.c +159 -0
- data/vendor/liburing/test/msg-ring.c +173 -13
- data/vendor/liburing/test/multicqes_drain.c +22 -19
- data/vendor/liburing/test/nvme.h +4 -3
- data/vendor/liburing/test/pipe-bug.c +95 -0
- data/vendor/liburing/test/poll-link.c +3 -3
- data/vendor/liburing/test/poll-many.c +41 -19
- data/vendor/liburing/test/poll-mshot-overflow.c +105 -2
- data/vendor/liburing/test/poll-race-mshot.c +292 -0
- data/vendor/liburing/test/poll-race.c +105 -0
- data/vendor/liburing/test/poll.c +244 -26
- data/vendor/liburing/test/pollfree.c +5 -5
- data/vendor/liburing/test/read-before-exit.c +20 -3
- data/vendor/liburing/test/read-write.c +2 -0
- data/vendor/liburing/test/recv-multishot.c +96 -3
- data/vendor/liburing/test/reg-reg-ring.c +90 -0
- data/vendor/liburing/test/rename.c +1 -1
- data/vendor/liburing/test/ring-leak.c +0 -1
- data/vendor/liburing/test/ring-leak2.c +1 -1
- data/vendor/liburing/test/ringbuf-read.c +10 -6
- data/vendor/liburing/test/send-zerocopy.c +273 -103
- data/vendor/liburing/test/send_recv.c +7 -4
- data/vendor/liburing/test/sendmsg_fs_cve.c +2 -2
- data/vendor/liburing/test/single-issuer.c +7 -9
- data/vendor/liburing/test/skip-cqe.c +3 -4
- data/vendor/liburing/test/socket.c +0 -1
- data/vendor/liburing/test/sq-poll-dup.c +10 -3
- data/vendor/liburing/test/sq-poll-kthread.c +1 -1
- data/vendor/liburing/test/sq-poll-share.c +3 -2
- data/vendor/liburing/test/sqpoll-cancel-hang.c +17 -6
- data/vendor/liburing/test/sqpoll-disable-exit.c +4 -4
- data/vendor/liburing/test/symlink.c +2 -1
- data/vendor/liburing/test/test.h +2 -1
- data/vendor/liburing/test/timeout-new.c +11 -7
- data/vendor/liburing/test/timeout.c +1 -2
- data/vendor/liburing/test/unlink.c +1 -1
- data/vendor/liburing/test/version.c +25 -0
- data/vendor/liburing/test/wakeup-hang.c +1 -1
- data/vendor/liburing/test/xattr.c +8 -4
- metadata +42 -6
- data/vendor/liburing/debian/compat +0 -1
- data/vendor/liburing/debian/liburing1-udeb.install +0 -1
- data/vendor/liburing/debian/liburing1.install +0 -1
- data/vendor/liburing/debian/liburing1.symbols +0 -32
@@ -23,6 +23,7 @@
|
|
23
23
|
#include <linux/swab.h>
|
24
24
|
#include "liburing/compat.h"
|
25
25
|
#include "liburing/io_uring.h"
|
26
|
+
#include "liburing/io_uring_version.h"
|
26
27
|
#include "liburing/barrier.h"
|
27
28
|
|
28
29
|
#ifndef uring_unlikely
|
@@ -33,6 +34,10 @@
|
|
33
34
|
#define uring_likely(cond) __builtin_expect(!!(cond), 1)
|
34
35
|
#endif
|
35
36
|
|
37
|
+
#ifndef IOURINGINLINE
|
38
|
+
#define IOURINGINLINE static inline
|
39
|
+
#endif
|
40
|
+
|
36
41
|
#ifdef __alpha__
|
37
42
|
/*
|
38
43
|
* alpha and mips are the exceptions, all other architectures have
|
@@ -151,7 +156,7 @@ struct io_uring_probe *io_uring_get_probe(void);
|
|
151
156
|
*/
|
152
157
|
void io_uring_free_probe(struct io_uring_probe *probe);
|
153
158
|
|
154
|
-
|
159
|
+
IOURINGINLINE int io_uring_opcode_supported(const struct io_uring_probe *p,
|
155
160
|
int op)
|
156
161
|
{
|
157
162
|
if (op > p->last_op)
|
@@ -226,6 +231,7 @@ int io_uring_register_iowq_max_workers(struct io_uring *ring,
|
|
226
231
|
unsigned int *values);
|
227
232
|
int io_uring_register_ring_fd(struct io_uring *ring);
|
228
233
|
int io_uring_unregister_ring_fd(struct io_uring *ring);
|
234
|
+
int io_uring_close_ring_fd(struct io_uring *ring);
|
229
235
|
int io_uring_register_buf_ring(struct io_uring *ring,
|
230
236
|
struct io_uring_buf_reg *reg, unsigned int flags);
|
231
237
|
int io_uring_unregister_buf_ring(struct io_uring *ring, int bgid);
|
@@ -283,8 +289,7 @@ int __io_uring_get_cqe(struct io_uring *ring,
|
|
283
289
|
/*
|
284
290
|
* Must be called after io_uring_for_each_cqe()
|
285
291
|
*/
|
286
|
-
|
287
|
-
unsigned nr)
|
292
|
+
IOURINGINLINE void io_uring_cq_advance(struct io_uring *ring, unsigned nr)
|
288
293
|
{
|
289
294
|
if (nr) {
|
290
295
|
struct io_uring_cq *cq = &ring->cq;
|
@@ -301,7 +306,7 @@ static inline void io_uring_cq_advance(struct io_uring *ring,
|
|
301
306
|
* Must be called after io_uring_{peek,wait}_cqe() after the cqe has
|
302
307
|
* been processed by the application.
|
303
308
|
*/
|
304
|
-
|
309
|
+
IOURINGINLINE void io_uring_cqe_seen(struct io_uring *ring,
|
305
310
|
struct io_uring_cqe *cqe)
|
306
311
|
{
|
307
312
|
if (cqe)
|
@@ -316,12 +321,12 @@ static inline void io_uring_cqe_seen(struct io_uring *ring,
|
|
316
321
|
* Associate pointer @data with the sqe, for later retrieval from the cqe
|
317
322
|
* at command completion time with io_uring_cqe_get_data().
|
318
323
|
*/
|
319
|
-
|
324
|
+
IOURINGINLINE void io_uring_sqe_set_data(struct io_uring_sqe *sqe, void *data)
|
320
325
|
{
|
321
326
|
sqe->user_data = (unsigned long) data;
|
322
327
|
}
|
323
328
|
|
324
|
-
|
329
|
+
IOURINGINLINE void *io_uring_cqe_get_data(const struct io_uring_cqe *cqe)
|
325
330
|
{
|
326
331
|
return (void *) (uintptr_t) cqe->user_data;
|
327
332
|
}
|
@@ -331,13 +336,13 @@ static inline void *io_uring_cqe_get_data(const struct io_uring_cqe *cqe)
|
|
331
336
|
* time with io_uring_cqe_get_data64. Just like the non-64 variants, except
|
332
337
|
* these store a 64-bit type rather than a data pointer.
|
333
338
|
*/
|
334
|
-
|
339
|
+
IOURINGINLINE void io_uring_sqe_set_data64(struct io_uring_sqe *sqe,
|
335
340
|
__u64 data)
|
336
341
|
{
|
337
342
|
sqe->user_data = data;
|
338
343
|
}
|
339
344
|
|
340
|
-
|
345
|
+
IOURINGINLINE __u64 io_uring_cqe_get_data64(const struct io_uring_cqe *cqe)
|
341
346
|
{
|
342
347
|
return cqe->user_data;
|
343
348
|
}
|
@@ -347,20 +352,20 @@ static inline __u64 io_uring_cqe_get_data64(const struct io_uring_cqe *cqe)
|
|
347
352
|
*/
|
348
353
|
#define LIBURING_HAVE_DATA64
|
349
354
|
|
350
|
-
|
355
|
+
IOURINGINLINE void io_uring_sqe_set_flags(struct io_uring_sqe *sqe,
|
351
356
|
unsigned flags)
|
352
357
|
{
|
353
358
|
sqe->flags = (__u8) flags;
|
354
359
|
}
|
355
360
|
|
356
|
-
|
361
|
+
IOURINGINLINE void __io_uring_set_target_fixed_file(struct io_uring_sqe *sqe,
|
357
362
|
unsigned int file_index)
|
358
363
|
{
|
359
364
|
/* 0 means no fixed files, indexes should be encoded as "index + 1" */
|
360
365
|
sqe->file_index = file_index + 1;
|
361
366
|
}
|
362
367
|
|
363
|
-
|
368
|
+
IOURINGINLINE void io_uring_prep_rw(int op, struct io_uring_sqe *sqe, int fd,
|
364
369
|
const void *addr, unsigned len,
|
365
370
|
__u64 offset)
|
366
371
|
{
|
@@ -379,29 +384,28 @@ static inline void io_uring_prep_rw(int op, struct io_uring_sqe *sqe, int fd,
|
|
379
384
|
sqe->__pad2[0] = 0;
|
380
385
|
}
|
381
386
|
|
382
|
-
|
383
|
-
*
|
384
|
-
*
|
385
|
-
*
|
386
|
-
*
|
387
|
-
*
|
388
|
-
*
|
389
|
-
*
|
390
|
-
*
|
391
|
-
* @
|
392
|
-
* @
|
387
|
+
/*
|
388
|
+
* io_uring_prep_splice() - Either @fd_in or @fd_out must be a pipe.
|
389
|
+
*
|
390
|
+
* - If @fd_in refers to a pipe, @off_in is ignored and must be set to -1.
|
391
|
+
*
|
392
|
+
* - If @fd_in does not refer to a pipe and @off_in is -1, then @nbytes are read
|
393
|
+
* from @fd_in starting from the file offset, which is incremented by the
|
394
|
+
* number of bytes read.
|
395
|
+
*
|
396
|
+
* - If @fd_in does not refer to a pipe and @off_in is not -1, then the starting
|
397
|
+
* offset of @fd_in will be @off_in.
|
393
398
|
*
|
394
399
|
* This splice operation can be used to implement sendfile by splicing to an
|
395
400
|
* intermediate pipe first, then splice to the final destination.
|
396
401
|
* In fact, the implementation of sendfile in kernel uses splice internally.
|
397
402
|
*
|
398
403
|
* NOTE that even if fd_in or fd_out refers to a pipe, the splice operation
|
399
|
-
* can still
|
400
|
-
*
|
401
|
-
* to 5.11.
|
404
|
+
* can still fail with EINVAL if one of the fd doesn't explicitly support splice
|
405
|
+
* operation, e.g. reading from terminal is unsupported from kernel 5.7 to 5.11.
|
402
406
|
* Check issue #291 for more information.
|
403
407
|
*/
|
404
|
-
|
408
|
+
IOURINGINLINE void io_uring_prep_splice(struct io_uring_sqe *sqe,
|
405
409
|
int fd_in, int64_t off_in,
|
406
410
|
int fd_out, int64_t off_out,
|
407
411
|
unsigned int nbytes,
|
@@ -414,7 +418,7 @@ static inline void io_uring_prep_splice(struct io_uring_sqe *sqe,
|
|
414
418
|
sqe->splice_flags = splice_flags;
|
415
419
|
}
|
416
420
|
|
417
|
-
|
421
|
+
IOURINGINLINE void io_uring_prep_tee(struct io_uring_sqe *sqe,
|
418
422
|
int fd_in, int fd_out,
|
419
423
|
unsigned int nbytes,
|
420
424
|
unsigned int splice_flags)
|
@@ -425,14 +429,14 @@ static inline void io_uring_prep_tee(struct io_uring_sqe *sqe,
|
|
425
429
|
sqe->splice_flags = splice_flags;
|
426
430
|
}
|
427
431
|
|
428
|
-
|
432
|
+
IOURINGINLINE void io_uring_prep_readv(struct io_uring_sqe *sqe, int fd,
|
429
433
|
const struct iovec *iovecs,
|
430
434
|
unsigned nr_vecs, __u64 offset)
|
431
435
|
{
|
432
436
|
io_uring_prep_rw(IORING_OP_READV, sqe, fd, iovecs, nr_vecs, offset);
|
433
437
|
}
|
434
438
|
|
435
|
-
|
439
|
+
IOURINGINLINE void io_uring_prep_readv2(struct io_uring_sqe *sqe, int fd,
|
436
440
|
const struct iovec *iovecs,
|
437
441
|
unsigned nr_vecs, __u64 offset,
|
438
442
|
int flags)
|
@@ -441,7 +445,7 @@ static inline void io_uring_prep_readv2(struct io_uring_sqe *sqe, int fd,
|
|
441
445
|
sqe->rw_flags = flags;
|
442
446
|
}
|
443
447
|
|
444
|
-
|
448
|
+
IOURINGINLINE void io_uring_prep_read_fixed(struct io_uring_sqe *sqe, int fd,
|
445
449
|
void *buf, unsigned nbytes,
|
446
450
|
__u64 offset, int buf_index)
|
447
451
|
{
|
@@ -449,14 +453,14 @@ static inline void io_uring_prep_read_fixed(struct io_uring_sqe *sqe, int fd,
|
|
449
453
|
sqe->buf_index = (__u16) buf_index;
|
450
454
|
}
|
451
455
|
|
452
|
-
|
456
|
+
IOURINGINLINE void io_uring_prep_writev(struct io_uring_sqe *sqe, int fd,
|
453
457
|
const struct iovec *iovecs,
|
454
458
|
unsigned nr_vecs, __u64 offset)
|
455
459
|
{
|
456
460
|
io_uring_prep_rw(IORING_OP_WRITEV, sqe, fd, iovecs, nr_vecs, offset);
|
457
461
|
}
|
458
462
|
|
459
|
-
|
463
|
+
IOURINGINLINE void io_uring_prep_writev2(struct io_uring_sqe *sqe, int fd,
|
460
464
|
const struct iovec *iovecs,
|
461
465
|
unsigned nr_vecs, __u64 offset,
|
462
466
|
int flags)
|
@@ -465,7 +469,7 @@ static inline void io_uring_prep_writev2(struct io_uring_sqe *sqe, int fd,
|
|
465
469
|
sqe->rw_flags = flags;
|
466
470
|
}
|
467
471
|
|
468
|
-
|
472
|
+
IOURINGINLINE void io_uring_prep_write_fixed(struct io_uring_sqe *sqe, int fd,
|
469
473
|
const void *buf, unsigned nbytes,
|
470
474
|
__u64 offset, int buf_index)
|
471
475
|
{
|
@@ -473,21 +477,22 @@ static inline void io_uring_prep_write_fixed(struct io_uring_sqe *sqe, int fd,
|
|
473
477
|
sqe->buf_index = (__u16) buf_index;
|
474
478
|
}
|
475
479
|
|
476
|
-
|
480
|
+
IOURINGINLINE void io_uring_prep_recvmsg(struct io_uring_sqe *sqe, int fd,
|
477
481
|
struct msghdr *msg, unsigned flags)
|
478
482
|
{
|
479
483
|
io_uring_prep_rw(IORING_OP_RECVMSG, sqe, fd, msg, 1, 0);
|
480
484
|
sqe->msg_flags = flags;
|
481
485
|
}
|
482
486
|
|
483
|
-
|
484
|
-
struct msghdr *msg,
|
487
|
+
IOURINGINLINE void io_uring_prep_recvmsg_multishot(struct io_uring_sqe *sqe,
|
488
|
+
int fd, struct msghdr *msg,
|
489
|
+
unsigned flags)
|
485
490
|
{
|
486
491
|
io_uring_prep_recvmsg(sqe, fd, msg, flags);
|
487
492
|
sqe->ioprio |= IORING_RECV_MULTISHOT;
|
488
493
|
}
|
489
494
|
|
490
|
-
|
495
|
+
IOURINGINLINE void io_uring_prep_sendmsg(struct io_uring_sqe *sqe, int fd,
|
491
496
|
const struct msghdr *msg,
|
492
497
|
unsigned flags)
|
493
498
|
{
|
@@ -495,7 +500,7 @@ static inline void io_uring_prep_sendmsg(struct io_uring_sqe *sqe, int fd,
|
|
495
500
|
sqe->msg_flags = flags;
|
496
501
|
}
|
497
502
|
|
498
|
-
|
503
|
+
IOURINGINLINE unsigned __io_uring_prep_poll_mask(unsigned poll_mask)
|
499
504
|
{
|
500
505
|
#if __BYTE_ORDER == __BIG_ENDIAN
|
501
506
|
poll_mask = __swahw32(poll_mask);
|
@@ -503,28 +508,28 @@ static inline unsigned __io_uring_prep_poll_mask(unsigned poll_mask)
|
|
503
508
|
return poll_mask;
|
504
509
|
}
|
505
510
|
|
506
|
-
|
511
|
+
IOURINGINLINE void io_uring_prep_poll_add(struct io_uring_sqe *sqe, int fd,
|
507
512
|
unsigned poll_mask)
|
508
513
|
{
|
509
514
|
io_uring_prep_rw(IORING_OP_POLL_ADD, sqe, fd, NULL, 0, 0);
|
510
515
|
sqe->poll32_events = __io_uring_prep_poll_mask(poll_mask);
|
511
516
|
}
|
512
517
|
|
513
|
-
|
518
|
+
IOURINGINLINE void io_uring_prep_poll_multishot(struct io_uring_sqe *sqe,
|
514
519
|
int fd, unsigned poll_mask)
|
515
520
|
{
|
516
521
|
io_uring_prep_poll_add(sqe, fd, poll_mask);
|
517
522
|
sqe->len = IORING_POLL_ADD_MULTI;
|
518
523
|
}
|
519
524
|
|
520
|
-
|
525
|
+
IOURINGINLINE void io_uring_prep_poll_remove(struct io_uring_sqe *sqe,
|
521
526
|
__u64 user_data)
|
522
527
|
{
|
523
528
|
io_uring_prep_rw(IORING_OP_POLL_REMOVE, sqe, -1, NULL, 0, 0);
|
524
529
|
sqe->addr = user_data;
|
525
530
|
}
|
526
531
|
|
527
|
-
|
532
|
+
IOURINGINLINE void io_uring_prep_poll_update(struct io_uring_sqe *sqe,
|
528
533
|
__u64 old_user_data,
|
529
534
|
__u64 new_user_data,
|
530
535
|
unsigned poll_mask, unsigned flags)
|
@@ -535,19 +540,19 @@ static inline void io_uring_prep_poll_update(struct io_uring_sqe *sqe,
|
|
535
540
|
sqe->poll32_events = __io_uring_prep_poll_mask(poll_mask);
|
536
541
|
}
|
537
542
|
|
538
|
-
|
543
|
+
IOURINGINLINE void io_uring_prep_fsync(struct io_uring_sqe *sqe, int fd,
|
539
544
|
unsigned fsync_flags)
|
540
545
|
{
|
541
546
|
io_uring_prep_rw(IORING_OP_FSYNC, sqe, fd, NULL, 0, 0);
|
542
547
|
sqe->fsync_flags = fsync_flags;
|
543
548
|
}
|
544
549
|
|
545
|
-
|
550
|
+
IOURINGINLINE void io_uring_prep_nop(struct io_uring_sqe *sqe)
|
546
551
|
{
|
547
552
|
io_uring_prep_rw(IORING_OP_NOP, sqe, -1, NULL, 0, 0);
|
548
553
|
}
|
549
554
|
|
550
|
-
|
555
|
+
IOURINGINLINE void io_uring_prep_timeout(struct io_uring_sqe *sqe,
|
551
556
|
struct __kernel_timespec *ts,
|
552
557
|
unsigned count, unsigned flags)
|
553
558
|
{
|
@@ -555,7 +560,7 @@ static inline void io_uring_prep_timeout(struct io_uring_sqe *sqe,
|
|
555
560
|
sqe->timeout_flags = flags;
|
556
561
|
}
|
557
562
|
|
558
|
-
|
563
|
+
IOURINGINLINE void io_uring_prep_timeout_remove(struct io_uring_sqe *sqe,
|
559
564
|
__u64 user_data, unsigned flags)
|
560
565
|
{
|
561
566
|
io_uring_prep_rw(IORING_OP_TIMEOUT_REMOVE, sqe, -1, NULL, 0, 0);
|
@@ -563,7 +568,7 @@ static inline void io_uring_prep_timeout_remove(struct io_uring_sqe *sqe,
|
|
563
568
|
sqe->timeout_flags = flags;
|
564
569
|
}
|
565
570
|
|
566
|
-
|
571
|
+
IOURINGINLINE void io_uring_prep_timeout_update(struct io_uring_sqe *sqe,
|
567
572
|
struct __kernel_timespec *ts,
|
568
573
|
__u64 user_data, unsigned flags)
|
569
574
|
{
|
@@ -573,7 +578,7 @@ static inline void io_uring_prep_timeout_update(struct io_uring_sqe *sqe,
|
|
573
578
|
sqe->timeout_flags = flags | IORING_TIMEOUT_UPDATE;
|
574
579
|
}
|
575
580
|
|
576
|
-
|
581
|
+
IOURINGINLINE void io_uring_prep_accept(struct io_uring_sqe *sqe, int fd,
|
577
582
|
struct sockaddr *addr,
|
578
583
|
socklen_t *addrlen, int flags)
|
579
584
|
{
|
@@ -583,7 +588,7 @@ static inline void io_uring_prep_accept(struct io_uring_sqe *sqe, int fd,
|
|
583
588
|
}
|
584
589
|
|
585
590
|
/* accept directly into the fixed file table */
|
586
|
-
|
591
|
+
IOURINGINLINE void io_uring_prep_accept_direct(struct io_uring_sqe *sqe, int fd,
|
587
592
|
struct sockaddr *addr,
|
588
593
|
socklen_t *addrlen, int flags,
|
589
594
|
unsigned int file_index)
|
@@ -592,7 +597,7 @@ static inline void io_uring_prep_accept_direct(struct io_uring_sqe *sqe, int fd,
|
|
592
597
|
__io_uring_set_target_fixed_file(sqe, file_index);
|
593
598
|
}
|
594
599
|
|
595
|
-
|
600
|
+
IOURINGINLINE void io_uring_prep_multishot_accept(struct io_uring_sqe *sqe,
|
596
601
|
int fd, struct sockaddr *addr,
|
597
602
|
socklen_t *addrlen, int flags)
|
598
603
|
{
|
@@ -601,7 +606,7 @@ static inline void io_uring_prep_multishot_accept(struct io_uring_sqe *sqe,
|
|
601
606
|
}
|
602
607
|
|
603
608
|
/* multishot accept directly into the fixed file table */
|
604
|
-
|
609
|
+
IOURINGINLINE void io_uring_prep_multishot_accept_direct(struct io_uring_sqe *sqe,
|
605
610
|
int fd,
|
606
611
|
struct sockaddr *addr,
|
607
612
|
socklen_t *addrlen,
|
@@ -611,7 +616,7 @@ static inline void io_uring_prep_multishot_accept_direct(struct io_uring_sqe *sq
|
|
611
616
|
__io_uring_set_target_fixed_file(sqe, IORING_FILE_INDEX_ALLOC - 1);
|
612
617
|
}
|
613
618
|
|
614
|
-
|
619
|
+
IOURINGINLINE void io_uring_prep_cancel64(struct io_uring_sqe *sqe,
|
615
620
|
__u64 user_data, int flags)
|
616
621
|
{
|
617
622
|
io_uring_prep_rw(IORING_OP_ASYNC_CANCEL, sqe, -1, NULL, 0, 0);
|
@@ -619,20 +624,20 @@ static inline void io_uring_prep_cancel64(struct io_uring_sqe *sqe,
|
|
619
624
|
sqe->cancel_flags = (__u32) flags;
|
620
625
|
}
|
621
626
|
|
622
|
-
|
627
|
+
IOURINGINLINE void io_uring_prep_cancel(struct io_uring_sqe *sqe,
|
623
628
|
void *user_data, int flags)
|
624
629
|
{
|
625
630
|
io_uring_prep_cancel64(sqe, (__u64) (uintptr_t) user_data, flags);
|
626
631
|
}
|
627
632
|
|
628
|
-
|
633
|
+
IOURINGINLINE void io_uring_prep_cancel_fd(struct io_uring_sqe *sqe, int fd,
|
629
634
|
unsigned int flags)
|
630
635
|
{
|
631
636
|
io_uring_prep_rw(IORING_OP_ASYNC_CANCEL, sqe, fd, NULL, 0, 0);
|
632
637
|
sqe->cancel_flags = (__u32) flags | IORING_ASYNC_CANCEL_FD;
|
633
638
|
}
|
634
639
|
|
635
|
-
|
640
|
+
IOURINGINLINE void io_uring_prep_link_timeout(struct io_uring_sqe *sqe,
|
636
641
|
struct __kernel_timespec *ts,
|
637
642
|
unsigned flags)
|
638
643
|
{
|
@@ -640,14 +645,14 @@ static inline void io_uring_prep_link_timeout(struct io_uring_sqe *sqe,
|
|
640
645
|
sqe->timeout_flags = flags;
|
641
646
|
}
|
642
647
|
|
643
|
-
|
648
|
+
IOURINGINLINE void io_uring_prep_connect(struct io_uring_sqe *sqe, int fd,
|
644
649
|
const struct sockaddr *addr,
|
645
650
|
socklen_t addrlen)
|
646
651
|
{
|
647
652
|
io_uring_prep_rw(IORING_OP_CONNECT, sqe, fd, addr, 0, addrlen);
|
648
653
|
}
|
649
654
|
|
650
|
-
|
655
|
+
IOURINGINLINE void io_uring_prep_files_update(struct io_uring_sqe *sqe,
|
651
656
|
int *fds, unsigned nr_fds,
|
652
657
|
int offset)
|
653
658
|
{
|
@@ -655,7 +660,7 @@ static inline void io_uring_prep_files_update(struct io_uring_sqe *sqe,
|
|
655
660
|
(__u64) offset);
|
656
661
|
}
|
657
662
|
|
658
|
-
|
663
|
+
IOURINGINLINE void io_uring_prep_fallocate(struct io_uring_sqe *sqe, int fd,
|
659
664
|
int mode, off_t offset, off_t len)
|
660
665
|
{
|
661
666
|
io_uring_prep_rw(IORING_OP_FALLOCATE, sqe, fd,
|
@@ -663,7 +668,7 @@ static inline void io_uring_prep_fallocate(struct io_uring_sqe *sqe, int fd,
|
|
663
668
|
sqe->addr = (__u64) len;
|
664
669
|
}
|
665
670
|
|
666
|
-
|
671
|
+
IOURINGINLINE void io_uring_prep_openat(struct io_uring_sqe *sqe, int dfd,
|
667
672
|
const char *path, int flags,
|
668
673
|
mode_t mode)
|
669
674
|
{
|
@@ -672,7 +677,7 @@ static inline void io_uring_prep_openat(struct io_uring_sqe *sqe, int dfd,
|
|
672
677
|
}
|
673
678
|
|
674
679
|
/* open directly into the fixed file table */
|
675
|
-
|
680
|
+
IOURINGINLINE void io_uring_prep_openat_direct(struct io_uring_sqe *sqe,
|
676
681
|
int dfd, const char *path,
|
677
682
|
int flags, mode_t mode,
|
678
683
|
unsigned file_index)
|
@@ -681,25 +686,25 @@ static inline void io_uring_prep_openat_direct(struct io_uring_sqe *sqe,
|
|
681
686
|
__io_uring_set_target_fixed_file(sqe, file_index);
|
682
687
|
}
|
683
688
|
|
684
|
-
|
689
|
+
IOURINGINLINE void io_uring_prep_close(struct io_uring_sqe *sqe, int fd)
|
685
690
|
{
|
686
691
|
io_uring_prep_rw(IORING_OP_CLOSE, sqe, fd, NULL, 0, 0);
|
687
692
|
}
|
688
693
|
|
689
|
-
|
694
|
+
IOURINGINLINE void io_uring_prep_close_direct(struct io_uring_sqe *sqe,
|
690
695
|
unsigned file_index)
|
691
696
|
{
|
692
697
|
io_uring_prep_close(sqe, 0);
|
693
698
|
__io_uring_set_target_fixed_file(sqe, file_index);
|
694
699
|
}
|
695
700
|
|
696
|
-
|
701
|
+
IOURINGINLINE void io_uring_prep_read(struct io_uring_sqe *sqe, int fd,
|
697
702
|
void *buf, unsigned nbytes, __u64 offset)
|
698
703
|
{
|
699
704
|
io_uring_prep_rw(IORING_OP_READ, sqe, fd, buf, nbytes, offset);
|
700
705
|
}
|
701
706
|
|
702
|
-
|
707
|
+
IOURINGINLINE void io_uring_prep_write(struct io_uring_sqe *sqe, int fd,
|
703
708
|
const void *buf, unsigned nbytes,
|
704
709
|
__u64 offset)
|
705
710
|
{
|
@@ -707,37 +712,37 @@ static inline void io_uring_prep_write(struct io_uring_sqe *sqe, int fd,
|
|
707
712
|
}
|
708
713
|
|
709
714
|
struct statx;
|
710
|
-
|
711
|
-
|
712
|
-
|
715
|
+
IOURINGINLINE void io_uring_prep_statx(struct io_uring_sqe *sqe, int dfd,
|
716
|
+
const char *path, int flags,
|
717
|
+
unsigned mask, struct statx *statxbuf)
|
713
718
|
{
|
714
719
|
io_uring_prep_rw(IORING_OP_STATX, sqe, dfd, path, mask,
|
715
720
|
(__u64) (unsigned long) statxbuf);
|
716
721
|
sqe->statx_flags = (__u32) flags;
|
717
722
|
}
|
718
723
|
|
719
|
-
|
724
|
+
IOURINGINLINE void io_uring_prep_fadvise(struct io_uring_sqe *sqe, int fd,
|
720
725
|
__u64 offset, off_t len, int advice)
|
721
726
|
{
|
722
727
|
io_uring_prep_rw(IORING_OP_FADVISE, sqe, fd, NULL, (__u32) len, offset);
|
723
728
|
sqe->fadvise_advice = (__u32) advice;
|
724
729
|
}
|
725
730
|
|
726
|
-
|
731
|
+
IOURINGINLINE void io_uring_prep_madvise(struct io_uring_sqe *sqe, void *addr,
|
727
732
|
off_t length, int advice)
|
728
733
|
{
|
729
734
|
io_uring_prep_rw(IORING_OP_MADVISE, sqe, -1, addr, (__u32) length, 0);
|
730
735
|
sqe->fadvise_advice = (__u32) advice;
|
731
736
|
}
|
732
737
|
|
733
|
-
|
738
|
+
IOURINGINLINE void io_uring_prep_send(struct io_uring_sqe *sqe, int sockfd,
|
734
739
|
const void *buf, size_t len, int flags)
|
735
740
|
{
|
736
741
|
io_uring_prep_rw(IORING_OP_SEND, sqe, sockfd, buf, (__u32) len, 0);
|
737
742
|
sqe->msg_flags = (__u32) flags;
|
738
743
|
}
|
739
744
|
|
740
|
-
|
745
|
+
IOURINGINLINE void io_uring_prep_send_zc(struct io_uring_sqe *sqe, int sockfd,
|
741
746
|
const void *buf, size_t len, int flags,
|
742
747
|
unsigned zc_flags)
|
743
748
|
{
|
@@ -746,7 +751,7 @@ static inline void io_uring_prep_send_zc(struct io_uring_sqe *sqe, int sockfd,
|
|
746
751
|
sqe->ioprio = zc_flags;
|
747
752
|
}
|
748
753
|
|
749
|
-
|
754
|
+
IOURINGINLINE void io_uring_prep_send_zc_fixed(struct io_uring_sqe *sqe,
|
750
755
|
int sockfd, const void *buf,
|
751
756
|
size_t len, int flags,
|
752
757
|
unsigned zc_flags,
|
@@ -757,7 +762,7 @@ static inline void io_uring_prep_send_zc_fixed(struct io_uring_sqe *sqe,
|
|
757
762
|
sqe->buf_index = buf_index;
|
758
763
|
}
|
759
764
|
|
760
|
-
|
765
|
+
IOURINGINLINE void io_uring_prep_sendmsg_zc(struct io_uring_sqe *sqe, int fd,
|
761
766
|
const struct msghdr *msg,
|
762
767
|
unsigned flags)
|
763
768
|
{
|
@@ -765,7 +770,7 @@ static inline void io_uring_prep_sendmsg_zc(struct io_uring_sqe *sqe, int fd,
|
|
765
770
|
sqe->opcode = IORING_OP_SENDMSG_ZC;
|
766
771
|
}
|
767
772
|
|
768
|
-
|
773
|
+
IOURINGINLINE void io_uring_prep_send_set_addr(struct io_uring_sqe *sqe,
|
769
774
|
const struct sockaddr *dest_addr,
|
770
775
|
__u16 addr_len)
|
771
776
|
{
|
@@ -773,14 +778,14 @@ static inline void io_uring_prep_send_set_addr(struct io_uring_sqe *sqe,
|
|
773
778
|
sqe->addr_len = addr_len;
|
774
779
|
}
|
775
780
|
|
776
|
-
|
781
|
+
IOURINGINLINE void io_uring_prep_recv(struct io_uring_sqe *sqe, int sockfd,
|
777
782
|
void *buf, size_t len, int flags)
|
778
783
|
{
|
779
784
|
io_uring_prep_rw(IORING_OP_RECV, sqe, sockfd, buf, (__u32) len, 0);
|
780
785
|
sqe->msg_flags = (__u32) flags;
|
781
786
|
}
|
782
787
|
|
783
|
-
|
788
|
+
IOURINGINLINE void io_uring_prep_recv_multishot(struct io_uring_sqe *sqe,
|
784
789
|
int sockfd, void *buf,
|
785
790
|
size_t len, int flags)
|
786
791
|
{
|
@@ -788,7 +793,7 @@ static inline void io_uring_prep_recv_multishot(struct io_uring_sqe *sqe,
|
|
788
793
|
sqe->ioprio |= IORING_RECV_MULTISHOT;
|
789
794
|
}
|
790
795
|
|
791
|
-
|
796
|
+
IOURINGINLINE struct io_uring_recvmsg_out *
|
792
797
|
io_uring_recvmsg_validate(void *buf, int buf_len, struct msghdr *msgh)
|
793
798
|
{
|
794
799
|
unsigned long header = msgh->msg_controllen + msgh->msg_namelen +
|
@@ -798,12 +803,12 @@ io_uring_recvmsg_validate(void *buf, int buf_len, struct msghdr *msgh)
|
|
798
803
|
return (struct io_uring_recvmsg_out *)buf;
|
799
804
|
}
|
800
805
|
|
801
|
-
|
806
|
+
IOURINGINLINE void *io_uring_recvmsg_name(struct io_uring_recvmsg_out *o)
|
802
807
|
{
|
803
808
|
return (void *) &o[1];
|
804
809
|
}
|
805
810
|
|
806
|
-
|
811
|
+
IOURINGINLINE struct cmsghdr *
|
807
812
|
io_uring_recvmsg_cmsg_firsthdr(struct io_uring_recvmsg_out *o,
|
808
813
|
struct msghdr *msgh)
|
809
814
|
{
|
@@ -814,7 +819,7 @@ io_uring_recvmsg_cmsg_firsthdr(struct io_uring_recvmsg_out *o,
|
|
814
819
|
msgh->msg_namelen);
|
815
820
|
}
|
816
821
|
|
817
|
-
|
822
|
+
IOURINGINLINE struct cmsghdr *
|
818
823
|
io_uring_recvmsg_cmsg_nexthdr(struct io_uring_recvmsg_out *o, struct msghdr *msgh,
|
819
824
|
struct cmsghdr *cmsg)
|
820
825
|
{
|
@@ -835,14 +840,14 @@ io_uring_recvmsg_cmsg_nexthdr(struct io_uring_recvmsg_out *o, struct msghdr *msg
|
|
835
840
|
return cmsg;
|
836
841
|
}
|
837
842
|
|
838
|
-
|
843
|
+
IOURINGINLINE void *io_uring_recvmsg_payload(struct io_uring_recvmsg_out *o,
|
839
844
|
struct msghdr *msgh)
|
840
845
|
{
|
841
846
|
return (void *)((unsigned char *)io_uring_recvmsg_name(o) +
|
842
847
|
msgh->msg_namelen + msgh->msg_controllen);
|
843
848
|
}
|
844
849
|
|
845
|
-
|
850
|
+
IOURINGINLINE unsigned int
|
846
851
|
io_uring_recvmsg_payload_length(struct io_uring_recvmsg_out *o,
|
847
852
|
int buf_len, struct msghdr *msgh)
|
848
853
|
{
|
@@ -853,7 +858,7 @@ io_uring_recvmsg_payload_length(struct io_uring_recvmsg_out *o,
|
|
853
858
|
return (unsigned int) (payload_end - payload_start);
|
854
859
|
}
|
855
860
|
|
856
|
-
|
861
|
+
IOURINGINLINE void io_uring_prep_openat2(struct io_uring_sqe *sqe, int dfd,
|
857
862
|
const char *path, struct open_how *how)
|
858
863
|
{
|
859
864
|
io_uring_prep_rw(IORING_OP_OPENAT2, sqe, dfd, path, sizeof(*how),
|
@@ -861,7 +866,7 @@ static inline void io_uring_prep_openat2(struct io_uring_sqe *sqe, int dfd,
|
|
861
866
|
}
|
862
867
|
|
863
868
|
/* open directly into the fixed file table */
|
864
|
-
|
869
|
+
IOURINGINLINE void io_uring_prep_openat2_direct(struct io_uring_sqe *sqe,
|
865
870
|
int dfd, const char *path,
|
866
871
|
struct open_how *how,
|
867
872
|
unsigned file_index)
|
@@ -871,7 +876,7 @@ static inline void io_uring_prep_openat2_direct(struct io_uring_sqe *sqe,
|
|
871
876
|
}
|
872
877
|
|
873
878
|
struct epoll_event;
|
874
|
-
|
879
|
+
IOURINGINLINE void io_uring_prep_epoll_ctl(struct io_uring_sqe *sqe, int epfd,
|
875
880
|
int fd, int op,
|
876
881
|
struct epoll_event *ev)
|
877
882
|
{
|
@@ -879,7 +884,7 @@ static inline void io_uring_prep_epoll_ctl(struct io_uring_sqe *sqe, int epfd,
|
|
879
884
|
(__u32) op, (__u32) fd);
|
880
885
|
}
|
881
886
|
|
882
|
-
|
887
|
+
IOURINGINLINE void io_uring_prep_provide_buffers(struct io_uring_sqe *sqe,
|
883
888
|
void *addr, int len, int nr,
|
884
889
|
int bgid, int bid)
|
885
890
|
{
|
@@ -888,33 +893,33 @@ static inline void io_uring_prep_provide_buffers(struct io_uring_sqe *sqe,
|
|
888
893
|
sqe->buf_group = (__u16) bgid;
|
889
894
|
}
|
890
895
|
|
891
|
-
|
896
|
+
IOURINGINLINE void io_uring_prep_remove_buffers(struct io_uring_sqe *sqe,
|
892
897
|
int nr, int bgid)
|
893
898
|
{
|
894
899
|
io_uring_prep_rw(IORING_OP_REMOVE_BUFFERS, sqe, nr, NULL, 0, 0);
|
895
900
|
sqe->buf_group = (__u16) bgid;
|
896
901
|
}
|
897
902
|
|
898
|
-
|
903
|
+
IOURINGINLINE void io_uring_prep_shutdown(struct io_uring_sqe *sqe, int fd,
|
899
904
|
int how)
|
900
905
|
{
|
901
906
|
io_uring_prep_rw(IORING_OP_SHUTDOWN, sqe, fd, NULL, (__u32) how, 0);
|
902
907
|
}
|
903
908
|
|
904
|
-
|
909
|
+
IOURINGINLINE void io_uring_prep_unlinkat(struct io_uring_sqe *sqe, int dfd,
|
905
910
|
const char *path, int flags)
|
906
911
|
{
|
907
912
|
io_uring_prep_rw(IORING_OP_UNLINKAT, sqe, dfd, path, 0, 0);
|
908
913
|
sqe->unlink_flags = (__u32) flags;
|
909
914
|
}
|
910
915
|
|
911
|
-
|
916
|
+
IOURINGINLINE void io_uring_prep_unlink(struct io_uring_sqe *sqe,
|
912
917
|
const char *path, int flags)
|
913
918
|
{
|
914
919
|
io_uring_prep_unlinkat(sqe, AT_FDCWD, path, flags);
|
915
920
|
}
|
916
921
|
|
917
|
-
|
922
|
+
IOURINGINLINE void io_uring_prep_renameat(struct io_uring_sqe *sqe, int olddfd,
|
918
923
|
const char *oldpath, int newdfd,
|
919
924
|
const char *newpath, unsigned int flags)
|
920
925
|
{
|
@@ -924,13 +929,14 @@ static inline void io_uring_prep_renameat(struct io_uring_sqe *sqe, int olddfd,
|
|
924
929
|
sqe->rename_flags = (__u32) flags;
|
925
930
|
}
|
926
931
|
|
927
|
-
|
928
|
-
|
932
|
+
IOURINGINLINE void io_uring_prep_rename(struct io_uring_sqe *sqe,
|
933
|
+
const char *oldpath,
|
934
|
+
const char *newpath)
|
929
935
|
{
|
930
936
|
io_uring_prep_renameat(sqe, AT_FDCWD, oldpath, AT_FDCWD, newpath, 0);
|
931
937
|
}
|
932
938
|
|
933
|
-
|
939
|
+
IOURINGINLINE void io_uring_prep_sync_file_range(struct io_uring_sqe *sqe,
|
934
940
|
int fd, unsigned len,
|
935
941
|
__u64 offset, int flags)
|
936
942
|
{
|
@@ -938,19 +944,19 @@ static inline void io_uring_prep_sync_file_range(struct io_uring_sqe *sqe,
|
|
938
944
|
sqe->sync_range_flags = (__u32) flags;
|
939
945
|
}
|
940
946
|
|
941
|
-
|
947
|
+
IOURINGINLINE void io_uring_prep_mkdirat(struct io_uring_sqe *sqe, int dfd,
|
942
948
|
const char *path, mode_t mode)
|
943
949
|
{
|
944
950
|
io_uring_prep_rw(IORING_OP_MKDIRAT, sqe, dfd, path, mode, 0);
|
945
951
|
}
|
946
952
|
|
947
|
-
|
953
|
+
IOURINGINLINE void io_uring_prep_mkdir(struct io_uring_sqe *sqe,
|
948
954
|
const char *path, mode_t mode)
|
949
955
|
{
|
950
956
|
io_uring_prep_mkdirat(sqe, AT_FDCWD, path, mode);
|
951
957
|
}
|
952
958
|
|
953
|
-
|
959
|
+
IOURINGINLINE void io_uring_prep_symlinkat(struct io_uring_sqe *sqe,
|
954
960
|
const char *target, int newdirfd,
|
955
961
|
const char *linkpath)
|
956
962
|
{
|
@@ -958,13 +964,14 @@ static inline void io_uring_prep_symlinkat(struct io_uring_sqe *sqe,
|
|
958
964
|
(uint64_t) (uintptr_t) linkpath);
|
959
965
|
}
|
960
966
|
|
961
|
-
|
962
|
-
|
967
|
+
IOURINGINLINE void io_uring_prep_symlink(struct io_uring_sqe *sqe,
|
968
|
+
const char *target,
|
969
|
+
const char *linkpath)
|
963
970
|
{
|
964
971
|
io_uring_prep_symlinkat(sqe, target, AT_FDCWD, linkpath);
|
965
972
|
}
|
966
973
|
|
967
|
-
|
974
|
+
IOURINGINLINE void io_uring_prep_linkat(struct io_uring_sqe *sqe, int olddfd,
|
968
975
|
const char *oldpath, int newdfd,
|
969
976
|
const char *newpath, int flags)
|
970
977
|
{
|
@@ -973,25 +980,44 @@ static inline void io_uring_prep_linkat(struct io_uring_sqe *sqe, int olddfd,
|
|
973
980
|
sqe->hardlink_flags = (__u32) flags;
|
974
981
|
}
|
975
982
|
|
976
|
-
|
977
|
-
|
983
|
+
IOURINGINLINE void io_uring_prep_link(struct io_uring_sqe *sqe,
|
984
|
+
const char *oldpath, const char *newpath,
|
985
|
+
int flags)
|
978
986
|
{
|
979
987
|
io_uring_prep_linkat(sqe, AT_FDCWD, oldpath, AT_FDCWD, newpath, flags);
|
980
988
|
}
|
981
989
|
|
982
|
-
|
990
|
+
IOURINGINLINE void io_uring_prep_msg_ring_cqe_flags(struct io_uring_sqe *sqe,
|
991
|
+
int fd, unsigned int len, __u64 data,
|
992
|
+
unsigned int flags, unsigned int cqe_flags)
|
993
|
+
{
|
994
|
+
io_uring_prep_rw(IORING_OP_MSG_RING, sqe, fd, NULL, len, data);
|
995
|
+
sqe->msg_ring_flags = IORING_MSG_RING_FLAGS_PASS | flags;
|
996
|
+
sqe->file_index = cqe_flags;
|
997
|
+
}
|
998
|
+
|
999
|
+
IOURINGINLINE void io_uring_prep_msg_ring(struct io_uring_sqe *sqe, int fd,
|
983
1000
|
unsigned int len, __u64 data,
|
984
1001
|
unsigned int flags)
|
985
1002
|
{
|
986
1003
|
io_uring_prep_rw(IORING_OP_MSG_RING, sqe, fd, NULL, len, data);
|
987
|
-
sqe->
|
1004
|
+
sqe->msg_ring_flags = flags;
|
988
1005
|
}
|
989
1006
|
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
1007
|
+
IOURINGINLINE void io_uring_prep_msg_ring_fd(struct io_uring_sqe *sqe, int fd,
|
1008
|
+
int source_fd, int target_fd,
|
1009
|
+
__u64 data, unsigned int flags)
|
1010
|
+
{
|
1011
|
+
io_uring_prep_rw(IORING_OP_MSG_RING, sqe, fd,
|
1012
|
+
(void *) (uintptr_t) IORING_MSG_SEND_FD, 0, data);
|
1013
|
+
sqe->addr3 = source_fd;
|
1014
|
+
__io_uring_set_target_fixed_file(sqe, target_fd);
|
1015
|
+
sqe->msg_ring_flags = flags;
|
1016
|
+
}
|
1017
|
+
|
1018
|
+
IOURINGINLINE void io_uring_prep_getxattr(struct io_uring_sqe *sqe,
|
1019
|
+
const char *name, char *value,
|
1020
|
+
const char *path, unsigned int len)
|
995
1021
|
{
|
996
1022
|
io_uring_prep_rw(IORING_OP_GETXATTR, sqe, 0, name, len,
|
997
1023
|
(__u64) (uintptr_t) value);
|
@@ -999,11 +1025,9 @@ static inline void io_uring_prep_getxattr(struct io_uring_sqe *sqe,
|
|
999
1025
|
sqe->xattr_flags = 0;
|
1000
1026
|
}
|
1001
1027
|
|
1002
|
-
|
1003
|
-
const char *name,
|
1004
|
-
const char *
|
1005
|
-
const char *path,
|
1006
|
-
int flags,
|
1028
|
+
IOURINGINLINE void io_uring_prep_setxattr(struct io_uring_sqe *sqe,
|
1029
|
+
const char *name, const char *value,
|
1030
|
+
const char *path, int flags,
|
1007
1031
|
unsigned int len)
|
1008
1032
|
{
|
1009
1033
|
io_uring_prep_rw(IORING_OP_SETXATTR, sqe, 0, name, len,
|
@@ -1012,30 +1036,25 @@ static inline void io_uring_prep_setxattr(struct io_uring_sqe *sqe,
|
|
1012
1036
|
sqe->xattr_flags = flags;
|
1013
1037
|
}
|
1014
1038
|
|
1015
|
-
|
1016
|
-
int fd,
|
1017
|
-
|
1018
|
-
char *value,
|
1019
|
-
unsigned int len)
|
1039
|
+
IOURINGINLINE void io_uring_prep_fgetxattr(struct io_uring_sqe *sqe,
|
1040
|
+
int fd, const char *name,
|
1041
|
+
char *value, unsigned int len)
|
1020
1042
|
{
|
1021
1043
|
io_uring_prep_rw(IORING_OP_FGETXATTR, sqe, fd, name, len,
|
1022
1044
|
(__u64) (uintptr_t) value);
|
1023
1045
|
sqe->xattr_flags = 0;
|
1024
1046
|
}
|
1025
1047
|
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
const char *value,
|
1030
|
-
int flags,
|
1031
|
-
unsigned int len)
|
1048
|
+
IOURINGINLINE void io_uring_prep_fsetxattr(struct io_uring_sqe *sqe, int fd,
|
1049
|
+
const char *name, const char *value,
|
1050
|
+
int flags, unsigned int len)
|
1032
1051
|
{
|
1033
1052
|
io_uring_prep_rw(IORING_OP_FSETXATTR, sqe, fd, name, len,
|
1034
1053
|
(__u64) (uintptr_t) value);
|
1035
1054
|
sqe->xattr_flags = flags;
|
1036
1055
|
}
|
1037
1056
|
|
1038
|
-
|
1057
|
+
IOURINGINLINE void io_uring_prep_socket(struct io_uring_sqe *sqe, int domain,
|
1039
1058
|
int type, int protocol,
|
1040
1059
|
unsigned int flags)
|
1041
1060
|
{
|
@@ -1043,7 +1062,7 @@ static inline void io_uring_prep_socket(struct io_uring_sqe *sqe, int domain,
|
|
1043
1062
|
sqe->rw_flags = flags;
|
1044
1063
|
}
|
1045
1064
|
|
1046
|
-
|
1065
|
+
IOURINGINLINE void io_uring_prep_socket_direct(struct io_uring_sqe *sqe,
|
1047
1066
|
int domain, int type,
|
1048
1067
|
int protocol,
|
1049
1068
|
unsigned file_index,
|
@@ -1054,9 +1073,10 @@ static inline void io_uring_prep_socket_direct(struct io_uring_sqe *sqe,
|
|
1054
1073
|
__io_uring_set_target_fixed_file(sqe, file_index);
|
1055
1074
|
}
|
1056
1075
|
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1076
|
+
IOURINGINLINE void io_uring_prep_socket_direct_alloc(struct io_uring_sqe *sqe,
|
1077
|
+
int domain, int type,
|
1078
|
+
int protocol,
|
1079
|
+
unsigned int flags)
|
1060
1080
|
{
|
1061
1081
|
io_uring_prep_rw(IORING_OP_SOCKET, sqe, domain, NULL, protocol, type);
|
1062
1082
|
sqe->rw_flags = flags;
|
@@ -1067,7 +1087,7 @@ static inline void io_uring_prep_socket_direct_alloc(struct io_uring_sqe *sqe,
|
|
1067
1087
|
* Returns number of unconsumed (if SQPOLL) or unsubmitted entries exist in
|
1068
1088
|
* the SQ ring
|
1069
1089
|
*/
|
1070
|
-
|
1090
|
+
IOURINGINLINE unsigned io_uring_sq_ready(const struct io_uring *ring)
|
1071
1091
|
{
|
1072
1092
|
unsigned khead = *ring->sq.khead;
|
1073
1093
|
|
@@ -1086,7 +1106,7 @@ static inline unsigned io_uring_sq_ready(const struct io_uring *ring)
|
|
1086
1106
|
/*
|
1087
1107
|
* Returns how much space is left in the SQ ring.
|
1088
1108
|
*/
|
1089
|
-
|
1109
|
+
IOURINGINLINE unsigned io_uring_sq_space_left(const struct io_uring *ring)
|
1090
1110
|
{
|
1091
1111
|
return ring->sq.ring_entries - io_uring_sq_ready(ring);
|
1092
1112
|
}
|
@@ -1098,7 +1118,7 @@ static inline unsigned io_uring_sq_space_left(const struct io_uring *ring)
|
|
1098
1118
|
* action is taken. Note: may return -EINVAL if the kernel doesn't support
|
1099
1119
|
* this feature.
|
1100
1120
|
*/
|
1101
|
-
|
1121
|
+
IOURINGINLINE int io_uring_sqring_wait(struct io_uring *ring)
|
1102
1122
|
{
|
1103
1123
|
if (!(ring->flags & IORING_SETUP_SQPOLL))
|
1104
1124
|
return 0;
|
@@ -1111,7 +1131,7 @@ static inline int io_uring_sqring_wait(struct io_uring *ring)
|
|
1111
1131
|
/*
|
1112
1132
|
* Returns how many unconsumed entries are ready in the CQ ring
|
1113
1133
|
*/
|
1114
|
-
|
1134
|
+
IOURINGINLINE unsigned io_uring_cq_ready(const struct io_uring *ring)
|
1115
1135
|
{
|
1116
1136
|
return io_uring_smp_load_acquire(ring->cq.ktail) - *ring->cq.khead;
|
1117
1137
|
}
|
@@ -1120,7 +1140,7 @@ static inline unsigned io_uring_cq_ready(const struct io_uring *ring)
|
|
1120
1140
|
* Returns true if there are overflow entries waiting to be flushed onto
|
1121
1141
|
* the CQ ring
|
1122
1142
|
*/
|
1123
|
-
|
1143
|
+
IOURINGINLINE bool io_uring_cq_has_overflow(const struct io_uring *ring)
|
1124
1144
|
{
|
1125
1145
|
return IO_URING_READ_ONCE(*ring->sq.kflags) & IORING_SQ_CQ_OVERFLOW;
|
1126
1146
|
}
|
@@ -1128,7 +1148,7 @@ static inline bool io_uring_cq_has_overflow(const struct io_uring *ring)
|
|
1128
1148
|
/*
|
1129
1149
|
* Returns true if the eventfd notification is currently enabled
|
1130
1150
|
*/
|
1131
|
-
|
1151
|
+
IOURINGINLINE bool io_uring_cq_eventfd_enabled(const struct io_uring *ring)
|
1132
1152
|
{
|
1133
1153
|
if (!ring->cq.kflags)
|
1134
1154
|
return true;
|
@@ -1140,7 +1160,7 @@ static inline bool io_uring_cq_eventfd_enabled(const struct io_uring *ring)
|
|
1140
1160
|
* Toggle eventfd notification on or off, if an eventfd is registered with
|
1141
1161
|
* the ring.
|
1142
1162
|
*/
|
1143
|
-
|
1163
|
+
IOURINGINLINE int io_uring_cq_eventfd_toggle(struct io_uring *ring,
|
1144
1164
|
bool enabled)
|
1145
1165
|
{
|
1146
1166
|
uint32_t flags;
|
@@ -1168,7 +1188,7 @@ static inline int io_uring_cq_eventfd_toggle(struct io_uring *ring,
|
|
1168
1188
|
* readily available. Returns 0 with cqe_ptr filled in on success, -errno on
|
1169
1189
|
* failure.
|
1170
1190
|
*/
|
1171
|
-
|
1191
|
+
IOURINGINLINE int io_uring_wait_cqe_nr(struct io_uring *ring,
|
1172
1192
|
struct io_uring_cqe **cqe_ptr,
|
1173
1193
|
unsigned wait_nr)
|
1174
1194
|
{
|
@@ -1180,7 +1200,7 @@ static inline int io_uring_wait_cqe_nr(struct io_uring *ring,
|
|
1180
1200
|
* "official" versions of this, io_uring_peek_cqe(), io_uring_wait_cqe(),
|
1181
1201
|
* or io_uring_wait_cqes*().
|
1182
1202
|
*/
|
1183
|
-
|
1203
|
+
IOURINGINLINE int __io_uring_peek_cqe(struct io_uring *ring,
|
1184
1204
|
struct io_uring_cqe **cqe_ptr,
|
1185
1205
|
unsigned *nr_available)
|
1186
1206
|
{
|
@@ -1226,7 +1246,7 @@ static inline int __io_uring_peek_cqe(struct io_uring *ring,
|
|
1226
1246
|
* Return an IO completion, if one is readily available. Returns 0 with
|
1227
1247
|
* cqe_ptr filled in on success, -errno on failure.
|
1228
1248
|
*/
|
1229
|
-
|
1249
|
+
IOURINGINLINE int io_uring_peek_cqe(struct io_uring *ring,
|
1230
1250
|
struct io_uring_cqe **cqe_ptr)
|
1231
1251
|
{
|
1232
1252
|
if (!__io_uring_peek_cqe(ring, cqe_ptr, NULL) && *cqe_ptr)
|
@@ -1239,7 +1259,7 @@ static inline int io_uring_peek_cqe(struct io_uring *ring,
|
|
1239
1259
|
* Return an IO completion, waiting for it if necessary. Returns 0 with
|
1240
1260
|
* cqe_ptr filled in on success, -errno on failure.
|
1241
1261
|
*/
|
1242
|
-
|
1262
|
+
IOURINGINLINE int io_uring_wait_cqe(struct io_uring *ring,
|
1243
1263
|
struct io_uring_cqe **cqe_ptr)
|
1244
1264
|
{
|
1245
1265
|
if (!__io_uring_peek_cqe(ring, cqe_ptr, NULL) && *cqe_ptr)
|
@@ -1255,7 +1275,7 @@ static inline int io_uring_wait_cqe(struct io_uring *ring,
|
|
1255
1275
|
*
|
1256
1276
|
* Returns a vacant sqe, or NULL if we're full.
|
1257
1277
|
*/
|
1258
|
-
|
1278
|
+
IOURINGINLINE struct io_uring_sqe *_io_uring_get_sqe(struct io_uring *ring)
|
1259
1279
|
{
|
1260
1280
|
struct io_uring_sq *sq = &ring->sq;
|
1261
1281
|
unsigned int head, next = sq->sqe_tail + 1;
|
@@ -1282,12 +1302,12 @@ static inline struct io_uring_sqe *_io_uring_get_sqe(struct io_uring *ring)
|
|
1282
1302
|
/*
|
1283
1303
|
* Return the appropriate mask for a buffer ring of size 'ring_entries'
|
1284
1304
|
*/
|
1285
|
-
|
1305
|
+
IOURINGINLINE int io_uring_buf_ring_mask(__u32 ring_entries)
|
1286
1306
|
{
|
1287
1307
|
return ring_entries - 1;
|
1288
1308
|
}
|
1289
1309
|
|
1290
|
-
|
1310
|
+
IOURINGINLINE void io_uring_buf_ring_init(struct io_uring_buf_ring *br)
|
1291
1311
|
{
|
1292
1312
|
br->tail = 0;
|
1293
1313
|
}
|
@@ -1295,7 +1315,7 @@ static inline void io_uring_buf_ring_init(struct io_uring_buf_ring *br)
|
|
1295
1315
|
/*
|
1296
1316
|
* Assign 'buf' with the addr/len/buffer ID supplied
|
1297
1317
|
*/
|
1298
|
-
|
1318
|
+
IOURINGINLINE void io_uring_buf_ring_add(struct io_uring_buf_ring *br,
|
1299
1319
|
void *addr, unsigned int len,
|
1300
1320
|
unsigned short bid, int mask,
|
1301
1321
|
int buf_offset)
|
@@ -1312,7 +1332,7 @@ static inline void io_uring_buf_ring_add(struct io_uring_buf_ring *br,
|
|
1312
1332
|
* io_uring_buf_ring_add() has been called 'count' times to fill in new
|
1313
1333
|
* buffers.
|
1314
1334
|
*/
|
1315
|
-
|
1335
|
+
IOURINGINLINE void io_uring_buf_ring_advance(struct io_uring_buf_ring *br,
|
1316
1336
|
int count)
|
1317
1337
|
{
|
1318
1338
|
unsigned short new_tail = br->tail + count;
|
@@ -1327,7 +1347,7 @@ static inline void io_uring_buf_ring_advance(struct io_uring_buf_ring *br,
|
|
1327
1347
|
* avoiding an extra atomic when needing to increment both the CQ ring and
|
1328
1348
|
* the ring buffer index at the same time.
|
1329
1349
|
*/
|
1330
|
-
|
1350
|
+
IOURINGINLINE void io_uring_buf_ring_cq_advance(struct io_uring *ring,
|
1331
1351
|
struct io_uring_buf_ring *br,
|
1332
1352
|
int count)
|
1333
1353
|
{
|
@@ -1336,7 +1356,7 @@ static inline void io_uring_buf_ring_cq_advance(struct io_uring *ring,
|
|
1336
1356
|
}
|
1337
1357
|
|
1338
1358
|
#ifndef LIBURING_INTERNAL
|
1339
|
-
|
1359
|
+
IOURINGINLINE struct io_uring_sqe *io_uring_get_sqe(struct io_uring *ring)
|
1340
1360
|
{
|
1341
1361
|
return _io_uring_get_sqe(ring);
|
1342
1362
|
}
|
@@ -1347,8 +1367,30 @@ struct io_uring_sqe *io_uring_get_sqe(struct io_uring *ring);
|
|
1347
1367
|
ssize_t io_uring_mlock_size(unsigned entries, unsigned flags);
|
1348
1368
|
ssize_t io_uring_mlock_size_params(unsigned entries, struct io_uring_params *p);
|
1349
1369
|
|
1370
|
+
/*
|
1371
|
+
* Versioning information for liburing.
|
1372
|
+
*
|
1373
|
+
* Use IO_URING_CHECK_VERSION() for compile time checks including from
|
1374
|
+
* preprocessor directives.
|
1375
|
+
*
|
1376
|
+
* Use io_uring_check_version() for runtime checks of the version of
|
1377
|
+
* liburing that was loaded by the dynamic linker.
|
1378
|
+
*/
|
1379
|
+
int io_uring_major_version(void);
|
1380
|
+
int io_uring_minor_version(void);
|
1381
|
+
bool io_uring_check_version(int major, int minor);
|
1382
|
+
|
1383
|
+
#define IO_URING_CHECK_VERSION(major,minor) \
|
1384
|
+
(major > IO_URING_VERSION_MAJOR || \
|
1385
|
+
(major == IO_URING_VERSION_MAJOR && \
|
1386
|
+
minor >= IO_URING_VERSION_MINOR))
|
1387
|
+
|
1350
1388
|
#ifdef __cplusplus
|
1351
1389
|
}
|
1352
1390
|
#endif
|
1353
1391
|
|
1392
|
+
#ifdef IOURINGINLINE
|
1393
|
+
#undef IOURINGINLINE
|
1394
|
+
#endif
|
1395
|
+
|
1354
1396
|
#endif
|