blob: 24651c229ed290f8df107be3d0f059556dd17208 [file] [log] [blame]
Jens Axboe0f212202020-09-13 13:09:39 -06001/* SPDX-License-Identifier: GPL-2.0-or-later */
2#ifndef _LINUX_IO_URING_H
3#define _LINUX_IO_URING_H
4
5#include <linux/sched.h>
6#include <linux/xarray.h>
Jens Axboe98447d62020-10-14 10:48:51 -06007
Jens Axboe0f212202020-09-13 13:09:39 -06008#if defined(CONFIG_IO_URING)
Jens Axboea3ec6002020-09-18 20:41:00 -06009struct sock *io_uring_get_socket(struct file *file);
Hao Xuf552a272021-08-12 12:14:35 +080010void __io_uring_cancel(bool cancel_all);
Jens Axboe0f212202020-09-13 13:09:39 -060011void __io_uring_free(struct task_struct *tsk);
Jens Axboee7a6c002022-03-04 08:22:22 -070012void io_uring_unreg_ringfd(void);
Dylan Yudaken33337d02022-04-26 01:29:05 -070013const char *io_uring_get_opcode(u8 opcode);
Jens Axboe0f212202020-09-13 13:09:39 -060014
Hao Xuf552a272021-08-12 12:14:35 +080015static inline void io_uring_files_cancel(void)
Jens Axboe0f212202020-09-13 13:09:39 -060016{
Jens Axboee7a6c002022-03-04 08:22:22 -070017 if (current->io_uring) {
18 io_uring_unreg_ringfd();
Hao Xuf552a272021-08-12 12:14:35 +080019 __io_uring_cancel(false);
Jens Axboee7a6c002022-03-04 08:22:22 -070020 }
Pavel Begunkov3f48cf12021-04-11 01:46:27 +010021}
22static inline void io_uring_task_cancel(void)
23{
Hao Xua4aadd12021-08-12 12:14:34 +080024 if (current->io_uring)
Hao Xuf552a272021-08-12 12:14:35 +080025 __io_uring_cancel(true);
Jens Axboe0f212202020-09-13 13:09:39 -060026}
27static inline void io_uring_free(struct task_struct *tsk)
28{
29 if (tsk->io_uring)
30 __io_uring_free(tsk);
31}
32#else
Jens Axboea3ec6002020-09-18 20:41:00 -060033static inline struct sock *io_uring_get_socket(struct file *file)
34{
35 return NULL;
36}
Jens Axboe0f212202020-09-13 13:09:39 -060037static inline void io_uring_task_cancel(void)
38{
39}
Hao Xuf552a272021-08-12 12:14:35 +080040static inline void io_uring_files_cancel(void)
Jens Axboe0f212202020-09-13 13:09:39 -060041{
42}
43static inline void io_uring_free(struct task_struct *tsk)
44{
45}
Dylan Yudaken33337d02022-04-26 01:29:05 -070046static inline const char *io_uring_get_opcode(u8 opcode)
47{
48 return "";
49}
Jens Axboe0f212202020-09-13 13:09:39 -060050#endif
51
52#endif