io_uring.h 1.6 KB
Newer Older
1 2 3 4 5 6
/* SPDX-License-Identifier: GPL-2.0-or-later */
#ifndef _LINUX_IO_URING_H
#define _LINUX_IO_URING_H

#include <linux/sched.h>
#include <linux/xarray.h>
7 8 9 10 11 12 13 14 15 16 17

struct io_identity {
	struct files_struct		*files;
	struct mm_struct		*mm;
#ifdef CONFIG_BLK_CGROUP
	struct cgroup_subsys_state	*blkcg_css;
#endif
	const struct cred		*creds;
	struct nsproxy			*nsproxy;
	struct fs_struct		*fs;
	unsigned long			fsize;
J
Jens Axboe 已提交
18
	refcount_t			count;
19
};
20 21 22 23 24 25 26

struct io_uring_task {
	/* submission side */
	struct xarray		xa;
	struct wait_queue_head	wait;
	struct file		*last;
	atomic_long_t		req_issue;
27 28
	struct io_identity	__identity;
	struct io_identity	*identity;
29 30 31 32 33 34 35

	/* completion side */
	bool			in_idle ____cacheline_aligned_in_smp;
	atomic_long_t		req_complete;
};

#if defined(CONFIG_IO_URING)
36
struct sock *io_uring_get_socket(struct file *file);
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
void __io_uring_task_cancel(void);
void __io_uring_files_cancel(struct files_struct *files);
void __io_uring_free(struct task_struct *tsk);

static inline void io_uring_task_cancel(void)
{
	if (current->io_uring && !xa_empty(&current->io_uring->xa))
		__io_uring_task_cancel();
}
static inline void io_uring_files_cancel(struct files_struct *files)
{
	if (current->io_uring && !xa_empty(&current->io_uring->xa))
		__io_uring_files_cancel(files);
}
static inline void io_uring_free(struct task_struct *tsk)
{
	if (tsk->io_uring)
		__io_uring_free(tsk);
}
#else
57 58 59 60
static inline struct sock *io_uring_get_socket(struct file *file)
{
	return NULL;
}
61 62 63 64 65 66 67 68 69 70 71 72
static inline void io_uring_task_cancel(void)
{
}
static inline void io_uring_files_cancel(struct files_struct *files)
{
}
static inline void io_uring_free(struct task_struct *tsk)
{
}
#endif

#endif