···29#include <linux/syscalls.h>30#include <linux/uio.h>3132-/*33- * Passed to the actors34- */35-struct splice_desc {36- unsigned int len, total_len; /* current and remaining length */37- unsigned int flags; /* splice flags */38- struct file *file; /* file to read/write */39- loff_t pos; /* file position */40-};41-42struct partial_page {43 unsigned int offset;44 unsigned int len;45};4647/*48- * Passed to move_to_pipe49 */50struct splice_pipe_desc {51 struct page **pages; /* page map */···182 * Pipe output worker. This sets up our pipe format with the page cache183 * pipe buffer operations. Otherwise very similar to the regular pipe_writev().184 */185-static ssize_t move_to_pipe(struct pipe_inode_info *pipe,186- struct splice_pipe_desc *spd)187{188 int ret, do_wakeup, page_nr;189···422 }423424 if (spd.nr_pages)425- return move_to_pipe(pipe, &spd);426427 return error;428}···656 return ret;657}658659-typedef int (splice_actor)(struct pipe_inode_info *, struct pipe_buffer *,660- struct splice_desc *);661-662/*663 * Pipe input worker. Most of this logic works like a regular pipe, the664 * key here is the 'actor' worker passed in that actually moves the data665 * to the wanted destination. See pipe_to_file/pipe_to_sendpage above.666 */667-static ssize_t move_from_pipe(struct pipe_inode_info *pipe, struct file *out,668- loff_t *ppos, size_t len, unsigned int flags,669- splice_actor *actor)670{671 int ret, do_wakeup, err;672 struct splice_desc sd;···782 struct address_space *mapping = out->f_mapping;783 ssize_t ret;784785- ret = move_from_pipe(pipe, out, ppos, len, flags, pipe_to_file);786 if (ret > 0) {787 struct inode *inode = mapping->host;788···824ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe, struct file *out,825 loff_t *ppos, size_t len, unsigned int flags)826{827- return move_from_pipe(pipe, out, ppos, len, flags, pipe_to_sendpage);828}829830EXPORT_SYMBOL(generic_splice_sendpage);···911912 /*913 * We don't have an immediate reader, but we'll read the stuff914- * out of the pipe right after the move_to_pipe(). So set915 * PIPE_READERS appropriately.916 */917 pipe->readers = 1;···1197 if (spd.nr_pages <= 0)1198 return spd.nr_pages;11991200- return move_to_pipe(pipe, &spd);1201}12021203asmlinkage long sys_vmsplice(int fd, const struct iovec __user *iov,
···29#include <linux/syscalls.h>30#include <linux/uio.h>31000000000032struct partial_page {33 unsigned int offset;34 unsigned int len;35};3637/*38+ * Passed to splice_to_pipe39 */40struct splice_pipe_desc {41 struct page **pages; /* page map */···192 * Pipe output worker. This sets up our pipe format with the page cache193 * pipe buffer operations. Otherwise very similar to the regular pipe_writev().194 */195+static ssize_t splice_to_pipe(struct pipe_inode_info *pipe,196+ struct splice_pipe_desc *spd)197{198 int ret, do_wakeup, page_nr;199···432 }433434 if (spd.nr_pages)435+ return splice_to_pipe(pipe, &spd);436437 return error;438}···666 return ret;667}668000669/*670 * Pipe input worker. Most of this logic works like a regular pipe, the671 * key here is the 'actor' worker passed in that actually moves the data672 * to the wanted destination. See pipe_to_file/pipe_to_sendpage above.673 */674+ssize_t splice_from_pipe(struct pipe_inode_info *pipe, struct file *out,675+ loff_t *ppos, size_t len, unsigned int flags,676+ splice_actor *actor)677{678 int ret, do_wakeup, err;679 struct splice_desc sd;···795 struct address_space *mapping = out->f_mapping;796 ssize_t ret;797798+ ret = splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_file);799 if (ret > 0) {800 struct inode *inode = mapping->host;801···837ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe, struct file *out,838 loff_t *ppos, size_t len, unsigned int flags)839{840+ return splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_sendpage);841}842843EXPORT_SYMBOL(generic_splice_sendpage);···924925 /*926 * We don't have an immediate reader, but we'll read the stuff927+ * out of the pipe right after the splice_to_pipe(). So set928 * PIPE_READERS appropriately.929 */930 pipe->readers = 1;···1210 if (spd.nr_pages <= 0)1211 return spd.nr_pages;12121213+ return splice_to_pipe(pipe, &spd);1214}12151216asmlinkage long sys_vmsplice(int fd, const struct iovec __user *iov,
+17
include/linux/pipe_fs_i.h
···61 /* from/to, of course */62#define SPLICE_F_MORE (0x04) /* expect more data */630000000000000000064#endif
···61 /* from/to, of course */62#define SPLICE_F_MORE (0x04) /* expect more data */6364+/*65+ * Passed to the actors66+ */67+struct splice_desc {68+ unsigned int len, total_len; /* current and remaining length */69+ unsigned int flags; /* splice flags */70+ struct file *file; /* file to read/write */71+ loff_t pos; /* file position */72+};73+74+typedef int (splice_actor)(struct pipe_inode_info *, struct pipe_buffer *,75+ struct splice_desc *);76+77+extern ssize_t splice_from_pipe(struct pipe_inode_info *, struct file *,78+ loff_t *, size_t, unsigned int,79+ splice_actor *);80+81#endif