[PATCH] splice: rearrange moving to/from pipe helpers

We need these for people writing their own ->splice_read/write hooks.

Signed-off-by: Jens Axboe <axboe@suse.de>

+28 -24
+11 -24
fs/splice.c
··· 29 29 #include <linux/syscalls.h> 30 30 #include <linux/uio.h> 31 31 32 - /* 33 - * Passed to the actors 34 - */ 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 - 42 32 struct partial_page { 43 33 unsigned int offset; 44 34 unsigned int len; 45 35 }; 46 36 47 37 /* 48 - * Passed to move_to_pipe 38 + * Passed to splice_to_pipe 49 39 */ 50 40 struct splice_pipe_desc { 51 41 struct page **pages; /* page map */ ··· 182 192 * Pipe output worker. This sets up our pipe format with the page cache 183 193 * pipe buffer operations. Otherwise very similar to the regular pipe_writev(). 184 194 */ 185 - static ssize_t move_to_pipe(struct pipe_inode_info *pipe, 186 - struct splice_pipe_desc *spd) 195 + static ssize_t splice_to_pipe(struct pipe_inode_info *pipe, 196 + struct splice_pipe_desc *spd) 187 197 { 188 198 int ret, do_wakeup, page_nr; 189 199 ··· 422 432 } 423 433 424 434 if (spd.nr_pages) 425 - return move_to_pipe(pipe, &spd); 435 + return splice_to_pipe(pipe, &spd); 426 436 427 437 return error; 428 438 } ··· 656 666 return ret; 657 667 } 658 668 659 - typedef int (splice_actor)(struct pipe_inode_info *, struct pipe_buffer *, 660 - struct splice_desc *); 661 - 662 669 /* 663 670 * Pipe input worker. Most of this logic works like a regular pipe, the 664 671 * key here is the 'actor' worker passed in that actually moves the data 665 672 * to the wanted destination. See pipe_to_file/pipe_to_sendpage above. 666 673 */ 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) 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) 670 677 { 671 678 int ret, do_wakeup, err; 672 679 struct splice_desc sd; ··· 782 795 struct address_space *mapping = out->f_mapping; 783 796 ssize_t ret; 784 797 785 - ret = move_from_pipe(pipe, out, ppos, len, flags, pipe_to_file); 798 + ret = splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_file); 786 799 if (ret > 0) { 787 800 struct inode *inode = mapping->host; 788 801 ··· 824 837 ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe, struct file *out, 825 838 loff_t *ppos, size_t len, unsigned int flags) 826 839 { 827 - return move_from_pipe(pipe, out, ppos, len, flags, pipe_to_sendpage); 840 + return splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_sendpage); 828 841 } 829 842 830 843 EXPORT_SYMBOL(generic_splice_sendpage); ··· 911 924 912 925 /* 913 926 * We don't have an immediate reader, but we'll read the stuff 914 - * out of the pipe right after the move_to_pipe(). So set 927 + * out of the pipe right after the splice_to_pipe(). So set 915 928 * PIPE_READERS appropriately. 916 929 */ 917 930 pipe->readers = 1; ··· 1197 1210 if (spd.nr_pages <= 0) 1198 1211 return spd.nr_pages; 1199 1212 1200 - return move_to_pipe(pipe, &spd); 1213 + return splice_to_pipe(pipe, &spd); 1201 1214 } 1202 1215 1203 1216 asmlinkage long sys_vmsplice(int fd, const struct iovec __user *iov,
+17
include/linux/pipe_fs_i.h
··· 61 61 /* from/to, of course */ 62 62 #define SPLICE_F_MORE (0x04) /* expect more data */ 63 63 64 + /* 65 + * Passed to the actors 66 + */ 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 + 64 81 #endif