public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH liburing  1/2] splice: add splice(2) helpers
  2020-02-15 22:07 [PATCH liburing 0/2] splice helpers + tests Pavel Begunkov
@ 2020-02-15 22:07 ` Pavel Begunkov
  0 siblings, 0 replies; 3+ messages in thread
From: Pavel Begunkov @ 2020-02-15 22:07 UTC (permalink / raw)
  To: Jens Axboe, io-uring, linux-kernel

Add splice helpers and update io_uring.h

Signed-off-by: Pavel Begunkov <[email protected]>
---
 src/include/liburing.h          | 12 ++++++++++++
 src/include/liburing/io_uring.h | 14 +++++++++++++-
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/src/include/liburing.h b/src/include/liburing.h
index 8ca6cd9..16ccadd 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -191,6 +191,18 @@ static inline void io_uring_prep_rw(int op, struct io_uring_sqe *sqe, int fd,
 	sqe->__pad2[0] = sqe->__pad2[1] = sqe->__pad2[2] = 0;
 }
 
+static void io_uring_prep_splice(struct io_uring_sqe *sqe,
+				 int fd_in, loff_t off_in,
+				 int fd_out, loff_t off_out,
+				 unsigned int nbytes, int splice_flags)
+{
+	io_uring_prep_rw(IORING_OP_SPLICE, sqe, fd_out, (void *)off_in,
+			 nbytes, off_out);
+	sqe->splice_fd_in = fd_in;
+	sqe->splice_flags = splice_flags;
+}
+
+
 static inline void io_uring_prep_readv(struct io_uring_sqe *sqe, int fd,
 				       const struct iovec *iovecs,
 				       unsigned nr_vecs, off_t offset)
diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h
index 424fb4b..0623e00 100644
--- a/src/include/liburing/io_uring.h
+++ b/src/include/liburing/io_uring.h
@@ -23,7 +23,10 @@ struct io_uring_sqe {
 		__u64	off;	/* offset into file */
 		__u64	addr2;
 	};
-	__u64	addr;		/* pointer to buffer or iovecs */
+	union {
+		__u64	addr;	/* pointer to buffer or iovecs */
+		__u64	off_in;
+	};
 	__u32	len;		/* buffer size or number of iovecs */
 	union {
 		__kernel_rwf_t	rw_flags;
@@ -37,6 +40,7 @@ struct io_uring_sqe {
 		__u32		open_flags;
 		__u32		statx_flags;
 		__u32		fadvise_advice;
+		__u32		splice_flags;
 	};
 	__u64	user_data;	/* data to be passed back at completion time */
 	union {
@@ -45,6 +49,7 @@ struct io_uring_sqe {
 			__u16	buf_index;
 			/* personality to use, if used */
 			__u16	personality;
+			__u32	splice_fd_in;
 		};
 		__u64	__pad2[3];
 	};
@@ -113,6 +118,7 @@ enum {
 	IORING_OP_RECV,
 	IORING_OP_OPENAT2,
 	IORING_OP_EPOLL_CTL,
+	IORING_OP_SPLICE,
 
 	/* this goes last, obviously */
 	IORING_OP_LAST,
@@ -128,6 +134,12 @@ enum {
  */
 #define IORING_TIMEOUT_ABS	(1U << 0)
 
+/*
+ * sqe->splice_flags
+ * extends splice(2) flags
+ */
+#define SPLICE_F_FD_IN_FIXED	(1U << 31) /* last bit for __u32 */
+
 /*
  * IO completion data structure (Completion Queue Entry)
  */
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH liburing 1/2] splice: add splice(2) helpers
       [not found] <[email protected]>
@ 2020-02-15 22:16 ` Pavel Begunkov
  2020-02-16  1:34   ` Pavel Begunkov
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel Begunkov @ 2020-02-15 22:16 UTC (permalink / raw)
  To: Jens Axboe, io-uring, linux-kernel

Add splice helpers and update io_uring.h

Signed-off-by: Pavel Begunkov <[email protected]>
---

Quick update for extra newline and the fixed fd comment

 src/include/liburing.h          | 11 +++++++++++
 src/include/liburing/io_uring.h | 14 +++++++++++++-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/src/include/liburing.h b/src/include/liburing.h
index 8ca6cd9..0628255 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -191,6 +191,17 @@ static inline void io_uring_prep_rw(int op, struct io_uring_sqe *sqe, int fd,
 	sqe->__pad2[0] = sqe->__pad2[1] = sqe->__pad2[2] = 0;
 }
 
+static void io_uring_prep_splice(struct io_uring_sqe *sqe,
+				 int fd_in, loff_t off_in,
+				 int fd_out, loff_t off_out,
+				 unsigned int nbytes, int splice_flags)
+{
+	io_uring_prep_rw(IORING_OP_SPLICE, sqe, fd_out, (void *)off_in,
+			 nbytes, off_out);
+	sqe->splice_fd_in = fd_in;
+	sqe->splice_flags = splice_flags;
+}
+
 static inline void io_uring_prep_readv(struct io_uring_sqe *sqe, int fd,
 				       const struct iovec *iovecs,
 				       unsigned nr_vecs, off_t offset)
diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h
index 424fb4b..dc78697 100644
--- a/src/include/liburing/io_uring.h
+++ b/src/include/liburing/io_uring.h
@@ -23,7 +23,10 @@ struct io_uring_sqe {
 		__u64	off;	/* offset into file */
 		__u64	addr2;
 	};
-	__u64	addr;		/* pointer to buffer or iovecs */
+	union {
+		__u64	addr;	/* pointer to buffer or iovecs */
+		__u64	off_in;
+	};
 	__u32	len;		/* buffer size or number of iovecs */
 	union {
 		__kernel_rwf_t	rw_flags;
@@ -37,6 +40,7 @@ struct io_uring_sqe {
 		__u32		open_flags;
 		__u32		statx_flags;
 		__u32		fadvise_advice;
+		__u32		splice_flags;
 	};
 	__u64	user_data;	/* data to be passed back at completion time */
 	union {
@@ -45,6 +49,7 @@ struct io_uring_sqe {
 			__u16	buf_index;
 			/* personality to use, if used */
 			__u16	personality;
+			__u32	splice_fd_in;
 		};
 		__u64	__pad2[3];
 	};
@@ -113,6 +118,7 @@ enum {
 	IORING_OP_RECV,
 	IORING_OP_OPENAT2,
 	IORING_OP_EPOLL_CTL,
+	IORING_OP_SPLICE,
 
 	/* this goes last, obviously */
 	IORING_OP_LAST,
@@ -128,6 +134,12 @@ enum {
  */
 #define IORING_TIMEOUT_ABS	(1U << 0)
 
+/*
+ * sqe->splice_flags
+ * extends splice(2) flags
+ */
+#define SPLICE_F_FD_IN_FIXED	(1U << 31) /* the last bit of __u32 */
+
 /*
  * IO completion data structure (Completion Queue Entry)
  */
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH liburing 1/2] splice: add splice(2) helpers
  2020-02-15 22:16 ` [PATCH liburing 1/2] splice: add splice(2) helpers Pavel Begunkov
@ 2020-02-16  1:34   ` Pavel Begunkov
  0 siblings, 0 replies; 3+ messages in thread
From: Pavel Begunkov @ 2020-02-16  1:34 UTC (permalink / raw)
  To: Jens Axboe, io-uring, linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 2844 bytes --]

On 16/02/2020 01:16, Pavel Begunkov wrote:
> Add splice helpers and update io_uring.h
> 
> Signed-off-by: Pavel Begunkov <[email protected]>
> ---
> 
> Quick update for extra newline and the fixed fd comment
> 
>  src/include/liburing.h          | 11 +++++++++++
>  src/include/liburing/io_uring.h | 14 +++++++++++++-
>  2 files changed, 24 insertions(+), 1 deletion(-)
> 
> diff --git a/src/include/liburing.h b/src/include/liburing.h
> index 8ca6cd9..0628255 100644
> --- a/src/include/liburing.h
> +++ b/src/include/liburing.h
> @@ -191,6 +191,17 @@ static inline void io_uring_prep_rw(int op, struct io_uring_sqe *sqe, int fd,
>  	sqe->__pad2[0] = sqe->__pad2[1] = sqe->__pad2[2] = 0;
>  }
>  
> +static void io_uring_prep_splice(struct io_uring_sqe *sqe,

And it still misses inline... My bad, I'll resend tomorrow.



> +				 int fd_in, loff_t off_in,
> +				 int fd_out, loff_t off_out,
> +				 unsigned int nbytes, int splice_flags)
> +{
> +	io_uring_prep_rw(IORING_OP_SPLICE, sqe, fd_out, (void *)off_in,
> +			 nbytes, off_out);
> +	sqe->splice_fd_in = fd_in;
> +	sqe->splice_flags = splice_flags;
> +}
> +
>  static inline void io_uring_prep_readv(struct io_uring_sqe *sqe, int fd,
>  				       const struct iovec *iovecs,
>  				       unsigned nr_vecs, off_t offset)
> diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h
> index 424fb4b..dc78697 100644
> --- a/src/include/liburing/io_uring.h
> +++ b/src/include/liburing/io_uring.h
> @@ -23,7 +23,10 @@ struct io_uring_sqe {
>  		__u64	off;	/* offset into file */
>  		__u64	addr2;
>  	};
> -	__u64	addr;		/* pointer to buffer or iovecs */
> +	union {
> +		__u64	addr;	/* pointer to buffer or iovecs */
> +		__u64	off_in;
> +	};
>  	__u32	len;		/* buffer size or number of iovecs */
>  	union {
>  		__kernel_rwf_t	rw_flags;
> @@ -37,6 +40,7 @@ struct io_uring_sqe {
>  		__u32		open_flags;
>  		__u32		statx_flags;
>  		__u32		fadvise_advice;
> +		__u32		splice_flags;
>  	};
>  	__u64	user_data;	/* data to be passed back at completion time */
>  	union {
> @@ -45,6 +49,7 @@ struct io_uring_sqe {
>  			__u16	buf_index;
>  			/* personality to use, if used */
>  			__u16	personality;
> +			__u32	splice_fd_in;
>  		};
>  		__u64	__pad2[3];
>  	};
> @@ -113,6 +118,7 @@ enum {
>  	IORING_OP_RECV,
>  	IORING_OP_OPENAT2,
>  	IORING_OP_EPOLL_CTL,
> +	IORING_OP_SPLICE,
>  
>  	/* this goes last, obviously */
>  	IORING_OP_LAST,
> @@ -128,6 +134,12 @@ enum {
>   */
>  #define IORING_TIMEOUT_ABS	(1U << 0)
>  
> +/*
> + * sqe->splice_flags
> + * extends splice(2) flags
> + */
> +#define SPLICE_F_FD_IN_FIXED	(1U << 31) /* the last bit of __u32 */
> +
>  /*
>   * IO completion data structure (Completion Queue Entry)
>   */
> 

-- 
Pavel Begunkov


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-02-16  1:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <[email protected]>
2020-02-15 22:16 ` [PATCH liburing 1/2] splice: add splice(2) helpers Pavel Begunkov
2020-02-16  1:34   ` Pavel Begunkov
2020-02-15 22:07 [PATCH liburing 0/2] splice helpers + tests Pavel Begunkov
2020-02-15 22:07 ` [PATCH liburing 1/2] splice: add splice(2) helpers Pavel Begunkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox