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