xref: /linux-6.15/io_uring/opdef.c (revision e10677a8)
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 #if defined(CONFIG_NET)
285 		.async_size		= sizeof(struct io_async_msghdr),
286 		.prep			= io_sendmsg_prep,
287 		.issue			= io_send,
288 #else
289 		.prep			= io_eopnotsupp_prep,
290 #endif
291 	},
292 	[IORING_OP_RECV] = {
293 		.needs_file		= 1,
294 		.unbound_nonreg_file	= 1,
295 		.pollin			= 1,
296 		.buffer_select		= 1,
297 		.audit_skip		= 1,
298 		.ioprio			= 1,
299 #if defined(CONFIG_NET)
300 		.async_size		= sizeof(struct io_async_msghdr),
301 		.prep			= io_recvmsg_prep,
302 		.issue			= io_recv,
303 #else
304 		.prep			= io_eopnotsupp_prep,
305 #endif
306 	},
307 	[IORING_OP_OPENAT2] = {
308 		.prep			= io_openat2_prep,
309 		.issue			= io_openat2,
310 	},
311 	[IORING_OP_EPOLL_CTL] = {
312 		.unbound_nonreg_file	= 1,
313 		.audit_skip		= 1,
314 #if defined(CONFIG_EPOLL)
315 		.prep			= io_epoll_ctl_prep,
316 		.issue			= io_epoll_ctl,
317 #else
318 		.prep			= io_eopnotsupp_prep,
319 #endif
320 	},
321 	[IORING_OP_SPLICE] = {
322 		.needs_file		= 1,
323 		.hash_reg_file		= 1,
324 		.unbound_nonreg_file	= 1,
325 		.audit_skip		= 1,
326 		.prep			= io_splice_prep,
327 		.issue			= io_splice,
328 	},
329 	[IORING_OP_PROVIDE_BUFFERS] = {
330 		.audit_skip		= 1,
331 		.iopoll			= 1,
332 		.prep			= io_provide_buffers_prep,
333 		.issue			= io_provide_buffers,
334 	},
335 	[IORING_OP_REMOVE_BUFFERS] = {
336 		.audit_skip		= 1,
337 		.iopoll			= 1,
338 		.prep			= io_remove_buffers_prep,
339 		.issue			= io_remove_buffers,
340 	},
341 	[IORING_OP_TEE] = {
342 		.needs_file		= 1,
343 		.hash_reg_file		= 1,
344 		.unbound_nonreg_file	= 1,
345 		.audit_skip		= 1,
346 		.prep			= io_tee_prep,
347 		.issue			= io_tee,
348 	},
349 	[IORING_OP_SHUTDOWN] = {
350 		.needs_file		= 1,
351 #if defined(CONFIG_NET)
352 		.prep			= io_shutdown_prep,
353 		.issue			= io_shutdown,
354 #else
355 		.prep			= io_eopnotsupp_prep,
356 #endif
357 	},
358 	[IORING_OP_RENAMEAT] = {
359 		.prep			= io_renameat_prep,
360 		.issue			= io_renameat,
361 	},
362 	[IORING_OP_UNLINKAT] = {
363 		.prep			= io_unlinkat_prep,
364 		.issue			= io_unlinkat,
365 	},
366 	[IORING_OP_MKDIRAT] = {
367 		.prep			= io_mkdirat_prep,
368 		.issue			= io_mkdirat,
369 	},
370 	[IORING_OP_SYMLINKAT] = {
371 		.prep			= io_symlinkat_prep,
372 		.issue			= io_symlinkat,
373 	},
374 	[IORING_OP_LINKAT] = {
375 		.prep			= io_linkat_prep,
376 		.issue			= io_linkat,
377 	},
378 	[IORING_OP_MSG_RING] = {
379 		.needs_file		= 1,
380 		.iopoll			= 1,
381 		.prep			= io_msg_ring_prep,
382 		.issue			= io_msg_ring,
383 	},
384 	[IORING_OP_FSETXATTR] = {
385 		.needs_file = 1,
386 		.prep			= io_fsetxattr_prep,
387 		.issue			= io_fsetxattr,
388 	},
389 	[IORING_OP_SETXATTR] = {
390 		.prep			= io_setxattr_prep,
391 		.issue			= io_setxattr,
392 	},
393 	[IORING_OP_FGETXATTR] = {
394 		.needs_file = 1,
395 		.prep			= io_fgetxattr_prep,
396 		.issue			= io_fgetxattr,
397 	},
398 	[IORING_OP_GETXATTR] = {
399 		.prep			= io_getxattr_prep,
400 		.issue			= io_getxattr,
401 	},
402 	[IORING_OP_SOCKET] = {
403 		.audit_skip		= 1,
404 #if defined(CONFIG_NET)
405 		.prep			= io_socket_prep,
406 		.issue			= io_socket,
407 #else
408 		.prep			= io_eopnotsupp_prep,
409 #endif
410 	},
411 	[IORING_OP_URING_CMD] = {
412 		.needs_file		= 1,
413 		.plug			= 1,
414 		.iopoll			= 1,
415 		.iopoll_queue		= 1,
416 		.async_size		= 2 * sizeof(struct io_uring_sqe),
417 		.prep			= io_uring_cmd_prep,
418 		.issue			= io_uring_cmd,
419 	},
420 	[IORING_OP_SEND_ZC] = {
421 		.needs_file		= 1,
422 		.unbound_nonreg_file	= 1,
423 		.pollout		= 1,
424 		.audit_skip		= 1,
425 		.ioprio			= 1,
426 #if defined(CONFIG_NET)
427 		.async_size		= sizeof(struct io_async_msghdr),
428 		.prep			= io_send_zc_prep,
429 		.issue			= io_send_zc,
430 #else
431 		.prep			= io_eopnotsupp_prep,
432 #endif
433 	},
434 	[IORING_OP_SENDMSG_ZC] = {
435 		.needs_file		= 1,
436 		.unbound_nonreg_file	= 1,
437 		.pollout		= 1,
438 		.ioprio			= 1,
439 #if defined(CONFIG_NET)
440 		.async_size		= sizeof(struct io_async_msghdr),
441 		.prep			= io_send_zc_prep,
442 		.issue			= io_sendmsg_zc,
443 #else
444 		.prep			= io_eopnotsupp_prep,
445 #endif
446 	},
447 	[IORING_OP_READ_MULTISHOT] = {
448 		.needs_file		= 1,
449 		.unbound_nonreg_file	= 1,
450 		.pollin			= 1,
451 		.buffer_select		= 1,
452 		.audit_skip		= 1,
453 		.async_size		= sizeof(struct io_async_rw),
454 		.prep			= io_read_mshot_prep,
455 		.issue			= io_read_mshot,
456 	},
457 	[IORING_OP_WAITID] = {
458 		.async_size		= sizeof(struct io_waitid_async),
459 		.prep			= io_waitid_prep,
460 		.issue			= io_waitid,
461 	},
462 	[IORING_OP_FUTEX_WAIT] = {
463 #if defined(CONFIG_FUTEX)
464 		.prep			= io_futex_prep,
465 		.issue			= io_futex_wait,
466 #else
467 		.prep			= io_eopnotsupp_prep,
468 #endif
469 	},
470 	[IORING_OP_FUTEX_WAKE] = {
471 #if defined(CONFIG_FUTEX)
472 		.prep			= io_futex_prep,
473 		.issue			= io_futex_wake,
474 #else
475 		.prep			= io_eopnotsupp_prep,
476 #endif
477 	},
478 	[IORING_OP_FUTEX_WAITV] = {
479 #if defined(CONFIG_FUTEX)
480 		.prep			= io_futexv_prep,
481 		.issue			= io_futexv_wait,
482 #else
483 		.prep			= io_eopnotsupp_prep,
484 #endif
485 	},
486 	[IORING_OP_FIXED_FD_INSTALL] = {
487 		.needs_file		= 1,
488 		.prep			= io_install_fixed_fd_prep,
489 		.issue			= io_install_fixed_fd,
490 	},
491 	[IORING_OP_FTRUNCATE] = {
492 		.needs_file		= 1,
493 		.hash_reg_file		= 1,
494 		.prep			= io_ftruncate_prep,
495 		.issue			= io_ftruncate,
496 	},
497 };
498 
499 const struct io_cold_def io_cold_defs[] = {
500 	[IORING_OP_NOP] = {
501 		.name			= "NOP",
502 	},
503 	[IORING_OP_READV] = {
504 		.name			= "READV",
505 		.cleanup		= io_readv_writev_cleanup,
506 		.fail			= io_rw_fail,
507 	},
508 	[IORING_OP_WRITEV] = {
509 		.name			= "WRITEV",
510 		.cleanup		= io_readv_writev_cleanup,
511 		.fail			= io_rw_fail,
512 	},
513 	[IORING_OP_FSYNC] = {
514 		.name			= "FSYNC",
515 	},
516 	[IORING_OP_READ_FIXED] = {
517 		.name			= "READ_FIXED",
518 		.fail			= io_rw_fail,
519 	},
520 	[IORING_OP_WRITE_FIXED] = {
521 		.name			= "WRITE_FIXED",
522 		.fail			= io_rw_fail,
523 	},
524 	[IORING_OP_POLL_ADD] = {
525 		.name			= "POLL_ADD",
526 	},
527 	[IORING_OP_POLL_REMOVE] = {
528 		.name			= "POLL_REMOVE",
529 	},
530 	[IORING_OP_SYNC_FILE_RANGE] = {
531 		.name			= "SYNC_FILE_RANGE",
532 	},
533 	[IORING_OP_SENDMSG] = {
534 		.name			= "SENDMSG",
535 #if defined(CONFIG_NET)
536 		.cleanup		= io_sendmsg_recvmsg_cleanup,
537 		.fail			= io_sendrecv_fail,
538 #endif
539 	},
540 	[IORING_OP_RECVMSG] = {
541 		.name			= "RECVMSG",
542 #if defined(CONFIG_NET)
543 		.cleanup		= io_sendmsg_recvmsg_cleanup,
544 		.fail			= io_sendrecv_fail,
545 #endif
546 	},
547 	[IORING_OP_TIMEOUT] = {
548 		.name			= "TIMEOUT",
549 	},
550 	[IORING_OP_TIMEOUT_REMOVE] = {
551 		.name			= "TIMEOUT_REMOVE",
552 	},
553 	[IORING_OP_ACCEPT] = {
554 		.name			= "ACCEPT",
555 	},
556 	[IORING_OP_ASYNC_CANCEL] = {
557 		.name			= "ASYNC_CANCEL",
558 	},
559 	[IORING_OP_LINK_TIMEOUT] = {
560 		.name			= "LINK_TIMEOUT",
561 	},
562 	[IORING_OP_CONNECT] = {
563 		.name			= "CONNECT",
564 	},
565 	[IORING_OP_FALLOCATE] = {
566 		.name			= "FALLOCATE",
567 	},
568 	[IORING_OP_OPENAT] = {
569 		.name			= "OPENAT",
570 		.cleanup		= io_open_cleanup,
571 	},
572 	[IORING_OP_CLOSE] = {
573 		.name			= "CLOSE",
574 	},
575 	[IORING_OP_FILES_UPDATE] = {
576 		.name			= "FILES_UPDATE",
577 	},
578 	[IORING_OP_STATX] = {
579 		.name			= "STATX",
580 		.cleanup		= io_statx_cleanup,
581 	},
582 	[IORING_OP_READ] = {
583 		.name			= "READ",
584 		.fail			= io_rw_fail,
585 	},
586 	[IORING_OP_WRITE] = {
587 		.name			= "WRITE",
588 		.fail			= io_rw_fail,
589 	},
590 	[IORING_OP_FADVISE] = {
591 		.name			= "FADVISE",
592 	},
593 	[IORING_OP_MADVISE] = {
594 		.name			= "MADVISE",
595 	},
596 	[IORING_OP_SEND] = {
597 		.name			= "SEND",
598 #if defined(CONFIG_NET)
599 		.cleanup		= io_sendmsg_recvmsg_cleanup,
600 		.fail			= io_sendrecv_fail,
601 #endif
602 	},
603 	[IORING_OP_RECV] = {
604 		.name			= "RECV",
605 #if defined(CONFIG_NET)
606 		.cleanup		= io_sendmsg_recvmsg_cleanup,
607 		.fail			= io_sendrecv_fail,
608 #endif
609 	},
610 	[IORING_OP_OPENAT2] = {
611 		.name			= "OPENAT2",
612 		.cleanup		= io_open_cleanup,
613 	},
614 	[IORING_OP_EPOLL_CTL] = {
615 		.name			= "EPOLL",
616 	},
617 	[IORING_OP_SPLICE] = {
618 		.name			= "SPLICE",
619 	},
620 	[IORING_OP_PROVIDE_BUFFERS] = {
621 		.name			= "PROVIDE_BUFFERS",
622 	},
623 	[IORING_OP_REMOVE_BUFFERS] = {
624 		.name			= "REMOVE_BUFFERS",
625 	},
626 	[IORING_OP_TEE] = {
627 		.name			= "TEE",
628 	},
629 	[IORING_OP_SHUTDOWN] = {
630 		.name			= "SHUTDOWN",
631 	},
632 	[IORING_OP_RENAMEAT] = {
633 		.name			= "RENAMEAT",
634 		.cleanup		= io_renameat_cleanup,
635 	},
636 	[IORING_OP_UNLINKAT] = {
637 		.name			= "UNLINKAT",
638 		.cleanup		= io_unlinkat_cleanup,
639 	},
640 	[IORING_OP_MKDIRAT] = {
641 		.name			= "MKDIRAT",
642 		.cleanup		= io_mkdirat_cleanup,
643 	},
644 	[IORING_OP_SYMLINKAT] = {
645 		.name			= "SYMLINKAT",
646 		.cleanup		= io_link_cleanup,
647 	},
648 	[IORING_OP_LINKAT] = {
649 		.name			= "LINKAT",
650 		.cleanup		= io_link_cleanup,
651 	},
652 	[IORING_OP_MSG_RING] = {
653 		.name			= "MSG_RING",
654 		.cleanup		= io_msg_ring_cleanup,
655 	},
656 	[IORING_OP_FSETXATTR] = {
657 		.name			= "FSETXATTR",
658 		.cleanup		= io_xattr_cleanup,
659 	},
660 	[IORING_OP_SETXATTR] = {
661 		.name			= "SETXATTR",
662 		.cleanup		= io_xattr_cleanup,
663 	},
664 	[IORING_OP_FGETXATTR] = {
665 		.name			= "FGETXATTR",
666 		.cleanup		= io_xattr_cleanup,
667 	},
668 	[IORING_OP_GETXATTR] = {
669 		.name			= "GETXATTR",
670 		.cleanup		= io_xattr_cleanup,
671 	},
672 	[IORING_OP_SOCKET] = {
673 		.name			= "SOCKET",
674 	},
675 	[IORING_OP_URING_CMD] = {
676 		.name			= "URING_CMD",
677 	},
678 	[IORING_OP_SEND_ZC] = {
679 		.name			= "SEND_ZC",
680 #if defined(CONFIG_NET)
681 		.cleanup		= io_send_zc_cleanup,
682 		.fail			= io_sendrecv_fail,
683 #endif
684 	},
685 	[IORING_OP_SENDMSG_ZC] = {
686 		.name			= "SENDMSG_ZC",
687 #if defined(CONFIG_NET)
688 		.cleanup		= io_send_zc_cleanup,
689 		.fail			= io_sendrecv_fail,
690 #endif
691 	},
692 	[IORING_OP_READ_MULTISHOT] = {
693 		.name			= "READ_MULTISHOT",
694 	},
695 	[IORING_OP_WAITID] = {
696 		.name			= "WAITID",
697 	},
698 	[IORING_OP_FUTEX_WAIT] = {
699 		.name			= "FUTEX_WAIT",
700 	},
701 	[IORING_OP_FUTEX_WAKE] = {
702 		.name			= "FUTEX_WAKE",
703 	},
704 	[IORING_OP_FUTEX_WAITV] = {
705 		.name			= "FUTEX_WAITV",
706 	},
707 	[IORING_OP_FIXED_FD_INSTALL] = {
708 		.name			= "FIXED_FD_INSTALL",
709 	},
710 	[IORING_OP_FTRUNCATE] = {
711 		.name			= "FTRUNCATE",
712 	},
713 };
714 
715 const char *io_uring_get_opcode(u8 opcode)
716 {
717 	if (opcode < IORING_OP_LAST)
718 		return io_cold_defs[opcode].name;
719 	return "INVALID";
720 }
721 
722 void __init io_uring_optable_init(void)
723 {
724 	int i;
725 
726 	BUILD_BUG_ON(ARRAY_SIZE(io_cold_defs) != IORING_OP_LAST);
727 	BUILD_BUG_ON(ARRAY_SIZE(io_issue_defs) != IORING_OP_LAST);
728 
729 	for (i = 0; i < ARRAY_SIZE(io_issue_defs); i++) {
730 		BUG_ON(!io_issue_defs[i].prep);
731 		if (io_issue_defs[i].prep != io_eopnotsupp_prep)
732 			BUG_ON(!io_issue_defs[i].issue);
733 		WARN_ON_ONCE(!io_cold_defs[i].name);
734 	}
735 }
736