diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/file.h | 2 | ||||
| -rw-r--r-- | include/linux/fs.h | 13 | ||||
| -rw-r--r-- | include/linux/sched/user.h | 2 | ||||
| -rw-r--r-- | include/linux/syscalls.h | 8 | ||||
| -rw-r--r-- | include/net/af_unix.h | 1 | ||||
| -rw-r--r-- | include/uapi/asm-generic/unistd.h | 9 | ||||
| -rw-r--r-- | include/uapi/linux/io_uring.h | 137 |
7 files changed, 169 insertions, 3 deletions
diff --git a/include/linux/file.h b/include/linux/file.h index 6b2fb032416c..3fcddff56bc4 100644 --- a/include/linux/file.h +++ b/include/linux/file.h | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | struct file; | 13 | struct file; |
| 14 | 14 | ||
| 15 | extern void fput(struct file *); | 15 | extern void fput(struct file *); |
| 16 | extern void fput_many(struct file *, unsigned int); | ||
| 16 | 17 | ||
| 17 | struct file_operations; | 18 | struct file_operations; |
| 18 | struct vfsmount; | 19 | struct vfsmount; |
| @@ -44,6 +45,7 @@ static inline void fdput(struct fd fd) | |||
| 44 | } | 45 | } |
| 45 | 46 | ||
| 46 | extern struct file *fget(unsigned int fd); | 47 | extern struct file *fget(unsigned int fd); |
| 48 | extern struct file *fget_many(unsigned int fd, unsigned int refs); | ||
| 47 | extern struct file *fget_raw(unsigned int fd); | 49 | extern struct file *fget_raw(unsigned int fd); |
| 48 | extern unsigned long __fdget(unsigned int fd); | 50 | extern unsigned long __fdget(unsigned int fd); |
| 49 | extern unsigned long __fdget_raw(unsigned int fd); | 51 | extern unsigned long __fdget_raw(unsigned int fd); |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 7442329a0011..0a257d89208e 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
| @@ -961,7 +961,9 @@ static inline struct file *get_file(struct file *f) | |||
| 961 | atomic_long_inc(&f->f_count); | 961 | atomic_long_inc(&f->f_count); |
| 962 | return f; | 962 | return f; |
| 963 | } | 963 | } |
| 964 | #define get_file_rcu(x) atomic_long_inc_not_zero(&(x)->f_count) | 964 | #define get_file_rcu_many(x, cnt) \ |
| 965 | atomic_long_add_unless(&(x)->f_count, (cnt), 0) | ||
| 966 | #define get_file_rcu(x) get_file_rcu_many((x), 1) | ||
| 965 | #define fput_atomic(x) atomic_long_add_unless(&(x)->f_count, -1, 1) | 967 | #define fput_atomic(x) atomic_long_add_unless(&(x)->f_count, -1, 1) |
| 966 | #define file_count(x) atomic_long_read(&(x)->f_count) | 968 | #define file_count(x) atomic_long_read(&(x)->f_count) |
| 967 | 969 | ||
| @@ -3511,4 +3513,13 @@ extern void inode_nohighmem(struct inode *inode); | |||
| 3511 | extern int vfs_fadvise(struct file *file, loff_t offset, loff_t len, | 3513 | extern int vfs_fadvise(struct file *file, loff_t offset, loff_t len, |
| 3512 | int advice); | 3514 | int advice); |
| 3513 | 3515 | ||
| 3516 | #if defined(CONFIG_IO_URING) | ||
| 3517 | extern struct sock *io_uring_get_socket(struct file *file); | ||
| 3518 | #else | ||
| 3519 | static inline struct sock *io_uring_get_socket(struct file *file) | ||
| 3520 | { | ||
| 3521 | return NULL; | ||
| 3522 | } | ||
| 3523 | #endif | ||
| 3524 | |||
| 3514 | #endif /* _LINUX_FS_H */ | 3525 | #endif /* _LINUX_FS_H */ |
diff --git a/include/linux/sched/user.h b/include/linux/sched/user.h index 39ad98c09c58..c7b5f86b91a1 100644 --- a/include/linux/sched/user.h +++ b/include/linux/sched/user.h | |||
| @@ -40,7 +40,7 @@ struct user_struct { | |||
| 40 | kuid_t uid; | 40 | kuid_t uid; |
| 41 | 41 | ||
| 42 | #if defined(CONFIG_PERF_EVENTS) || defined(CONFIG_BPF_SYSCALL) || \ | 42 | #if defined(CONFIG_PERF_EVENTS) || defined(CONFIG_BPF_SYSCALL) || \ |
| 43 | defined(CONFIG_NET) | 43 | defined(CONFIG_NET) || defined(CONFIG_IO_URING) |
| 44 | atomic_long_t locked_vm; | 44 | atomic_long_t locked_vm; |
| 45 | #endif | 45 | #endif |
| 46 | 46 | ||
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index 94369f5bd8e5..c2962953bf11 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h | |||
| @@ -69,6 +69,7 @@ struct file_handle; | |||
| 69 | struct sigaltstack; | 69 | struct sigaltstack; |
| 70 | struct rseq; | 70 | struct rseq; |
| 71 | union bpf_attr; | 71 | union bpf_attr; |
| 72 | struct io_uring_params; | ||
| 72 | 73 | ||
| 73 | #include <linux/types.h> | 74 | #include <linux/types.h> |
| 74 | #include <linux/aio_abi.h> | 75 | #include <linux/aio_abi.h> |
| @@ -314,6 +315,13 @@ asmlinkage long sys_io_pgetevents_time32(aio_context_t ctx_id, | |||
| 314 | struct io_event __user *events, | 315 | struct io_event __user *events, |
| 315 | struct old_timespec32 __user *timeout, | 316 | struct old_timespec32 __user *timeout, |
| 316 | const struct __aio_sigset *sig); | 317 | const struct __aio_sigset *sig); |
| 318 | asmlinkage long sys_io_uring_setup(u32 entries, | ||
| 319 | struct io_uring_params __user *p); | ||
| 320 | asmlinkage long sys_io_uring_enter(unsigned int fd, u32 to_submit, | ||
| 321 | u32 min_complete, u32 flags, | ||
| 322 | const sigset_t __user *sig, size_t sigsz); | ||
| 323 | asmlinkage long sys_io_uring_register(unsigned int fd, unsigned int op, | ||
| 324 | void __user *arg, unsigned int nr_args); | ||
| 317 | 325 | ||
| 318 | /* fs/xattr.c */ | 326 | /* fs/xattr.c */ |
| 319 | asmlinkage long sys_setxattr(const char __user *path, const char __user *name, | 327 | asmlinkage long sys_setxattr(const char __user *path, const char __user *name, |
diff --git a/include/net/af_unix.h b/include/net/af_unix.h index ddbba838d048..3426d6dacc45 100644 --- a/include/net/af_unix.h +++ b/include/net/af_unix.h | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | void unix_inflight(struct user_struct *user, struct file *fp); | 11 | void unix_inflight(struct user_struct *user, struct file *fp); |
| 12 | void unix_notinflight(struct user_struct *user, struct file *fp); | 12 | void unix_notinflight(struct user_struct *user, struct file *fp); |
| 13 | void unix_destruct_scm(struct sk_buff *skb); | ||
| 13 | void unix_gc(void); | 14 | void unix_gc(void); |
| 14 | void wait_for_unix_gc(void); | 15 | void wait_for_unix_gc(void); |
| 15 | struct sock *unix_get_socket(struct file *filp); | 16 | struct sock *unix_get_socket(struct file *filp); |
diff --git a/include/uapi/asm-generic/unistd.h b/include/uapi/asm-generic/unistd.h index 12cdf611d217..bf4624efe5e6 100644 --- a/include/uapi/asm-generic/unistd.h +++ b/include/uapi/asm-generic/unistd.h | |||
| @@ -824,8 +824,15 @@ __SYSCALL(__NR_futex_time64, sys_futex) | |||
| 824 | __SYSCALL(__NR_sched_rr_get_interval_time64, sys_sched_rr_get_interval) | 824 | __SYSCALL(__NR_sched_rr_get_interval_time64, sys_sched_rr_get_interval) |
| 825 | #endif | 825 | #endif |
| 826 | 826 | ||
| 827 | #define __NR_io_uring_setup 425 | ||
| 828 | __SYSCALL(__NR_io_uring_setup, sys_io_uring_setup) | ||
| 829 | #define __NR_io_uring_enter 426 | ||
| 830 | __SYSCALL(__NR_io_uring_enter, sys_io_uring_enter) | ||
| 831 | #define __NR_io_uring_register 427 | ||
| 832 | __SYSCALL(__NR_io_uring_register, sys_io_uring_register) | ||
| 833 | |||
| 827 | #undef __NR_syscalls | 834 | #undef __NR_syscalls |
| 828 | #define __NR_syscalls 424 | 835 | #define __NR_syscalls 428 |
| 829 | 836 | ||
| 830 | /* | 837 | /* |
| 831 | * 32 bit systems traditionally used different | 838 | * 32 bit systems traditionally used different |
diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h new file mode 100644 index 000000000000..e23408692118 --- /dev/null +++ b/include/uapi/linux/io_uring.h | |||
| @@ -0,0 +1,137 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | ||
| 2 | /* | ||
| 3 | * Header file for the io_uring interface. | ||
| 4 | * | ||
| 5 | * Copyright (C) 2019 Jens Axboe | ||
| 6 | * Copyright (C) 2019 Christoph Hellwig | ||
| 7 | */ | ||
| 8 | #ifndef LINUX_IO_URING_H | ||
| 9 | #define LINUX_IO_URING_H | ||
| 10 | |||
| 11 | #include <linux/fs.h> | ||
| 12 | #include <linux/types.h> | ||
| 13 | |||
| 14 | /* | ||
| 15 | * IO submission data structure (Submission Queue Entry) | ||
| 16 | */ | ||
| 17 | struct io_uring_sqe { | ||
| 18 | __u8 opcode; /* type of operation for this sqe */ | ||
| 19 | __u8 flags; /* IOSQE_ flags */ | ||
| 20 | __u16 ioprio; /* ioprio for the request */ | ||
| 21 | __s32 fd; /* file descriptor to do IO on */ | ||
| 22 | __u64 off; /* offset into file */ | ||
| 23 | __u64 addr; /* pointer to buffer or iovecs */ | ||
| 24 | __u32 len; /* buffer size or number of iovecs */ | ||
| 25 | union { | ||
| 26 | __kernel_rwf_t rw_flags; | ||
| 27 | __u32 fsync_flags; | ||
| 28 | __u16 poll_events; | ||
| 29 | }; | ||
| 30 | __u64 user_data; /* data to be passed back at completion time */ | ||
| 31 | union { | ||
| 32 | __u16 buf_index; /* index into fixed buffers, if used */ | ||
| 33 | __u64 __pad2[3]; | ||
| 34 | }; | ||
| 35 | }; | ||
| 36 | |||
| 37 | /* | ||
| 38 | * sqe->flags | ||
| 39 | */ | ||
| 40 | #define IOSQE_FIXED_FILE (1U << 0) /* use fixed fileset */ | ||
| 41 | |||
| 42 | /* | ||
| 43 | * io_uring_setup() flags | ||
| 44 | */ | ||
| 45 | #define IORING_SETUP_IOPOLL (1U << 0) /* io_context is polled */ | ||
| 46 | #define IORING_SETUP_SQPOLL (1U << 1) /* SQ poll thread */ | ||
| 47 | #define IORING_SETUP_SQ_AFF (1U << 2) /* sq_thread_cpu is valid */ | ||
| 48 | |||
| 49 | #define IORING_OP_NOP 0 | ||
| 50 | #define IORING_OP_READV 1 | ||
| 51 | #define IORING_OP_WRITEV 2 | ||
| 52 | #define IORING_OP_FSYNC 3 | ||
| 53 | #define IORING_OP_READ_FIXED 4 | ||
| 54 | #define IORING_OP_WRITE_FIXED 5 | ||
| 55 | #define IORING_OP_POLL_ADD 6 | ||
| 56 | #define IORING_OP_POLL_REMOVE 7 | ||
| 57 | |||
| 58 | /* | ||
| 59 | * sqe->fsync_flags | ||
| 60 | */ | ||
| 61 | #define IORING_FSYNC_DATASYNC (1U << 0) | ||
| 62 | |||
| 63 | /* | ||
| 64 | * IO completion data structure (Completion Queue Entry) | ||
| 65 | */ | ||
| 66 | struct io_uring_cqe { | ||
| 67 | __u64 user_data; /* sqe->data submission passed back */ | ||
| 68 | __s32 res; /* result code for this event */ | ||
| 69 | __u32 flags; | ||
| 70 | }; | ||
| 71 | |||
| 72 | /* | ||
| 73 | * Magic offsets for the application to mmap the data it needs | ||
| 74 | */ | ||
| 75 | #define IORING_OFF_SQ_RING 0ULL | ||
| 76 | #define IORING_OFF_CQ_RING 0x8000000ULL | ||
| 77 | #define IORING_OFF_SQES 0x10000000ULL | ||
| 78 | |||
| 79 | /* | ||
| 80 | * Filled with the offset for mmap(2) | ||
| 81 | */ | ||
| 82 | struct io_sqring_offsets { | ||
| 83 | __u32 head; | ||
| 84 | __u32 tail; | ||
| 85 | __u32 ring_mask; | ||
| 86 | __u32 ring_entries; | ||
| 87 | __u32 flags; | ||
| 88 | __u32 dropped; | ||
| 89 | __u32 array; | ||
| 90 | __u32 resv1; | ||
| 91 | __u64 resv2; | ||
| 92 | }; | ||
| 93 | |||
| 94 | /* | ||
| 95 | * sq_ring->flags | ||
| 96 | */ | ||
| 97 | #define IORING_SQ_NEED_WAKEUP (1U << 0) /* needs io_uring_enter wakeup */ | ||
| 98 | |||
| 99 | struct io_cqring_offsets { | ||
| 100 | __u32 head; | ||
| 101 | __u32 tail; | ||
| 102 | __u32 ring_mask; | ||
| 103 | __u32 ring_entries; | ||
| 104 | __u32 overflow; | ||
| 105 | __u32 cqes; | ||
| 106 | __u64 resv[2]; | ||
| 107 | }; | ||
| 108 | |||
| 109 | /* | ||
| 110 | * io_uring_enter(2) flags | ||
| 111 | */ | ||
| 112 | #define IORING_ENTER_GETEVENTS (1U << 0) | ||
| 113 | #define IORING_ENTER_SQ_WAKEUP (1U << 1) | ||
| 114 | |||
| 115 | /* | ||
| 116 | * Passed in for io_uring_setup(2). Copied back with updated info on success | ||
| 117 | */ | ||
| 118 | struct io_uring_params { | ||
| 119 | __u32 sq_entries; | ||
| 120 | __u32 cq_entries; | ||
| 121 | __u32 flags; | ||
| 122 | __u32 sq_thread_cpu; | ||
| 123 | __u32 sq_thread_idle; | ||
| 124 | __u32 resv[5]; | ||
| 125 | struct io_sqring_offsets sq_off; | ||
| 126 | struct io_cqring_offsets cq_off; | ||
| 127 | }; | ||
| 128 | |||
| 129 | /* | ||
| 130 | * io_uring_register(2) opcodes and arguments | ||
| 131 | */ | ||
| 132 | #define IORING_REGISTER_BUFFERS 0 | ||
| 133 | #define IORING_UNREGISTER_BUFFERS 1 | ||
| 134 | #define IORING_REGISTER_FILES 2 | ||
| 135 | #define IORING_UNREGISTER_FILES 3 | ||
| 136 | |||
| 137 | #endif | ||
