polyphony 0.98 → 0.99

Sign up to get free protection for your applications and to get access to all the features.
Files changed (182) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/examples/io/https_server_sni_2.rb +14 -8
  4. data/ext/polyphony/extconf.rb +6 -5
  5. data/ext/polyphony/libev.h +0 -2
  6. data/lib/polyphony/core/sync.rb +53 -0
  7. data/lib/polyphony/extensions/io.rb +37 -14
  8. data/lib/polyphony/extensions/openssl.rb +1 -1
  9. data/lib/polyphony/version.rb +1 -1
  10. data/test/test_io.rb +6 -7
  11. data/test/test_socket.rb +61 -0
  12. data/test/test_sync.rb +42 -1
  13. data/vendor/liburing/.github/workflows/build.yml +7 -16
  14. data/vendor/liburing/.gitignore +5 -0
  15. data/vendor/liburing/CHANGELOG +23 -1
  16. data/vendor/liburing/Makefile +4 -3
  17. data/vendor/liburing/Makefile.common +1 -0
  18. data/vendor/liburing/README +48 -0
  19. data/vendor/liburing/configure +76 -6
  20. data/vendor/liburing/debian/changelog +11 -0
  21. data/vendor/liburing/debian/control +7 -16
  22. data/vendor/liburing/debian/liburing-dev.manpages +3 -6
  23. data/vendor/liburing/debian/liburing2.install +1 -0
  24. data/vendor/liburing/debian/liburing2.symbols +56 -0
  25. data/vendor/liburing/debian/rules +15 -68
  26. data/vendor/liburing/examples/Makefile +4 -0
  27. data/vendor/liburing/examples/io_uring-close-test.c +123 -0
  28. data/vendor/liburing/examples/io_uring-udp.c +1 -1
  29. data/vendor/liburing/examples/send-zerocopy.c +315 -56
  30. data/vendor/liburing/examples/ucontext-cp.c +2 -17
  31. data/vendor/liburing/liburing-ffi.pc.in +12 -0
  32. data/vendor/liburing/liburing.pc.in +1 -1
  33. data/vendor/liburing/liburing.spec +1 -1
  34. data/vendor/liburing/make-debs.sh +3 -3
  35. data/vendor/liburing/man/IO_URING_CHECK_VERSION.3 +1 -0
  36. data/vendor/liburing/man/IO_URING_VERSION_MAJOR.3 +1 -0
  37. data/vendor/liburing/man/IO_URING_VERSION_MINOR.3 +1 -0
  38. data/vendor/liburing/man/io_uring_buf_ring_add.3 +6 -6
  39. data/vendor/liburing/man/io_uring_check_version.3 +72 -0
  40. data/vendor/liburing/man/io_uring_close_ring_fd.3 +43 -0
  41. data/vendor/liburing/man/io_uring_major_version.3 +1 -0
  42. data/vendor/liburing/man/io_uring_minor_version.3 +1 -0
  43. data/vendor/liburing/man/io_uring_prep_accept.3 +1 -1
  44. data/vendor/liburing/man/io_uring_prep_fgetxattr.3 +1 -0
  45. data/vendor/liburing/man/io_uring_prep_fsetxattr.3 +1 -0
  46. data/vendor/liburing/man/io_uring_prep_getxattr.3 +61 -0
  47. data/vendor/liburing/man/io_uring_prep_link_timeout.3 +94 -0
  48. data/vendor/liburing/man/io_uring_prep_msg_ring.3 +22 -2
  49. data/vendor/liburing/man/io_uring_prep_msg_ring_cqe_flags.3 +1 -0
  50. data/vendor/liburing/man/io_uring_prep_poll_add.3 +1 -1
  51. data/vendor/liburing/man/io_uring_prep_provide_buffers.3 +18 -9
  52. data/vendor/liburing/man/io_uring_prep_readv.3 +3 -3
  53. data/vendor/liburing/man/io_uring_prep_readv2.3 +3 -3
  54. data/vendor/liburing/man/io_uring_prep_recv.3 +5 -5
  55. data/vendor/liburing/man/io_uring_prep_recvmsg.3 +4 -4
  56. data/vendor/liburing/man/io_uring_prep_send.3 +9 -0
  57. data/vendor/liburing/man/io_uring_prep_send_set_addr.3 +38 -0
  58. data/vendor/liburing/man/io_uring_prep_send_zc.3 +39 -7
  59. data/vendor/liburing/man/io_uring_prep_send_zc_fixed.3 +1 -0
  60. data/vendor/liburing/man/io_uring_prep_sendmsg.3 +20 -0
  61. data/vendor/liburing/man/io_uring_prep_sendmsg_zc.3 +1 -0
  62. data/vendor/liburing/man/io_uring_prep_setxattr.3 +64 -0
  63. data/vendor/liburing/man/io_uring_prep_splice.3 +40 -0
  64. data/vendor/liburing/man/io_uring_prep_writev.3 +2 -2
  65. data/vendor/liburing/man/io_uring_prep_writev2.3 +2 -2
  66. data/vendor/liburing/man/io_uring_recvmsg_out.3 +13 -9
  67. data/vendor/liburing/man/io_uring_register.2 +15 -9
  68. data/vendor/liburing/man/io_uring_register_buf_ring.3 +4 -4
  69. data/vendor/liburing/man/io_uring_register_buffers.3 +49 -6
  70. data/vendor/liburing/man/io_uring_register_buffers_sparse.3 +1 -0
  71. data/vendor/liburing/man/io_uring_register_buffers_tags.3 +1 -0
  72. data/vendor/liburing/man/io_uring_register_buffers_update_tag.3 +1 -0
  73. data/vendor/liburing/man/io_uring_register_files.3 +60 -5
  74. data/vendor/liburing/man/io_uring_register_files_tags.3 +1 -0
  75. data/vendor/liburing/man/io_uring_register_files_update.3 +1 -0
  76. data/vendor/liburing/man/io_uring_register_files_update_tag.3 +1 -0
  77. data/vendor/liburing/man/io_uring_setup.2 +31 -2
  78. data/vendor/liburing/man/io_uring_wait_cqe_timeout.3 +1 -1
  79. data/vendor/liburing/src/Makefile +25 -3
  80. data/vendor/liburing/src/ffi.c +15 -0
  81. data/vendor/liburing/src/include/liburing/io_uring.h +30 -7
  82. data/vendor/liburing/src/include/liburing.h +190 -148
  83. data/vendor/liburing/src/int_flags.h +1 -0
  84. data/vendor/liburing/src/lib.h +5 -16
  85. data/vendor/liburing/src/liburing-ffi.map +172 -0
  86. data/vendor/liburing/src/liburing.map +11 -0
  87. data/vendor/liburing/src/nolibc.c +9 -2
  88. data/vendor/liburing/src/queue.c +2 -2
  89. data/vendor/liburing/src/register.c +66 -96
  90. data/vendor/liburing/src/setup.c +5 -4
  91. data/vendor/liburing/src/version.c +21 -0
  92. data/vendor/liburing/test/232c93d07b74.c +3 -3
  93. data/vendor/liburing/test/35fa71a030ca.c +3 -3
  94. data/vendor/liburing/test/500f9fbadef8.c +2 -0
  95. data/vendor/liburing/test/917257daa0fe.c +1 -1
  96. data/vendor/liburing/test/Makefile +27 -7
  97. data/vendor/liburing/test/a0908ae19763.c +2 -2
  98. data/vendor/liburing/test/a4c0b3decb33.c +2 -2
  99. data/vendor/liburing/test/accept-link.c +4 -4
  100. data/vendor/liburing/test/accept-reuse.c +5 -7
  101. data/vendor/liburing/test/accept.c +34 -31
  102. data/vendor/liburing/test/b19062a56726.c +1 -1
  103. data/vendor/liburing/test/buf-ring.c +58 -4
  104. data/vendor/liburing/test/ce593a6c480a.c +2 -2
  105. data/vendor/liburing/test/close-opath.c +2 -1
  106. data/vendor/liburing/test/connect.c +8 -0
  107. data/vendor/liburing/test/cq-overflow.c +14 -8
  108. data/vendor/liburing/test/d4ae271dfaae.c +1 -1
  109. data/vendor/liburing/test/defer-taskrun.c +64 -9
  110. data/vendor/liburing/test/defer.c +1 -1
  111. data/vendor/liburing/test/double-poll-crash.c +3 -3
  112. data/vendor/liburing/test/eeed8b54e0df.c +8 -3
  113. data/vendor/liburing/test/eploop.c +74 -0
  114. data/vendor/liburing/test/eventfd-ring.c +1 -1
  115. data/vendor/liburing/test/eventfd.c +1 -1
  116. data/vendor/liburing/test/evloop.c +73 -0
  117. data/vendor/liburing/test/exit-no-cleanup.c +1 -1
  118. data/vendor/liburing/test/fadvise.c +1 -1
  119. data/vendor/liburing/test/fc2a85cb02ef.c +3 -3
  120. data/vendor/liburing/test/fd-pass.c +35 -16
  121. data/vendor/liburing/test/file-register.c +61 -0
  122. data/vendor/liburing/test/file-verify.c +2 -2
  123. data/vendor/liburing/test/files-exit-hang-timeout.c +2 -2
  124. data/vendor/liburing/test/fixed-link.c +1 -1
  125. data/vendor/liburing/test/fsnotify.c +118 -0
  126. data/vendor/liburing/test/hardlink.c +1 -1
  127. data/vendor/liburing/test/helpers.c +54 -2
  128. data/vendor/liburing/test/helpers.h +4 -0
  129. data/vendor/liburing/test/io-cancel.c +3 -1
  130. data/vendor/liburing/test/io_uring_passthrough.c +39 -8
  131. data/vendor/liburing/test/io_uring_setup.c +3 -80
  132. data/vendor/liburing/test/iopoll-overflow.c +118 -0
  133. data/vendor/liburing/test/iopoll.c +90 -4
  134. data/vendor/liburing/test/lfs-openat-write.c +7 -9
  135. data/vendor/liburing/test/lfs-openat.c +6 -8
  136. data/vendor/liburing/test/link_drain.c +31 -5
  137. data/vendor/liburing/test/madvise.c +1 -1
  138. data/vendor/liburing/test/msg-ring-flags.c +192 -0
  139. data/vendor/liburing/test/msg-ring-overflow.c +159 -0
  140. data/vendor/liburing/test/msg-ring.c +173 -13
  141. data/vendor/liburing/test/multicqes_drain.c +22 -19
  142. data/vendor/liburing/test/nvme.h +4 -3
  143. data/vendor/liburing/test/pipe-bug.c +95 -0
  144. data/vendor/liburing/test/poll-link.c +3 -3
  145. data/vendor/liburing/test/poll-many.c +41 -19
  146. data/vendor/liburing/test/poll-mshot-overflow.c +105 -2
  147. data/vendor/liburing/test/poll-race-mshot.c +292 -0
  148. data/vendor/liburing/test/poll-race.c +105 -0
  149. data/vendor/liburing/test/poll.c +244 -26
  150. data/vendor/liburing/test/pollfree.c +5 -5
  151. data/vendor/liburing/test/read-before-exit.c +20 -3
  152. data/vendor/liburing/test/read-write.c +2 -0
  153. data/vendor/liburing/test/recv-multishot.c +96 -3
  154. data/vendor/liburing/test/reg-reg-ring.c +90 -0
  155. data/vendor/liburing/test/rename.c +1 -1
  156. data/vendor/liburing/test/ring-leak.c +0 -1
  157. data/vendor/liburing/test/ring-leak2.c +1 -1
  158. data/vendor/liburing/test/ringbuf-read.c +10 -6
  159. data/vendor/liburing/test/send-zerocopy.c +273 -103
  160. data/vendor/liburing/test/send_recv.c +7 -4
  161. data/vendor/liburing/test/sendmsg_fs_cve.c +2 -2
  162. data/vendor/liburing/test/single-issuer.c +7 -9
  163. data/vendor/liburing/test/skip-cqe.c +3 -4
  164. data/vendor/liburing/test/socket.c +0 -1
  165. data/vendor/liburing/test/sq-poll-dup.c +10 -3
  166. data/vendor/liburing/test/sq-poll-kthread.c +1 -1
  167. data/vendor/liburing/test/sq-poll-share.c +3 -2
  168. data/vendor/liburing/test/sqpoll-cancel-hang.c +17 -6
  169. data/vendor/liburing/test/sqpoll-disable-exit.c +4 -4
  170. data/vendor/liburing/test/symlink.c +2 -1
  171. data/vendor/liburing/test/test.h +2 -1
  172. data/vendor/liburing/test/timeout-new.c +11 -7
  173. data/vendor/liburing/test/timeout.c +1 -2
  174. data/vendor/liburing/test/unlink.c +1 -1
  175. data/vendor/liburing/test/version.c +25 -0
  176. data/vendor/liburing/test/wakeup-hang.c +1 -1
  177. data/vendor/liburing/test/xattr.c +8 -4
  178. metadata +42 -6
  179. data/vendor/liburing/debian/compat +0 -1
  180. data/vendor/liburing/debian/liburing1-udeb.install +0 -1
  181. data/vendor/liburing/debian/liburing1.install +0 -1
  182. data/vendor/liburing/debian/liburing1.symbols +0 -32
@@ -0,0 +1,64 @@
1
+ .\" Copyright (C) 2023 Rutvik Patel <heyrutvik@gmail.com>
2
+ .\"
3
+ .\" SPDX-License-Identifier: LGPL-2.0-or-later
4
+ .\"
5
+ .TH io_uring_prep_setxattr 3 "January 23, 2023" "liburing-2.4" "liburing Manual"
6
+ .SH NAME
7
+ io_uring_prep_setxattr, io_uring_prep_fsetxattr \- prepare a request to set an
8
+ extended attribute value
9
+ .SH SYNOPSIS
10
+ .nf
11
+ .B #include <liburing.h>
12
+ .PP
13
+ .BI "void io_uring_prep_setxattr(struct io_uring_sqe *" sqe ","
14
+ .BI " const char *" name ","
15
+ .BI " const char *" value ","
16
+ .BI " const char *" path ","
17
+ .BI " int " flags ","
18
+ .BI " unsigned int " len ");"
19
+ .PP
20
+ .BI "void io_uring_prep_fsetxattr(struct io_uring_sqe *" sqe ","
21
+ .BI " int " fd ","
22
+ .BI " const char *" name ","
23
+ .BI " const char *" value ","
24
+ .BI " int " flags ","
25
+ .BI " unsigned int " len ");"
26
+ .fi
27
+ .SH DESCRIPTION
28
+ .PP
29
+ The
30
+ .BR io_uring_prep_setxattr (3)
31
+ function prepares a request to set an extended attribute value. The submission
32
+ queue entry
33
+ .I sqe
34
+ is setup to set the
35
+ .I value
36
+ of the extended attribute identified by
37
+ .I name
38
+ and associated with the given
39
+ .I path
40
+ in the filesystem with modifier flags
41
+ .IR flags .
42
+ The
43
+ .I len
44
+ argument specifies the size (in bytes) of
45
+ .IR value .
46
+
47
+ .BR io_uring_prep_fsetxattr (3)
48
+ is identical to
49
+ .BR io_uring_prep_setxattr (3),
50
+ only the extended attribute is set on the open file referred to by
51
+ .I fd
52
+ in place of
53
+ .IR path .
54
+
55
+ This function prepares an async
56
+ .BR setxattr (2)
57
+ request. See that man page for details.
58
+
59
+ .SH RETURN VALUE
60
+ None
61
+
62
+ .SH SEE ALSO
63
+ .BR io_uring_get_sqe (3),
64
+ .BR setxattr (2)
@@ -52,6 +52,36 @@ and
52
52
  .I fd_in
53
53
  given as a registered file descriptor offset.
54
54
 
55
+ If
56
+ .I fd_in
57
+ refers to a pipe,
58
+ .I off_in
59
+ is ignored and must be set to -1.
60
+
61
+ If
62
+ .I fd_in
63
+ does not refer to a pipe and
64
+ .I off_in
65
+ is -1, then
66
+ .I nbytes
67
+ are read from
68
+ .I fd_in
69
+ starting from the file offset, which is incremented by the number of bytes read.
70
+
71
+ If
72
+ .I fd_in
73
+ does not refer to a pipe and
74
+ .I off_in
75
+ is not -1, then the starting offset of
76
+ .I fd_in
77
+ will be
78
+ .IR off_in .
79
+
80
+ The same rules apply to
81
+ .I fd_out
82
+ and
83
+ .IR off_out .
84
+
55
85
  This function prepares an async
56
86
  .BR splice (2)
57
87
  request. See that man page for details.
@@ -78,3 +108,13 @@ field.
78
108
  .BR io_uring_submit (3),
79
109
  .BR io_uring_register (2),
80
110
  .BR splice (2)
111
+
112
+ .SH NOTES
113
+ Note that even if
114
+ .I fd_in
115
+ or
116
+ .I fd_out
117
+ refers to a pipe, the splice operation can still fail with
118
+ .B EINVAL
119
+ if one of the fd doesn't explicitly support splice operation, e.g. reading from
120
+ terminal is unsupported from kernel 5.7 to 5.11.
@@ -64,8 +64,8 @@ directly in the CQE
64
64
  .I res
65
65
  field.
66
66
  .SH NOTES
67
- Unless an application explicitly needs to pass in more than iovec, it is more
68
- efficient to use
67
+ Unless an application explicitly needs to pass in more than one iovec, it
68
+ is more efficient to use
69
69
  .BR io_uring_prep_write (3)
70
70
  rather than this function, as no state has to be maintained for a
71
71
  non-vectored IO request.
@@ -90,8 +90,8 @@ directly in the CQE
90
90
  .I res
91
91
  field.
92
92
  .SH NOTES
93
- Unless an application explicitly needs to pass in more than iovec, it is more
94
- efficient to use
93
+ Unless an application explicitly needs to pass in more than one iovec, it
94
+ is more efficient to use
95
95
  .BR io_uring_prep_write (3)
96
96
  rather than this function, as no state has to be maintained for a
97
97
  non-vectored IO request.
@@ -2,7 +2,7 @@
2
2
  .\"
3
3
  .\" SPDX-License-Identifier: LGPL-2.0-or-later
4
4
  .\"
5
- .TH io_uring_recvmsg_out 3 "Julyu 26, 2022" "liburing-2.2" "liburing Manual"
5
+ .TH io_uring_recvmsg_out 3 "July 26, 2022" "liburing-2.2" "liburing Manual"
6
6
  .SH NAME
7
7
  io_uring_recvmsg_out - access data from multishot recvmsg
8
8
  .SH SYNOPSIS
@@ -15,13 +15,13 @@ io_uring_recvmsg_out - access data from multishot recvmsg
15
15
  .PP
16
16
  .BI "void *io_uring_recvmsg_name(struct io_uring_recvmsg_out *" o ");"
17
17
  .PP
18
- .BI "struct cmsghdr *io_uring_recvmsg_cmsg_firsthdr(struct io_uring_recvmsg_out * " o ","
19
- .BI " struct msghdr *" msgh ");"
20
- .BI "struct cmsghdr *io_uring_recvmsg_cmsg_nexthdr(struct io_uring_recvmsg_out * " o ","
18
+ .BI "struct cmsghdr *io_uring_recvmsg_cmsg_firsthdr(struct io_uring_recvmsg_out *" o ","
19
+ .BI " struct msghdr *" msgh ");"
20
+ .BI "struct cmsghdr *io_uring_recvmsg_cmsg_nexthdr(struct io_uring_recvmsg_out *" o ","
21
21
  .BI " struct msghdr *" msgh ","
22
22
  .BI " struct cmsghdr *" cmsg ");"
23
23
  .PP
24
- .BI "void *io_uring_recvmsg_payload(struct io_uring_recvmsg_out * " o ","
24
+ .BI "void *io_uring_recvmsg_payload(struct io_uring_recvmsg_out *" o ","
25
25
  .BI " struct msghdr *" msgh ");"
26
26
  .BI "unsigned int io_uring_recvmsg_payload_length(struct io_uring_recvmsg_out *" o ","
27
27
  .BI " int " buf_len ","
@@ -32,12 +32,16 @@ io_uring_recvmsg_out - access data from multishot recvmsg
32
32
  .SH DESCRIPTION
33
33
 
34
34
  These functions are used to access data in the payload delivered by
35
- .BR io_uring_prep_recv_multishot (3)
36
- .
35
+ .BR io_uring_prep_recvmsg_multishot (3).
36
+ .PP
37
+ .I msgh
38
+ should point to the
39
+ .I struct msghdr
40
+ submitted with the request.
37
41
  .PP
38
42
  .BR io_uring_recvmsg_validate (3)
39
43
  will validate a buffer delivered by
40
- .BR io_uring_prep_recv_multishot (3)
44
+ .BR io_uring_prep_recvmsg_multishot (3)
41
45
  and extract the
42
46
  .I io_uring_recvmsg_out
43
47
  if it is valid, returning a pointer to it or else NULL.
@@ -75,4 +79,4 @@ Calculates the usable payload length in bytes.
75
79
 
76
80
 
77
81
  .SH "SEE ALSO"
78
- .BR io_uring_prep_recv_multishot (3)
82
+ .BR io_uring_prep_recvmsg_multishot (3)
@@ -31,6 +31,14 @@ application memory, greatly reducing per-I/O overhead.
31
31
  .I fd
32
32
  is the file descriptor returned by a call to
33
33
  .BR io_uring_setup (2).
34
+ If
35
+ .I opcode
36
+ has the flag
37
+ .B IORING_REGISTER_USE_REGISTERED_RING
38
+ ored into it,
39
+ .I fd
40
+ is instead the index of a registered ring fd.
41
+
34
42
  .I opcode
35
43
  can be one of:
36
44
 
@@ -620,20 +628,16 @@ is the desired size of the ring, and must be a power-of-2 in size. The maximum
620
628
  size allowed is 2^15 (32768).
621
629
  .I bgid
622
630
  is the buffer group ID associated with this ring. SQEs that select a buffer
623
- has a buffer group associated with them in their
631
+ have a buffer group associated with them in their
624
632
  .I buf_group
625
- field, and the associated CQE will have
633
+ field, and the associated CQEs will have
626
634
  .B IORING_CQE_F_BUFFER
627
635
  set in their
628
636
  .I flags
629
637
  member, which will also contain the specific ID of the buffer selected. The rest
630
638
  of the fields are reserved and must be cleared to zero.
631
639
 
632
- The
633
- .I flags
634
- argument is currently unused and must be set to zero.
635
-
636
- .i nr_args
640
+ .I nr_args
637
641
  must be set to 1.
638
642
 
639
643
  Also see
@@ -718,8 +722,10 @@ Available since 6.0.
718
722
 
719
723
  On success,
720
724
  .BR io_uring_register (2)
721
- returns 0. On error, a negative error code is returned. The caller should not
722
- rely on
725
+ returns either 0 or a positive value, depending on the
726
+ .I opcode
727
+ used. On error, a negative error value is returned. The caller should not rely
728
+ on the
723
729
  .I errno
724
730
  variable.
725
731
 
@@ -59,9 +59,9 @@ is the desired size of the ring, and must be a power-of-2 in size. The maximum
59
59
  size allowed is 2^15 (32768).
60
60
  .I bgid
61
61
  is the buffer group ID associated with this ring. SQEs that select a buffer
62
- has a buffer group associated with them in their
62
+ have a buffer group associated with them in their
63
63
  .I buf_group
64
- field, and the associated CQE will have
64
+ field, and the associated CQEs will have
65
65
  .B IORING_CQE_F_BUFFER
66
66
  set in their
67
67
  .I flags
@@ -118,12 +118,12 @@ is the buffer ID that will be returned in the CQE once consumed.
118
118
 
119
119
  Reserved fields must not be touched. Applications must use
120
120
  .BR io_uring_buf_ring_init (3)
121
- to initialise the buffer ring. Applications may use
121
+ to initialise the buffer ring before use. Applications may use
122
122
  .BR io_uring_buf_ring_add (3)
123
123
  and
124
124
  .BR io_uring_buf_ring_advance (3)
125
125
  or
126
- .BR io_uring_buf_ring_advance (3)
126
+ .BR io_uring_buf_ring_cq_advance (3)
127
127
  to provide buffers, which will set these fields and update the tail.
128
128
 
129
129
  Available since 5.19.
@@ -9,12 +9,23 @@ io_uring_register_buffers \- register buffers for fixed buffer operations
9
9
  .nf
10
10
  .B #include <liburing.h>
11
11
  .PP
12
- .BI "int io_uring_register_buffers(struct io_uring *" ring ",
13
- .BI " const struct iovec *" iovecs ",
12
+ .BI "int io_uring_register_buffers(struct io_uring *" ring ","
13
+ .BI " const struct iovec *" iovecs ","
14
14
  .BI " unsigned " nr_iovecs ");"
15
15
  .PP
16
- .BI "int io_uring_register_buffers_sparse(struct io_uring *" ring ",
17
- .BI " unsigned " nr_iovecs ");"
16
+ .BI "int io_uring_register_buffers_tags(struct io_uring *" ring ","
17
+ .BI " const struct iovec *" iovecs ","
18
+ .BI " const __u64 *" tags ","
19
+ .BI " unsigned " nr ");"
20
+ .PP
21
+ .BI "int io_uring_register_buffers_sparse(struct io_uring *" ring ","
22
+ .BI " unsigned " nr_iovecs ");"
23
+ .PP
24
+ .BI "int io_uring_register_buffers_update_tag(struct io_uring *" ring ","
25
+ .BI " unsigned " off ","
26
+ .BI " const struct iovec *" iovecs ","
27
+ .BI " const __u64 *" tags ","
28
+ .BI " unsigned " nr ");"
18
29
  .fi
19
30
  .SH DESCRIPTION
20
31
  .PP
@@ -27,6 +38,16 @@ number of buffers defined by the array
27
38
  belonging to the
28
39
  .IR ring .
29
40
 
41
+ The
42
+ .BR io_uring_register_buffers_tags (3)
43
+ function behaves the same as
44
+ .BR io_uring_register_buffers (3)
45
+ function but additionally takes
46
+ .I tags
47
+ parameter. See
48
+ .B IORING_REGISTER_BUFFERS2
49
+ for the resource tagging description.
50
+
30
51
  The
31
52
  .BR io_uring_register_buffers_sparse (3)
32
53
  function registers
@@ -46,14 +67,36 @@ the buffer is registered rather than doing a map and unmap for each IO
46
67
  every time IO is performed to that region. Additionally, it also avoids
47
68
  manipulating the page reference counts for each IO.
48
69
 
70
+ The
71
+ .BR io_uring_register_buffers_update_tag (3)
72
+ function updates registered buffers with new ones, either turning a sparse
73
+ entry into a real one, or replacing an existing entry. The
74
+ .I off
75
+ is offset on which to start the update
76
+ .I nr
77
+ number of buffers defined by the array
78
+ .I iovecs
79
+ belonging to the
80
+ .IR ring .
81
+ The
82
+ .I tags
83
+ points to an array of tags. See
84
+ .B IORING_REGISTER_BUFFERS2
85
+ for the resource tagging description.
86
+
49
87
  .SH RETURN VALUE
50
88
  On success
51
- .BR io_uring_register_buffers (3)
89
+ .BR io_uring_register_buffers (3),
90
+ .BR io_uring_register_buffers_tags (3)
52
91
  and
53
92
  .BR io_uring_register_buffers_sparse (3)
54
- return 0. On failure they return
93
+ return 0.
94
+ .BR io_uring_register_buffers_update_tag (3)
95
+ return number of buffers updated.
96
+ On failure they return
55
97
  .BR -errno .
56
98
  .SH SEE ALSO
99
+ .BR io_uring_register (2),
57
100
  .BR io_uring_get_sqe (3),
58
101
  .BR io_uring_unregister_buffers (3),
59
102
  .BR io_uring_register_buf_ring (3),
@@ -0,0 +1 @@
1
+ io_uring_register_buffers.3
@@ -0,0 +1 @@
1
+ io_uring_register_buffers.3
@@ -0,0 +1 @@
1
+ io_uring_register_buffers.3
@@ -13,8 +13,24 @@ io_uring_register_files \- register file descriptors
13
13
  .BI " const int *" files ","
14
14
  .BI " unsigned " nr_files ");"
15
15
  .PP
16
+ .BI "int io_uring_register_files_tags(struct io_uring *" ring ","
17
+ .BI " const int *" files ","
18
+ .BI " const __u64 *" tags ","
19
+ .BI " unsigned " nr ");"
20
+ .PP
16
21
  .BI "int io_uring_register_files_sparse(struct io_uring *" ring ","
17
- .BI " unsigned " nr_files ");"
22
+ .BI " unsigned " nr_files ");"
23
+ .PP
24
+ .BI "int io_uring_register_files_update(struct io_uring *" ring ","
25
+ .BI " unsigned " off ","
26
+ .BI " const int *" files ","
27
+ .BI " unsigned " nr_files ");"
28
+ .PP
29
+ .BI "int io_uring_register_files_update_tag(struct io_uring *" ring ","
30
+ .BI " unsigned " off ","
31
+ .BI " const int *" files ","
32
+ .BI " const __u64 *" tags ","
33
+ .BI " unsigned " nr_files ");"
18
34
  .fi
19
35
  .SH DESCRIPTION
20
36
  .PP
@@ -28,12 +44,23 @@ belonging to the
28
44
  .I ring
29
45
  for subsequent operations.
30
46
 
47
+ The
48
+ .BR io_uring_register_files_tags (3)
49
+ function behaves the same as
50
+ .BR io_uring_register_files (3)
51
+ function but additionally takes
52
+ .I tags
53
+ parameter. See
54
+ .B IORING_REGISTER_BUFFERS2
55
+ for the resource tagging description.
56
+
31
57
  The
32
58
  .BR io_uring_register_files_sparse (3)
33
59
  function registers an empty file table of
34
60
  .I nr_files
35
- number of file descriptors. The sparse variant is available in kernels 5.19
36
- and later.
61
+ number of file descriptors. These files must be updated before use, using eg
62
+ .BR io_uring_register_files_update_tag (3).
63
+ The sparse variant is available in kernels 5.19 and later.
37
64
 
38
65
  Registering a file table is a prerequisite for using any request that uses
39
66
  direct descriptors.
@@ -45,13 +72,41 @@ shared, for example if the process has ever created any threads, then this
45
72
  cost goes up even more. Using registered files reduces the overhead of
46
73
  file reference management across requests that operate on a file.
47
74
 
75
+ The
76
+ .BR io_uring_register_files_update (3)
77
+ function updates existing registered files. The
78
+ .I off
79
+ is offset on which to start the update
80
+ .I nr_files
81
+ number of files defined by the array
82
+ .I files
83
+ belonging to the
84
+ .IR ring .
85
+
86
+ The
87
+ .BR io_uring_register_files_update_tag (3)
88
+ function behaves the same as
89
+ .BR io_uring_register_files_update (3)
90
+ function but additionally takes
91
+ .I tags
92
+ parameter. See
93
+ .B IORING_REGISTER_BUFFERS2
94
+ for the resource tagging description.
95
+
48
96
  .SH RETURN VALUE
49
97
  On success
50
- .BR io_uring_register_files (3)
98
+ .BR io_uring_register_files (3),
99
+ .BR io_uring_register_files_tags (3)
51
100
  and
52
101
  .BR io_uring_register_files_sparse (3)
53
- return 0. On failure they return
102
+ return 0.
103
+ .BR io_uring_register_files_update (3)
104
+ and
105
+ .BR io_uring_register_files_update_tag (3)
106
+ return number of files updated.
107
+ On failure they return
54
108
  .BR -errno .
55
109
  .SH SEE ALSO
110
+ .BR io_uring_register (2),
56
111
  .BR io_uring_get_sqe (3),
57
112
  .BR io_uring_unregister_files (3)
@@ -0,0 +1 @@
1
+ io_uring_register_files.3
@@ -0,0 +1 @@
1
+ io_uring_register_files.3
@@ -0,0 +1 @@
1
+ io_uring_register_files.3
@@ -13,7 +13,7 @@ io_uring_setup \- setup a context for performing asynchronous I/O
13
13
  .PP
14
14
  .BI "int io_uring_setup(u32 " entries ", struct io_uring_params *" p );
15
15
  .fi
16
- .PPAA
16
+ .PP
17
17
  .SH DESCRIPTION
18
18
  .PP
19
19
  The
@@ -71,6 +71,14 @@ application must poll for completions on the CQ ring by calling
71
71
  It is illegal to mix and match polled and non-polled I/O on an io_uring
72
72
  instance.
73
73
 
74
+ This is only applicable for storage devices for now, and the storage device
75
+ must be configured for polling. How to do that depends on the device type
76
+ in question. For NVMe devices, the nvme driver must be loaded with the
77
+ .I poll_queues
78
+ parameter set to the desired number of polling queues. The polling queues
79
+ will be shared appropriately between the CPUs in the system, if the number
80
+ is less than the number of online CPU threads.
81
+
74
82
  .TP
75
83
  .B IORING_SETUP_SQPOLL
76
84
  When this flag is specified, a kernel thread is created to perform
@@ -119,6 +127,18 @@ is a submission queue ring setup using the
119
127
  described below.
120
128
  .TP
121
129
  .BR
130
+ Note that, when using a ring setup with
131
+ .B IORING_SETUP_SQPOLL,
132
+ you never directly call the
133
+ .BR io_uring_enter (2)
134
+ system call. That is usually taken care of by liburing's
135
+ .BR io_uring_submit (3)
136
+ function. It automatically determines if you are using
137
+ polling mode or not and deals with when your program needs to call
138
+ .BR io_uring_enter (2)
139
+ without you having to bother about it.
140
+ .TP
141
+ .BR
122
142
  Before version 5.11 of the Linux kernel, to successfully use this feature, the
123
143
  application must register a set of files to be used for IO through
124
144
  .BR io_uring_register (2)
@@ -132,7 +152,9 @@ feature flag.
132
152
  In version 5.11 and later, it is no longer necessary to register files to use
133
153
  this feature. 5.11 also allows using this as non-root, if the user has the
134
154
  .B CAP_SYS_NICE
135
- capability.
155
+ capability. In 5.13 this requirement was also relaxed, and no special privileges
156
+ are needed for SQPOLL in newer kernels. Certain stable kernels older than 5.13
157
+ may also support unprivileged SQPOLL.
136
158
  .TP
137
159
  .B IORING_SETUP_SQ_AFF
138
160
  If this flag is specified, then the poll thread will be bound to the
@@ -445,6 +467,13 @@ are used with open or accept, then file assignment needs to happen post
445
467
  execution of that SQE. If this flag is set, then the kernel will defer
446
468
  file assignment until execution of a given request is started. Available since
447
469
  kernel 5.17.
470
+ .TP
471
+ .B IORING_FEAT_REG_REG_RING
472
+ If this flag is set, then io_uring supports calling
473
+ .BR io_uring_register (2)
474
+ using a registered ring fd, via
475
+ .BR IORING_REGISTER_USE_REGISTERED_RING .
476
+ Available since kernel 6.3.
448
477
 
449
478
  .PP
450
479
  The rest of the fields in the
@@ -42,7 +42,7 @@ when waiting for a request.
42
42
 
43
43
  .SH RETURN VALUE
44
44
  On success
45
- .BR io_uring_wait_cqes (3)
45
+ .BR io_uring_wait_cqe_timeout (3)
46
46
  returns 0 and the cqe_ptr param is filled in. On failure it returns
47
47
  .BR -errno .
48
48
  The return value indicates the result of waiting for a CQE, and it has no
@@ -8,7 +8,8 @@ libdevdir ?= $(prefix)/lib
8
8
  LIBURING_CFLAGS ?=
9
9
  CPPFLAGS ?=
10
10
  override CPPFLAGS += -D_GNU_SOURCE \
11
- -Iinclude/ -include ../config-host.h
11
+ -Iinclude/ -include ../config-host.h \
12
+ -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
12
13
  CFLAGS ?= -g -O3 -Wall -Wextra -fno-stack-protector
13
14
  override CFLAGS += -Wno-unused-parameter -Wno-sign-compare \
14
15
  -DLIBURING_INTERNAL \
@@ -21,10 +22,15 @@ ENABLE_SHARED ?= 1
21
22
 
22
23
  soname=liburing.so.$(VERSION_MAJOR)
23
24
  libname=liburing.so.$(VERSION)
25
+ ffi_soname=liburing-ffi.so.$(VERSION_MAJOR)
26
+ ffi_libname=liburing-ffi.so.$(VERSION)
27
+
24
28
  all_targets += liburing.a
29
+ all_targets += liburing-ffi.a
25
30
 
26
31
  ifeq ($(ENABLE_SHARED),1)
27
32
  all_targets += $(libname)
33
+ all_targets += $(ffi_libname)
28
34
  endif
29
35
 
30
36
  include ../Makefile.quiet
@@ -35,7 +41,7 @@ endif
35
41
 
36
42
  all: $(all_targets)
37
43
 
38
- liburing_srcs := setup.c queue.c register.c syscall.c
44
+ liburing_srcs := setup.c queue.c register.c syscall.c version.c
39
45
 
40
46
  ifeq ($(CONFIG_NOLIBC),y)
41
47
  liburing_srcs += nolibc.c
@@ -47,6 +53,8 @@ endif
47
53
  override CPPFLAGS += -MT "$@" -MMD -MP -MF "$@.d"
48
54
  liburing_objs := $(patsubst %.c,%.ol,$(liburing_srcs))
49
55
  liburing_sobjs := $(patsubst %.c,%.os,$(liburing_srcs))
56
+ liburing_ffi_objs := ffi.ol
57
+ liburing_ffi_sobjs := ffi.os
50
58
 
51
59
  %.os: %.c
52
60
  $(QUIET_CC)$(CC) $(CPPFLAGS) $(SO_CFLAGS) -c -o $@ $<
@@ -65,25 +73,39 @@ liburing.a: $(liburing_objs)
65
73
  $(QUIET_AR)$(AR) r liburing.a $^
66
74
  $(QUIET_RANLIB)$(RANLIB) liburing.a
67
75
 
76
+ liburing-ffi.a: $(liburing_objs) $(liburing_ffi_objs)
77
+ @rm -f liburing-ffi.a
78
+ $(QUIET_AR)$(AR) r liburing-ffi.a $^
79
+ $(QUIET_RANLIB)$(RANLIB) liburing-ffi.a
80
+
68
81
  $(libname): $(liburing_sobjs) liburing.map
69
82
  $(QUIET_CC)$(CC) $(SO_CFLAGS) -shared -Wl,--version-script=liburing.map -Wl,-soname=$(soname) -o $@ $(liburing_sobjs) $(LINK_FLAGS)
70
83
 
84
+ $(ffi_libname): $(liburing_ffi_objs) $(liburing_ffi_sobjs) liburing-ffi.map
85
+ $(QUIET_CC)$(CC) $(SO_CFLAGS) -shared -Wl,--version-script=liburing-ffi.map -Wl,-soname=$(ffi_soname) -o $@ $(liburing_sobjs) $(liburing_ffi_sobjs) $(LINK_FLAGS)
86
+
71
87
  install: $(all_targets)
72
88
  install -D -m 644 include/liburing/io_uring.h $(includedir)/liburing/io_uring.h
73
89
  install -D -m 644 include/liburing.h $(includedir)/liburing.h
74
90
  install -D -m 644 include/liburing/compat.h $(includedir)/liburing/compat.h
75
91
  install -D -m 644 include/liburing/barrier.h $(includedir)/liburing/barrier.h
92
+ install -D -m 644 include/liburing/io_uring_version.h $(includedir)/liburing/io_uring_version.h
76
93
  install -D -m 644 liburing.a $(libdevdir)/liburing.a
94
+ install -D -m 644 liburing-ffi.a $(libdevdir)/liburing-ffi.a
77
95
  ifeq ($(ENABLE_SHARED),1)
78
96
  install -D -m 755 $(libname) $(libdir)/$(libname)
97
+ install -D -m 755 $(ffi_libname) $(libdir)/$(ffi_libname)
79
98
  ln -sf $(libname) $(libdir)/$(soname)
80
99
  ln -sf $(relativelibdir)$(libname) $(libdevdir)/liburing.so
100
+ ln -sf $(ffi_libname) $(libdir)/$(ffi_soname)
101
+ ln -sf $(relativelibdir)$(ffi_libname) $(libdevdir)/liburing-ffi.so
81
102
  endif
82
103
 
83
104
  clean:
84
- @rm -f $(all_targets) $(liburing_objs) $(liburing_sobjs) $(soname).new
105
+ @rm -f $(all_targets) $(liburing_objs) $(liburing_sobjs) $(liburing_ffi_objs) $(liburing_ffi_sobjs) $(soname).new
85
106
  @rm -f *.so* *.a *.o *.d
86
107
  @rm -f include/liburing/compat.h
108
+ @rm -f include/liburing/io_uring_version.h
87
109
 
88
110
  @# When cleaning, we don't include ../config-host.mak,
89
111
  @# so the nolibc objects are always skipped, clean them up!
@@ -0,0 +1,15 @@
1
+ /* SPDX-License-Identifier: MIT */
2
+ #define IOURINGINLINE
3
+
4
+ #ifdef __clang__
5
+ // clang doesn't seem to particularly like that we're including a header that
6
+ // deliberately contains function definitions so we explicitly silence it
7
+ #pragma clang diagnostic push
8
+ #pragma clang diagnostic ignored "-Wmissing-prototypes"
9
+ #endif
10
+
11
+ #include "liburing.h"
12
+
13
+ #ifdef __clang__
14
+ #pragma clang diagnostic pop
15
+ #endif