opdef.c 16 KB

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