Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

splice: completely document external interface with kerneldoc

Also add fs/splice.c as a kerneldoc target with a smaller blurb that
should be expanded to better explain the overview of splice.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>

+96 -24
+11
Documentation/DocBook/kernel-api.tmpl
··· 643 643 !Edrivers/spi/spi.c 644 644 </chapter> 645 645 646 + <chapter id="splice"> 647 + <title>splice API</title> 648 + <para>) 649 + splice is a method for moving blocks of data around inside the 650 + kernel, without continually transferring it between the kernel 651 + and user space. 652 + </para> 653 + !Iinclude/linux/splice.h 654 + !Ffs/splice.c 655 + </chapter> 656 + 646 657 </book>
+85 -24
fs/splice.c
··· 153 153 .get = generic_pipe_buf_get, 154 154 }; 155 155 156 - /* 157 - * Pipe output worker. This fills a pipe with the information contained 158 - * from splice_pipe_desc(). 156 + /** 157 + * splice_to_pipe - fill passed data into a pipe 158 + * @pipe: pipe to fill 159 + * @spd: data to fill 160 + * 161 + * Description: 162 + * @spd contains a map of pages and len/offset tupples, a long with 163 + * the struct pipe_buf_operations associated with these pages. This 164 + * function will link that data to the pipe. 165 + * 159 166 */ 160 167 ssize_t splice_to_pipe(struct pipe_inode_info *pipe, 161 168 struct splice_pipe_desc *spd) ··· 288 281 page_cache_readahead(mapping, &in->f_ra, in, index, nr_pages); 289 282 290 283 /* 291 - * Now fill in the holes: 292 - */ 293 - error = 0; 294 - 295 - /* 296 284 * Lookup the (hopefully) full range of pages we need. 297 285 */ 298 286 spd.nr_pages = find_get_pages_contig(mapping, index, nr_pages, pages); 299 287 300 288 /* 301 289 * If find_get_pages_contig() returned fewer pages than we needed, 302 - * allocate the rest. 290 + * allocate the rest and fill in the holes. 303 291 */ 292 + error = 0; 304 293 index += spd.nr_pages; 305 294 while (spd.nr_pages < nr_pages) { 306 295 /* ··· 458 455 /** 459 456 * generic_file_splice_read - splice data from file to a pipe 460 457 * @in: file to splice from 458 + * @ppos: position in @in 461 459 * @pipe: pipe to splice to 462 460 * @len: number of bytes to splice 463 461 * @flags: splice modifier flags 464 462 * 465 - * Will read pages from given file and fill them into a pipe. 463 + * Description: 464 + * Will read pages from given file and fill them into a pipe. Can be 465 + * used as long as the address_space operations for the source implements 466 + * a readpage() hook. 467 + * 466 468 */ 467 469 ssize_t generic_file_splice_read(struct file *in, loff_t *ppos, 468 470 struct pipe_inode_info *pipe, size_t len, ··· 656 648 return ret; 657 649 } 658 650 659 - /* 660 - * Pipe input worker. Most of this logic works like a regular pipe, the 661 - * key here is the 'actor' worker passed in that actually moves the data 662 - * to the wanted destination. See pipe_to_file/pipe_to_sendpage above. 651 + /** 652 + * __splice_from_pipe - splice data from a pipe to given actor 653 + * @pipe: pipe to splice from 654 + * @sd: information to @actor 655 + * @actor: handler that splices the data 656 + * 657 + * Description: 658 + * This function does little more than loop over the pipe and call 659 + * @actor to do the actual moving of a single struct pipe_buffer to 660 + * the desired destination. See pipe_to_file, pipe_to_sendpage, or 661 + * pipe_to_user. 662 + * 663 663 */ 664 664 ssize_t __splice_from_pipe(struct pipe_inode_info *pipe, struct splice_desc *sd, 665 665 splice_actor *actor) ··· 760 744 } 761 745 EXPORT_SYMBOL(__splice_from_pipe); 762 746 747 + /** 748 + * splice_from_pipe - splice data from a pipe to a file 749 + * @pipe: pipe to splice from 750 + * @out: file to splice to 751 + * @ppos: position in @out 752 + * @len: how many bytes to splice 753 + * @flags: splice modifier flags 754 + * @actor: handler that splices the data 755 + * 756 + * Description: 757 + * See __splice_from_pipe. This function locks the input and output inodes, 758 + * otherwise it's identical to __splice_from_pipe(). 759 + * 760 + */ 763 761 ssize_t splice_from_pipe(struct pipe_inode_info *pipe, struct file *out, 764 762 loff_t *ppos, size_t len, unsigned int flags, 765 763 splice_actor *actor) ··· 804 774 * generic_file_splice_write_nolock - generic_file_splice_write without mutexes 805 775 * @pipe: pipe info 806 776 * @out: file to write to 777 + * @ppos: position in @out 807 778 * @len: number of bytes to splice 808 779 * @flags: splice modifier flags 809 780 * 810 - * Will either move or copy pages (determined by @flags options) from 811 - * the given pipe inode to the given file. The caller is responsible 812 - * for acquiring i_mutex on both inodes. 781 + * Description: 782 + * Will either move or copy pages (determined by @flags options) from 783 + * the given pipe inode to the given file. The caller is responsible 784 + * for acquiring i_mutex on both inodes. 813 785 * 814 786 */ 815 787 ssize_t ··· 863 831 * generic_file_splice_write - splice data from a pipe to a file 864 832 * @pipe: pipe info 865 833 * @out: file to write to 834 + * @ppos: position in @out 866 835 * @len: number of bytes to splice 867 836 * @flags: splice modifier flags 868 837 * 869 - * Will either move or copy pages (determined by @flags options) from 870 - * the given pipe inode to the given file. 838 + * Description: 839 + * Will either move or copy pages (determined by @flags options) from 840 + * the given pipe inode to the given file. 871 841 * 872 842 */ 873 843 ssize_t ··· 920 886 921 887 /** 922 888 * generic_splice_sendpage - splice data from a pipe to a socket 923 - * @inode: pipe inode 889 + * @pipe: pipe to splice from 924 890 * @out: socket to write to 891 + * @ppos: position in @out 925 892 * @len: number of bytes to splice 926 893 * @flags: splice modifier flags 927 894 * 928 - * Will send @len bytes from the pipe to a network socket. No data copying 929 - * is involved. 895 + * Description: 896 + * Will send @len bytes from the pipe to a network socket. No data copying 897 + * is involved. 930 898 * 931 899 */ 932 900 ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe, struct file *out, ··· 982 946 return in->f_op->splice_read(in, ppos, pipe, len, flags); 983 947 } 984 948 985 - /* 986 - * Splices from an input file to an actor, using a 'direct' pipe. 949 + /** 950 + * splice_direct_to_actor - splices data directly between two non-pipes 951 + * @in: file to splice from 952 + * @sd: actor information on where to splice to 953 + * @actor: handles the data splicing 954 + * 955 + * Description: 956 + * This is a special case helper to splice directly between two 957 + * points, without requiring an explicit pipe. Internally an allocated 958 + * pipe is cached in the process, and reused during the life time of 959 + * that process. 960 + * 987 961 */ 988 962 ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd, 989 963 splice_direct_actor *actor) ··· 1123 1077 return do_splice_from(pipe, file, &sd->pos, sd->total_len, sd->flags); 1124 1078 } 1125 1079 1080 + /** 1081 + * do_splice_direct - splices data directly between two files 1082 + * @in: file to splice from 1083 + * @ppos: input file offset 1084 + * @out: file to splice to 1085 + * @len: number of bytes to splice 1086 + * @flags: splice modifier flags 1087 + * 1088 + * Description: 1089 + * For use by do_sendfile(). splice can easily emulate sendfile, but 1090 + * doing it in the application would incur an extra system call 1091 + * (splice in + splice out, as compared to just sendfile()). So this helper 1092 + * can splice directly through a process-private pipe. 1093 + * 1094 + */ 1126 1095 long do_splice_direct(struct file *in, loff_t *ppos, struct file *out, 1127 1096 size_t len, unsigned int flags) 1128 1097 {