Linux Audio

Check our new training course

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