Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * io_uring opcode handling table |
| 4 | */ |
| 5 | #include <linux/kernel.h> |
| 6 | #include <linux/errno.h> |
| 7 | #include <linux/fs.h> |
| 8 | #include <linux/file.h> |
| 9 | #include <linux/io_uring.h> |
| 10 | |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 11 | #include "io_uring.h" |
| 12 | #include "opdef.h" |
| 13 | #include "refs.h" |
| 14 | #include "tctx.h" |
| 15 | #include "sqpoll.h" |
| 16 | #include "fdinfo.h" |
| 17 | #include "kbuf.h" |
| 18 | #include "rsrc.h" |
| 19 | |
| 20 | #include "xattr.h" |
| 21 | #include "nop.h" |
| 22 | #include "fs.h" |
| 23 | #include "splice.h" |
| 24 | #include "sync.h" |
| 25 | #include "advise.h" |
| 26 | #include "openclose.h" |
| 27 | #include "uring_cmd.h" |
| 28 | #include "epoll.h" |
| 29 | #include "statx.h" |
| 30 | #include "net.h" |
| 31 | #include "msg_ring.h" |
| 32 | #include "timeout.h" |
| 33 | #include "poll.h" |
| 34 | #include "cancel.h" |
| 35 | #include "rw.h" |
Jens Axboe | f31ecf67 | 2023-07-10 16:14:37 -0600 | [diff] [blame] | 36 | #include "waitid.h" |
Jens Axboe | 194bb58 | 2023-06-08 11:57:40 -0600 | [diff] [blame] | 37 | #include "futex.h" |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 38 | |
| 39 | static int io_no_issue(struct io_kiocb *req, unsigned int issue_flags) |
| 40 | { |
| 41 | WARN_ON_ONCE(1); |
| 42 | return -ECANCELED; |
| 43 | } |
| 44 | |
| 45 | static __maybe_unused int io_eopnotsupp_prep(struct io_kiocb *kiocb, |
| 46 | const struct io_uring_sqe *sqe) |
| 47 | { |
| 48 | return -EOPNOTSUPP; |
| 49 | } |
| 50 | |
Breno Leitao | a7dd278 | 2023-01-12 06:44:10 -0800 | [diff] [blame] | 51 | const struct io_issue_def io_issue_defs[] = { |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 52 | [IORING_OP_NOP] = { |
| 53 | .audit_skip = 1, |
| 54 | .iopoll = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 55 | .prep = io_nop_prep, |
| 56 | .issue = io_nop, |
| 57 | }, |
| 58 | [IORING_OP_READV] = { |
| 59 | .needs_file = 1, |
| 60 | .unbound_nonreg_file = 1, |
| 61 | .pollin = 1, |
| 62 | .buffer_select = 1, |
| 63 | .plug = 1, |
| 64 | .audit_skip = 1, |
| 65 | .ioprio = 1, |
| 66 | .iopoll = 1, |
Pavel Begunkov | ef0ec1a | 2022-12-07 03:53:26 +0000 | [diff] [blame] | 67 | .iopoll_queue = 1, |
Jens Axboe | d2d778f | 2023-09-11 13:46:07 -0600 | [diff] [blame] | 68 | .vectored = 1, |
Jens Axboe | 0e984ec | 2023-11-06 07:41:17 -0700 | [diff] [blame] | 69 | .prep = io_prep_rwv, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 70 | .issue = io_read, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 71 | }, |
| 72 | [IORING_OP_WRITEV] = { |
| 73 | .needs_file = 1, |
| 74 | .hash_reg_file = 1, |
| 75 | .unbound_nonreg_file = 1, |
| 76 | .pollout = 1, |
| 77 | .plug = 1, |
| 78 | .audit_skip = 1, |
| 79 | .ioprio = 1, |
| 80 | .iopoll = 1, |
Pavel Begunkov | ef0ec1a | 2022-12-07 03:53:26 +0000 | [diff] [blame] | 81 | .iopoll_queue = 1, |
Jens Axboe | d2d778f | 2023-09-11 13:46:07 -0600 | [diff] [blame] | 82 | .vectored = 1, |
Jens Axboe | 0e984ec | 2023-11-06 07:41:17 -0700 | [diff] [blame] | 83 | .prep = io_prep_rwv, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 84 | .issue = io_write, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 85 | }, |
| 86 | [IORING_OP_FSYNC] = { |
| 87 | .needs_file = 1, |
| 88 | .audit_skip = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 89 | .prep = io_fsync_prep, |
| 90 | .issue = io_fsync, |
| 91 | }, |
| 92 | [IORING_OP_READ_FIXED] = { |
| 93 | .needs_file = 1, |
| 94 | .unbound_nonreg_file = 1, |
| 95 | .pollin = 1, |
| 96 | .plug = 1, |
| 97 | .audit_skip = 1, |
| 98 | .ioprio = 1, |
| 99 | .iopoll = 1, |
Pavel Begunkov | ef0ec1a | 2022-12-07 03:53:26 +0000 | [diff] [blame] | 100 | .iopoll_queue = 1, |
Jens Axboe | f688944 | 2023-11-06 07:43:16 -0700 | [diff] [blame] | 101 | .prep = io_prep_rw_fixed, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 102 | .issue = io_read, |
| 103 | }, |
| 104 | [IORING_OP_WRITE_FIXED] = { |
| 105 | .needs_file = 1, |
| 106 | .hash_reg_file = 1, |
| 107 | .unbound_nonreg_file = 1, |
| 108 | .pollout = 1, |
| 109 | .plug = 1, |
| 110 | .audit_skip = 1, |
| 111 | .ioprio = 1, |
| 112 | .iopoll = 1, |
Pavel Begunkov | ef0ec1a | 2022-12-07 03:53:26 +0000 | [diff] [blame] | 113 | .iopoll_queue = 1, |
Jens Axboe | f688944 | 2023-11-06 07:43:16 -0700 | [diff] [blame] | 114 | .prep = io_prep_rw_fixed, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 115 | .issue = io_write, |
| 116 | }, |
| 117 | [IORING_OP_POLL_ADD] = { |
| 118 | .needs_file = 1, |
| 119 | .unbound_nonreg_file = 1, |
| 120 | .audit_skip = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 121 | .prep = io_poll_add_prep, |
| 122 | .issue = io_poll_add, |
| 123 | }, |
| 124 | [IORING_OP_POLL_REMOVE] = { |
| 125 | .audit_skip = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 126 | .prep = io_poll_remove_prep, |
| 127 | .issue = io_poll_remove, |
| 128 | }, |
| 129 | [IORING_OP_SYNC_FILE_RANGE] = { |
| 130 | .needs_file = 1, |
| 131 | .audit_skip = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 132 | .prep = io_sfr_prep, |
| 133 | .issue = io_sync_file_range, |
| 134 | }, |
| 135 | [IORING_OP_SENDMSG] = { |
| 136 | .needs_file = 1, |
| 137 | .unbound_nonreg_file = 1, |
| 138 | .pollout = 1, |
| 139 | .ioprio = 1, |
Pavel Begunkov | 858c293 | 2022-09-08 13:20:30 +0100 | [diff] [blame] | 140 | .manual_alloc = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 141 | #if defined(CONFIG_NET) |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 142 | .prep = io_sendmsg_prep, |
| 143 | .issue = io_sendmsg, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 144 | #else |
| 145 | .prep = io_eopnotsupp_prep, |
| 146 | #endif |
| 147 | }, |
| 148 | [IORING_OP_RECVMSG] = { |
| 149 | .needs_file = 1, |
| 150 | .unbound_nonreg_file = 1, |
| 151 | .pollin = 1, |
| 152 | .buffer_select = 1, |
| 153 | .ioprio = 1, |
Pavel Begunkov | 858c293 | 2022-09-08 13:20:30 +0100 | [diff] [blame] | 154 | .manual_alloc = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 155 | #if defined(CONFIG_NET) |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 156 | .prep = io_recvmsg_prep, |
| 157 | .issue = io_recvmsg, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 158 | #else |
| 159 | .prep = io_eopnotsupp_prep, |
| 160 | #endif |
| 161 | }, |
| 162 | [IORING_OP_TIMEOUT] = { |
| 163 | .audit_skip = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 164 | .prep = io_timeout_prep, |
| 165 | .issue = io_timeout, |
| 166 | }, |
| 167 | [IORING_OP_TIMEOUT_REMOVE] = { |
| 168 | /* used by timeout updates' prep() */ |
| 169 | .audit_skip = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 170 | .prep = io_timeout_remove_prep, |
| 171 | .issue = io_timeout_remove, |
| 172 | }, |
| 173 | [IORING_OP_ACCEPT] = { |
| 174 | .needs_file = 1, |
| 175 | .unbound_nonreg_file = 1, |
| 176 | .pollin = 1, |
| 177 | .poll_exclusive = 1, |
| 178 | .ioprio = 1, /* used for flags */ |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 179 | #if defined(CONFIG_NET) |
| 180 | .prep = io_accept_prep, |
| 181 | .issue = io_accept, |
| 182 | #else |
| 183 | .prep = io_eopnotsupp_prep, |
| 184 | #endif |
| 185 | }, |
| 186 | [IORING_OP_ASYNC_CANCEL] = { |
| 187 | .audit_skip = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 188 | .prep = io_async_cancel_prep, |
| 189 | .issue = io_async_cancel, |
| 190 | }, |
| 191 | [IORING_OP_LINK_TIMEOUT] = { |
| 192 | .audit_skip = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 193 | .prep = io_link_timeout_prep, |
| 194 | .issue = io_no_issue, |
| 195 | }, |
| 196 | [IORING_OP_CONNECT] = { |
| 197 | .needs_file = 1, |
| 198 | .unbound_nonreg_file = 1, |
| 199 | .pollout = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 200 | #if defined(CONFIG_NET) |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 201 | .prep = io_connect_prep, |
| 202 | .issue = io_connect, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 203 | #else |
| 204 | .prep = io_eopnotsupp_prep, |
| 205 | #endif |
| 206 | }, |
| 207 | [IORING_OP_FALLOCATE] = { |
| 208 | .needs_file = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 209 | .prep = io_fallocate_prep, |
| 210 | .issue = io_fallocate, |
| 211 | }, |
| 212 | [IORING_OP_OPENAT] = { |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 213 | .prep = io_openat_prep, |
| 214 | .issue = io_openat, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 215 | }, |
| 216 | [IORING_OP_CLOSE] = { |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 217 | .prep = io_close_prep, |
| 218 | .issue = io_close, |
| 219 | }, |
Pavel Begunkov | d9808ce | 2022-09-01 11:54:02 +0100 | [diff] [blame] | 220 | [IORING_OP_FILES_UPDATE] = { |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 221 | .audit_skip = 1, |
| 222 | .iopoll = 1, |
Pavel Begunkov | d9808ce | 2022-09-01 11:54:02 +0100 | [diff] [blame] | 223 | .prep = io_files_update_prep, |
| 224 | .issue = io_files_update, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 225 | }, |
| 226 | [IORING_OP_STATX] = { |
| 227 | .audit_skip = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 228 | .prep = io_statx_prep, |
| 229 | .issue = io_statx, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 230 | }, |
| 231 | [IORING_OP_READ] = { |
| 232 | .needs_file = 1, |
| 233 | .unbound_nonreg_file = 1, |
| 234 | .pollin = 1, |
| 235 | .buffer_select = 1, |
| 236 | .plug = 1, |
| 237 | .audit_skip = 1, |
| 238 | .ioprio = 1, |
| 239 | .iopoll = 1, |
Pavel Begunkov | ef0ec1a | 2022-12-07 03:53:26 +0000 | [diff] [blame] | 240 | .iopoll_queue = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 241 | .prep = io_prep_rw, |
| 242 | .issue = io_read, |
| 243 | }, |
| 244 | [IORING_OP_WRITE] = { |
| 245 | .needs_file = 1, |
| 246 | .hash_reg_file = 1, |
| 247 | .unbound_nonreg_file = 1, |
| 248 | .pollout = 1, |
| 249 | .plug = 1, |
| 250 | .audit_skip = 1, |
| 251 | .ioprio = 1, |
| 252 | .iopoll = 1, |
Pavel Begunkov | ef0ec1a | 2022-12-07 03:53:26 +0000 | [diff] [blame] | 253 | .iopoll_queue = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 254 | .prep = io_prep_rw, |
| 255 | .issue = io_write, |
| 256 | }, |
| 257 | [IORING_OP_FADVISE] = { |
| 258 | .needs_file = 1, |
| 259 | .audit_skip = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 260 | .prep = io_fadvise_prep, |
| 261 | .issue = io_fadvise, |
| 262 | }, |
| 263 | [IORING_OP_MADVISE] = { |
Richard Guy Briggs | fbe870a | 2023-02-01 15:33:33 -0500 | [diff] [blame] | 264 | .audit_skip = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 265 | .prep = io_madvise_prep, |
| 266 | .issue = io_madvise, |
| 267 | }, |
| 268 | [IORING_OP_SEND] = { |
| 269 | .needs_file = 1, |
| 270 | .unbound_nonreg_file = 1, |
| 271 | .pollout = 1, |
| 272 | .audit_skip = 1, |
| 273 | .ioprio = 1, |
Pavel Begunkov | 516e82f | 2022-09-21 12:17:51 +0100 | [diff] [blame] | 274 | .manual_alloc = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 275 | #if defined(CONFIG_NET) |
| 276 | .prep = io_sendmsg_prep, |
| 277 | .issue = io_send, |
| 278 | #else |
| 279 | .prep = io_eopnotsupp_prep, |
| 280 | #endif |
| 281 | }, |
| 282 | [IORING_OP_RECV] = { |
| 283 | .needs_file = 1, |
| 284 | .unbound_nonreg_file = 1, |
| 285 | .pollin = 1, |
| 286 | .buffer_select = 1, |
| 287 | .audit_skip = 1, |
| 288 | .ioprio = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 289 | #if defined(CONFIG_NET) |
| 290 | .prep = io_recvmsg_prep, |
| 291 | .issue = io_recv, |
| 292 | #else |
| 293 | .prep = io_eopnotsupp_prep, |
| 294 | #endif |
| 295 | }, |
| 296 | [IORING_OP_OPENAT2] = { |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 297 | .prep = io_openat2_prep, |
| 298 | .issue = io_openat2, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 299 | }, |
| 300 | [IORING_OP_EPOLL_CTL] = { |
| 301 | .unbound_nonreg_file = 1, |
| 302 | .audit_skip = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 303 | #if defined(CONFIG_EPOLL) |
| 304 | .prep = io_epoll_ctl_prep, |
| 305 | .issue = io_epoll_ctl, |
| 306 | #else |
| 307 | .prep = io_eopnotsupp_prep, |
| 308 | #endif |
| 309 | }, |
| 310 | [IORING_OP_SPLICE] = { |
| 311 | .needs_file = 1, |
| 312 | .hash_reg_file = 1, |
| 313 | .unbound_nonreg_file = 1, |
| 314 | .audit_skip = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 315 | .prep = io_splice_prep, |
| 316 | .issue = io_splice, |
| 317 | }, |
| 318 | [IORING_OP_PROVIDE_BUFFERS] = { |
| 319 | .audit_skip = 1, |
| 320 | .iopoll = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 321 | .prep = io_provide_buffers_prep, |
| 322 | .issue = io_provide_buffers, |
| 323 | }, |
| 324 | [IORING_OP_REMOVE_BUFFERS] = { |
| 325 | .audit_skip = 1, |
| 326 | .iopoll = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 327 | .prep = io_remove_buffers_prep, |
| 328 | .issue = io_remove_buffers, |
| 329 | }, |
| 330 | [IORING_OP_TEE] = { |
| 331 | .needs_file = 1, |
| 332 | .hash_reg_file = 1, |
| 333 | .unbound_nonreg_file = 1, |
| 334 | .audit_skip = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 335 | .prep = io_tee_prep, |
| 336 | .issue = io_tee, |
| 337 | }, |
| 338 | [IORING_OP_SHUTDOWN] = { |
| 339 | .needs_file = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 340 | #if defined(CONFIG_NET) |
| 341 | .prep = io_shutdown_prep, |
| 342 | .issue = io_shutdown, |
| 343 | #else |
| 344 | .prep = io_eopnotsupp_prep, |
| 345 | #endif |
| 346 | }, |
| 347 | [IORING_OP_RENAMEAT] = { |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 348 | .prep = io_renameat_prep, |
| 349 | .issue = io_renameat, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 350 | }, |
| 351 | [IORING_OP_UNLINKAT] = { |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 352 | .prep = io_unlinkat_prep, |
| 353 | .issue = io_unlinkat, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 354 | }, |
| 355 | [IORING_OP_MKDIRAT] = { |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 356 | .prep = io_mkdirat_prep, |
| 357 | .issue = io_mkdirat, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 358 | }, |
| 359 | [IORING_OP_SYMLINKAT] = { |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 360 | .prep = io_symlinkat_prep, |
| 361 | .issue = io_symlinkat, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 362 | }, |
| 363 | [IORING_OP_LINKAT] = { |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 364 | .prep = io_linkat_prep, |
| 365 | .issue = io_linkat, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 366 | }, |
| 367 | [IORING_OP_MSG_RING] = { |
| 368 | .needs_file = 1, |
| 369 | .iopoll = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 370 | .prep = io_msg_ring_prep, |
| 371 | .issue = io_msg_ring, |
| 372 | }, |
| 373 | [IORING_OP_FSETXATTR] = { |
| 374 | .needs_file = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 375 | .prep = io_fsetxattr_prep, |
| 376 | .issue = io_fsetxattr, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 377 | }, |
| 378 | [IORING_OP_SETXATTR] = { |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 379 | .prep = io_setxattr_prep, |
| 380 | .issue = io_setxattr, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 381 | }, |
| 382 | [IORING_OP_FGETXATTR] = { |
| 383 | .needs_file = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 384 | .prep = io_fgetxattr_prep, |
| 385 | .issue = io_fgetxattr, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 386 | }, |
| 387 | [IORING_OP_GETXATTR] = { |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 388 | .prep = io_getxattr_prep, |
| 389 | .issue = io_getxattr, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 390 | }, |
| 391 | [IORING_OP_SOCKET] = { |
| 392 | .audit_skip = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 393 | #if defined(CONFIG_NET) |
| 394 | .prep = io_socket_prep, |
| 395 | .issue = io_socket, |
| 396 | #else |
| 397 | .prep = io_eopnotsupp_prep, |
| 398 | #endif |
| 399 | }, |
| 400 | [IORING_OP_URING_CMD] = { |
| 401 | .needs_file = 1, |
| 402 | .plug = 1, |
Kanchan Joshi | 5756a3a | 2022-08-23 21:44:41 +0530 | [diff] [blame] | 403 | .iopoll = 1, |
Pavel Begunkov | ef0ec1a | 2022-12-07 03:53:26 +0000 | [diff] [blame] | 404 | .iopoll_queue = 1, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 405 | .prep = io_uring_cmd_prep, |
| 406 | .issue = io_uring_cmd, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 407 | }, |
Pavel Begunkov | b48c312 | 2022-09-01 11:54:04 +0100 | [diff] [blame] | 408 | [IORING_OP_SEND_ZC] = { |
Pavel Begunkov | 06a5464 | 2022-07-12 21:52:43 +0100 | [diff] [blame] | 409 | .needs_file = 1, |
| 410 | .unbound_nonreg_file = 1, |
| 411 | .pollout = 1, |
| 412 | .audit_skip = 1, |
| 413 | .ioprio = 1, |
Pavel Begunkov | 581711c | 2022-08-24 13:07:43 +0100 | [diff] [blame] | 414 | .manual_alloc = 1, |
Pavel Begunkov | 06a5464 | 2022-07-12 21:52:43 +0100 | [diff] [blame] | 415 | #if defined(CONFIG_NET) |
Pavel Begunkov | b0e9b55 | 2022-09-21 12:17:52 +0100 | [diff] [blame] | 416 | .prep = io_send_zc_prep, |
| 417 | .issue = io_send_zc, |
Pavel Begunkov | 06a5464 | 2022-07-12 21:52:43 +0100 | [diff] [blame] | 418 | #else |
| 419 | .prep = io_eopnotsupp_prep, |
| 420 | #endif |
Pavel Begunkov | 06a5464 | 2022-07-12 21:52:43 +0100 | [diff] [blame] | 421 | }, |
Pavel Begunkov | 493108d | 2022-09-21 12:17:54 +0100 | [diff] [blame] | 422 | [IORING_OP_SENDMSG_ZC] = { |
Pavel Begunkov | 493108d | 2022-09-21 12:17:54 +0100 | [diff] [blame] | 423 | .needs_file = 1, |
| 424 | .unbound_nonreg_file = 1, |
| 425 | .pollout = 1, |
Pavel Begunkov | 493108d | 2022-09-21 12:17:54 +0100 | [diff] [blame] | 426 | .ioprio = 1, |
| 427 | .manual_alloc = 1, |
| 428 | #if defined(CONFIG_NET) |
Pavel Begunkov | 493108d | 2022-09-21 12:17:54 +0100 | [diff] [blame] | 429 | .prep = io_send_zc_prep, |
| 430 | .issue = io_sendmsg_zc, |
Breno Leitao | f30bd4d | 2023-01-12 06:44:11 -0800 | [diff] [blame] | 431 | #else |
| 432 | .prep = io_eopnotsupp_prep, |
| 433 | #endif |
| 434 | }, |
Jens Axboe | fc68fcd | 2023-09-11 13:35:42 -0600 | [diff] [blame] | 435 | [IORING_OP_READ_MULTISHOT] = { |
| 436 | .needs_file = 1, |
| 437 | .unbound_nonreg_file = 1, |
| 438 | .pollin = 1, |
| 439 | .buffer_select = 1, |
| 440 | .audit_skip = 1, |
| 441 | .prep = io_read_mshot_prep, |
| 442 | .issue = io_read_mshot, |
| 443 | }, |
Jens Axboe | f31ecf67 | 2023-07-10 16:14:37 -0600 | [diff] [blame] | 444 | [IORING_OP_WAITID] = { |
| 445 | .prep = io_waitid_prep, |
| 446 | .issue = io_waitid, |
| 447 | }, |
Jens Axboe | 194bb58 | 2023-06-08 11:57:40 -0600 | [diff] [blame] | 448 | [IORING_OP_FUTEX_WAIT] = { |
| 449 | #if defined(CONFIG_FUTEX) |
| 450 | .prep = io_futex_prep, |
| 451 | .issue = io_futex_wait, |
| 452 | #else |
| 453 | .prep = io_eopnotsupp_prep, |
| 454 | #endif |
| 455 | }, |
| 456 | [IORING_OP_FUTEX_WAKE] = { |
| 457 | #if defined(CONFIG_FUTEX) |
| 458 | .prep = io_futex_prep, |
| 459 | .issue = io_futex_wake, |
| 460 | #else |
| 461 | .prep = io_eopnotsupp_prep, |
| 462 | #endif |
| 463 | }, |
Jens Axboe | 8f35019 | 2023-06-12 19:04:32 -0600 | [diff] [blame] | 464 | [IORING_OP_FUTEX_WAITV] = { |
| 465 | #if defined(CONFIG_FUTEX) |
| 466 | .prep = io_futexv_prep, |
| 467 | .issue = io_futexv_wait, |
| 468 | #else |
| 469 | .prep = io_eopnotsupp_prep, |
| 470 | #endif |
| 471 | }, |
Jens Axboe | dc18b89 | 2023-12-07 20:06:02 -0700 | [diff] [blame] | 472 | [IORING_OP_FIXED_FD_INSTALL] = { |
| 473 | .needs_file = 1, |
| 474 | .audit_skip = 1, |
| 475 | .prep = io_install_fixed_fd_prep, |
| 476 | .issue = io_install_fixed_fd, |
| 477 | }, |
Breno Leitao | f30bd4d | 2023-01-12 06:44:11 -0800 | [diff] [blame] | 478 | }; |
| 479 | |
Breno Leitao | f30bd4d | 2023-01-12 06:44:11 -0800 | [diff] [blame] | 480 | const struct io_cold_def io_cold_defs[] = { |
| 481 | [IORING_OP_NOP] = { |
| 482 | .name = "NOP", |
| 483 | }, |
| 484 | [IORING_OP_READV] = { |
| 485 | .async_size = sizeof(struct io_async_rw), |
| 486 | .name = "READV", |
| 487 | .prep_async = io_readv_prep_async, |
| 488 | .cleanup = io_readv_writev_cleanup, |
| 489 | .fail = io_rw_fail, |
| 490 | }, |
| 491 | [IORING_OP_WRITEV] = { |
| 492 | .async_size = sizeof(struct io_async_rw), |
| 493 | .name = "WRITEV", |
| 494 | .prep_async = io_writev_prep_async, |
| 495 | .cleanup = io_readv_writev_cleanup, |
| 496 | .fail = io_rw_fail, |
| 497 | }, |
| 498 | [IORING_OP_FSYNC] = { |
| 499 | .name = "FSYNC", |
| 500 | }, |
| 501 | [IORING_OP_READ_FIXED] = { |
| 502 | .async_size = sizeof(struct io_async_rw), |
| 503 | .name = "READ_FIXED", |
| 504 | .fail = io_rw_fail, |
| 505 | }, |
| 506 | [IORING_OP_WRITE_FIXED] = { |
| 507 | .async_size = sizeof(struct io_async_rw), |
| 508 | .name = "WRITE_FIXED", |
| 509 | .fail = io_rw_fail, |
| 510 | }, |
| 511 | [IORING_OP_POLL_ADD] = { |
| 512 | .name = "POLL_ADD", |
| 513 | }, |
| 514 | [IORING_OP_POLL_REMOVE] = { |
| 515 | .name = "POLL_REMOVE", |
| 516 | }, |
| 517 | [IORING_OP_SYNC_FILE_RANGE] = { |
| 518 | .name = "SYNC_FILE_RANGE", |
| 519 | }, |
| 520 | [IORING_OP_SENDMSG] = { |
| 521 | .name = "SENDMSG", |
| 522 | #if defined(CONFIG_NET) |
| 523 | .async_size = sizeof(struct io_async_msghdr), |
| 524 | .prep_async = io_sendmsg_prep_async, |
| 525 | .cleanup = io_sendmsg_recvmsg_cleanup, |
| 526 | .fail = io_sendrecv_fail, |
| 527 | #endif |
| 528 | }, |
| 529 | [IORING_OP_RECVMSG] = { |
| 530 | .name = "RECVMSG", |
| 531 | #if defined(CONFIG_NET) |
| 532 | .async_size = sizeof(struct io_async_msghdr), |
| 533 | .prep_async = io_recvmsg_prep_async, |
| 534 | .cleanup = io_sendmsg_recvmsg_cleanup, |
| 535 | .fail = io_sendrecv_fail, |
| 536 | #endif |
| 537 | }, |
| 538 | [IORING_OP_TIMEOUT] = { |
| 539 | .async_size = sizeof(struct io_timeout_data), |
| 540 | .name = "TIMEOUT", |
| 541 | }, |
| 542 | [IORING_OP_TIMEOUT_REMOVE] = { |
| 543 | .name = "TIMEOUT_REMOVE", |
| 544 | }, |
| 545 | [IORING_OP_ACCEPT] = { |
| 546 | .name = "ACCEPT", |
| 547 | }, |
| 548 | [IORING_OP_ASYNC_CANCEL] = { |
| 549 | .name = "ASYNC_CANCEL", |
| 550 | }, |
| 551 | [IORING_OP_LINK_TIMEOUT] = { |
| 552 | .async_size = sizeof(struct io_timeout_data), |
| 553 | .name = "LINK_TIMEOUT", |
| 554 | }, |
| 555 | [IORING_OP_CONNECT] = { |
| 556 | .name = "CONNECT", |
| 557 | #if defined(CONFIG_NET) |
| 558 | .async_size = sizeof(struct io_async_connect), |
| 559 | .prep_async = io_connect_prep_async, |
| 560 | #endif |
| 561 | }, |
| 562 | [IORING_OP_FALLOCATE] = { |
| 563 | .name = "FALLOCATE", |
| 564 | }, |
| 565 | [IORING_OP_OPENAT] = { |
| 566 | .name = "OPENAT", |
| 567 | .cleanup = io_open_cleanup, |
| 568 | }, |
| 569 | [IORING_OP_CLOSE] = { |
| 570 | .name = "CLOSE", |
| 571 | }, |
| 572 | [IORING_OP_FILES_UPDATE] = { |
| 573 | .name = "FILES_UPDATE", |
| 574 | }, |
| 575 | [IORING_OP_STATX] = { |
| 576 | .name = "STATX", |
| 577 | .cleanup = io_statx_cleanup, |
| 578 | }, |
| 579 | [IORING_OP_READ] = { |
| 580 | .async_size = sizeof(struct io_async_rw), |
| 581 | .name = "READ", |
| 582 | .fail = io_rw_fail, |
| 583 | }, |
| 584 | [IORING_OP_WRITE] = { |
| 585 | .async_size = sizeof(struct io_async_rw), |
| 586 | .name = "WRITE", |
| 587 | .fail = io_rw_fail, |
| 588 | }, |
| 589 | [IORING_OP_FADVISE] = { |
| 590 | .name = "FADVISE", |
| 591 | }, |
| 592 | [IORING_OP_MADVISE] = { |
| 593 | .name = "MADVISE", |
| 594 | }, |
| 595 | [IORING_OP_SEND] = { |
| 596 | .name = "SEND", |
| 597 | #if defined(CONFIG_NET) |
| 598 | .async_size = sizeof(struct io_async_msghdr), |
| 599 | .fail = io_sendrecv_fail, |
| 600 | .prep_async = io_send_prep_async, |
| 601 | #endif |
| 602 | }, |
| 603 | [IORING_OP_RECV] = { |
| 604 | .name = "RECV", |
| 605 | #if defined(CONFIG_NET) |
| 606 | .fail = io_sendrecv_fail, |
| 607 | #endif |
| 608 | }, |
| 609 | [IORING_OP_OPENAT2] = { |
| 610 | .name = "OPENAT2", |
| 611 | .cleanup = io_open_cleanup, |
| 612 | }, |
| 613 | [IORING_OP_EPOLL_CTL] = { |
| 614 | .name = "EPOLL", |
| 615 | }, |
| 616 | [IORING_OP_SPLICE] = { |
| 617 | .name = "SPLICE", |
| 618 | }, |
| 619 | [IORING_OP_PROVIDE_BUFFERS] = { |
| 620 | .name = "PROVIDE_BUFFERS", |
| 621 | }, |
| 622 | [IORING_OP_REMOVE_BUFFERS] = { |
| 623 | .name = "REMOVE_BUFFERS", |
| 624 | }, |
| 625 | [IORING_OP_TEE] = { |
| 626 | .name = "TEE", |
| 627 | }, |
| 628 | [IORING_OP_SHUTDOWN] = { |
| 629 | .name = "SHUTDOWN", |
| 630 | }, |
| 631 | [IORING_OP_RENAMEAT] = { |
| 632 | .name = "RENAMEAT", |
| 633 | .cleanup = io_renameat_cleanup, |
| 634 | }, |
| 635 | [IORING_OP_UNLINKAT] = { |
| 636 | .name = "UNLINKAT", |
| 637 | .cleanup = io_unlinkat_cleanup, |
| 638 | }, |
| 639 | [IORING_OP_MKDIRAT] = { |
| 640 | .name = "MKDIRAT", |
| 641 | .cleanup = io_mkdirat_cleanup, |
| 642 | }, |
| 643 | [IORING_OP_SYMLINKAT] = { |
| 644 | .name = "SYMLINKAT", |
| 645 | .cleanup = io_link_cleanup, |
| 646 | }, |
| 647 | [IORING_OP_LINKAT] = { |
| 648 | .name = "LINKAT", |
| 649 | .cleanup = io_link_cleanup, |
| 650 | }, |
| 651 | [IORING_OP_MSG_RING] = { |
| 652 | .name = "MSG_RING", |
| 653 | .cleanup = io_msg_ring_cleanup, |
| 654 | }, |
| 655 | [IORING_OP_FSETXATTR] = { |
| 656 | .name = "FSETXATTR", |
| 657 | .cleanup = io_xattr_cleanup, |
| 658 | }, |
| 659 | [IORING_OP_SETXATTR] = { |
| 660 | .name = "SETXATTR", |
| 661 | .cleanup = io_xattr_cleanup, |
| 662 | }, |
| 663 | [IORING_OP_FGETXATTR] = { |
| 664 | .name = "FGETXATTR", |
| 665 | .cleanup = io_xattr_cleanup, |
| 666 | }, |
| 667 | [IORING_OP_GETXATTR] = { |
| 668 | .name = "GETXATTR", |
| 669 | .cleanup = io_xattr_cleanup, |
| 670 | }, |
| 671 | [IORING_OP_SOCKET] = { |
| 672 | .name = "SOCKET", |
| 673 | }, |
| 674 | [IORING_OP_URING_CMD] = { |
| 675 | .name = "URING_CMD", |
Breno Leitao | fd9b854 | 2023-05-04 05:18:55 -0700 | [diff] [blame] | 676 | .async_size = 2 * sizeof(struct io_uring_sqe), |
Breno Leitao | f30bd4d | 2023-01-12 06:44:11 -0800 | [diff] [blame] | 677 | .prep_async = io_uring_cmd_prep_async, |
| 678 | }, |
| 679 | [IORING_OP_SEND_ZC] = { |
| 680 | .name = "SEND_ZC", |
| 681 | #if defined(CONFIG_NET) |
| 682 | .async_size = sizeof(struct io_async_msghdr), |
| 683 | .prep_async = io_send_prep_async, |
| 684 | .cleanup = io_send_zc_cleanup, |
| 685 | .fail = io_sendrecv_fail, |
| 686 | #endif |
| 687 | }, |
| 688 | [IORING_OP_SENDMSG_ZC] = { |
| 689 | .name = "SENDMSG_ZC", |
| 690 | #if defined(CONFIG_NET) |
| 691 | .async_size = sizeof(struct io_async_msghdr), |
Pavel Begunkov | 493108d | 2022-09-21 12:17:54 +0100 | [diff] [blame] | 692 | .prep_async = io_sendmsg_prep_async, |
| 693 | .cleanup = io_send_zc_cleanup, |
| 694 | .fail = io_sendrecv_fail, |
Pavel Begunkov | 493108d | 2022-09-21 12:17:54 +0100 | [diff] [blame] | 695 | #endif |
| 696 | }, |
Jens Axboe | fc68fcd | 2023-09-11 13:35:42 -0600 | [diff] [blame] | 697 | [IORING_OP_READ_MULTISHOT] = { |
| 698 | .name = "READ_MULTISHOT", |
| 699 | }, |
Jens Axboe | f31ecf67 | 2023-07-10 16:14:37 -0600 | [diff] [blame] | 700 | [IORING_OP_WAITID] = { |
| 701 | .name = "WAITID", |
| 702 | .async_size = sizeof(struct io_waitid_async), |
| 703 | }, |
Jens Axboe | 194bb58 | 2023-06-08 11:57:40 -0600 | [diff] [blame] | 704 | [IORING_OP_FUTEX_WAIT] = { |
| 705 | .name = "FUTEX_WAIT", |
| 706 | }, |
| 707 | [IORING_OP_FUTEX_WAKE] = { |
| 708 | .name = "FUTEX_WAKE", |
| 709 | }, |
Jens Axboe | 8f35019 | 2023-06-12 19:04:32 -0600 | [diff] [blame] | 710 | [IORING_OP_FUTEX_WAITV] = { |
| 711 | .name = "FUTEX_WAITV", |
| 712 | }, |
Jens Axboe | dc18b89 | 2023-12-07 20:06:02 -0700 | [diff] [blame] | 713 | [IORING_OP_FIXED_FD_INSTALL] = { |
| 714 | .name = "FIXED_FD_INSTALL", |
| 715 | }, |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 716 | }; |
| 717 | |
| 718 | const char *io_uring_get_opcode(u8 opcode) |
| 719 | { |
| 720 | if (opcode < IORING_OP_LAST) |
Breno Leitao | f30bd4d | 2023-01-12 06:44:11 -0800 | [diff] [blame] | 721 | return io_cold_defs[opcode].name; |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 722 | return "INVALID"; |
| 723 | } |
| 724 | |
| 725 | void __init io_uring_optable_init(void) |
| 726 | { |
| 727 | int i; |
| 728 | |
Breno Leitao | f30bd4d | 2023-01-12 06:44:11 -0800 | [diff] [blame] | 729 | BUILD_BUG_ON(ARRAY_SIZE(io_cold_defs) != IORING_OP_LAST); |
Breno Leitao | a7dd278 | 2023-01-12 06:44:10 -0800 | [diff] [blame] | 730 | BUILD_BUG_ON(ARRAY_SIZE(io_issue_defs) != IORING_OP_LAST); |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 731 | |
Breno Leitao | a7dd278 | 2023-01-12 06:44:10 -0800 | [diff] [blame] | 732 | for (i = 0; i < ARRAY_SIZE(io_issue_defs); i++) { |
| 733 | BUG_ON(!io_issue_defs[i].prep); |
| 734 | if (io_issue_defs[i].prep != io_eopnotsupp_prep) |
| 735 | BUG_ON(!io_issue_defs[i].issue); |
Breno Leitao | f30bd4d | 2023-01-12 06:44:11 -0800 | [diff] [blame] | 736 | WARN_ON_ONCE(!io_cold_defs[i].name); |
Jens Axboe | d9b57aa | 2022-06-15 16:27:42 -0600 | [diff] [blame] | 737 | } |
| 738 | } |