opdef.c 16 KB

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