io_uring.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. #ifndef _LINUX_IO_URING_H
  3. #define _LINUX_IO_URING_H
  4. #include <linux/sched.h>
  5. #include <linux/xarray.h>
  6. struct io_identity {
  7. struct files_struct *files;
  8. struct mm_struct *mm;
  9. #ifdef CONFIG_BLK_CGROUP
  10. struct cgroup_subsys_state *blkcg_css;
  11. #endif
  12. const struct cred *creds;
  13. struct nsproxy *nsproxy;
  14. struct fs_struct *fs;
  15. unsigned long fsize;
  16. #ifdef CONFIG_AUDIT
  17. kuid_t loginuid;
  18. unsigned int sessionid;
  19. #endif
  20. refcount_t count;
  21. };
  22. struct io_uring_task {
  23. /* submission side */
  24. struct xarray xa;
  25. struct wait_queue_head wait;
  26. struct file *last;
  27. struct percpu_counter inflight;
  28. struct io_identity __identity;
  29. struct io_identity *identity;
  30. atomic_t in_idle;
  31. bool sqpoll;
  32. };
  33. #if defined(CONFIG_IO_URING)
  34. struct sock *io_uring_get_socket(struct file *file);
  35. void __io_uring_task_cancel(void);
  36. void __io_uring_files_cancel(struct files_struct *files);
  37. void __io_uring_free(struct task_struct *tsk);
  38. static inline void io_uring_task_cancel(void)
  39. {
  40. if (current->io_uring && !xa_empty(&current->io_uring->xa))
  41. __io_uring_task_cancel();
  42. }
  43. static inline void io_uring_files_cancel(struct files_struct *files)
  44. {
  45. if (current->io_uring && !xa_empty(&current->io_uring->xa))
  46. __io_uring_files_cancel(files);
  47. }
  48. static inline void io_uring_free(struct task_struct *tsk)
  49. {
  50. if (tsk->io_uring)
  51. __io_uring_free(tsk);
  52. }
  53. #else
  54. static inline struct sock *io_uring_get_socket(struct file *file)
  55. {
  56. return NULL;
  57. }
  58. static inline void io_uring_task_cancel(void)
  59. {
  60. }
  61. static inline void io_uring_files_cancel(struct files_struct *files)
  62. {
  63. }
  64. static inline void io_uring_free(struct task_struct *tsk)
  65. {
  66. }
  67. #endif
  68. #endif