History

io_uring: add splice(2) support

Add support for splice(2). - output file is specified as sqe->fd, so it's handled by generic code - hash_reg_file handled by generic code as well - len is 32bit, but should be fine - the fd_in is registered file, when SPLICE_F_FD_IN_FIXED is set, which is a splice flag (i.e. sqe->splice_flags).

Pavel Begunkov committed 6 years ago

Commit 7d67af21 parent 8da11c12 files · +122 −1Browse files

Showing the changes to include/uapi/linux (1 of 2 files). Show all

Unified · Split

include/uapi/linux/io_uring.h+13−1
@@ -23,7 +23,10 @@ struct io_uring_sqe { · 22 unmodified lines
2323 __u64 off; /* offset into file */
2424 __u64 addr2;
2525 };
26− __u64 addr; /* pointer to buffer or iovecs */
26+ union {
27+ __u64 addr; /* pointer to buffer or iovecs */
28+ __u64 splice_off_in;
29+ };
2730 __u32 len; /* buffer size or number of iovecs */
2831 union {
2932 __kernel_rwf_t rw_flags;
@@ -37,6 +40,7 @@ struct io_uring_sqe { · 7 unmodified lines
3740 __u32 open_flags;
3841 __u32 statx_flags;
3942 __u32 fadvise_advice;
43+ __u32 splice_flags;
4044 };
4145 __u64 user_data; /* data to be passed back at completion time */
4246 union {
@@ -45,6 +49,7 @@ struct io_uring_sqe { · 2 unmodified lines
4549 __u16 buf_index;
4650 /* personality to use, if used */
4751 __u16 personality;
52+ __s32 splice_fd_in;
4853 };
4954 __u64 __pad2[3];
5055 };
@@ -113,6 +118,7 @@ enum { · 62 unmodified lines
113118 IORING_OP_RECV,
114119 IORING_OP_OPENAT2,
115120 IORING_OP_EPOLL_CTL,
121+ IORING_OP_SPLICE,
116122
117123 /* this goes last, obviously */
118124 IORING_OP_LAST,
@@ -128,6 +134,12 @@ enum { · 9 unmodified lines
128134 */
129135 #define IORING_TIMEOUT_ABS (1U << 0)
130136
137+/*
138+ * sqe->splice_flags
139+ * extends splice(2) flags
140+ */
141+#define SPLICE_F_FD_IN_FIXED (1U << 31) /* the last bit of __u32 */
142+
131143 /*
132144 * IO completion data structure (Completion Queue Entry)
133145 */