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