Linux Audio

Check our new training course

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