···643643!Edrivers/spi/spi.c644644 </chapter>645645646646+ <chapter id="splice">647647+ <title>splice API</title>648648+ <para>)649649+ splice is a method for moving blocks of data around inside the650650+ kernel, without continually transferring it between the kernel651651+ and user space.652652+ </para>653653+!Iinclude/linux/splice.h654654+!Ffs/splice.c655655+ </chapter>656656+646657</book>
+85-24
fs/splice.c
···153153 .get = generic_pipe_buf_get,154154};155155156156-/*157157- * Pipe output worker. This fills a pipe with the information contained158158- * from splice_pipe_desc().156156+/**157157+ * splice_to_pipe - fill passed data into a pipe158158+ * @pipe: pipe to fill159159+ * @spd: data to fill160160+ *161161+ * Description:162162+ * @spd contains a map of pages and len/offset tupples, a long with163163+ * the struct pipe_buf_operations associated with these pages. This164164+ * function will link that data to the pipe.165165+ *159166 */160167ssize_t splice_to_pipe(struct pipe_inode_info *pipe,161168 struct splice_pipe_desc *spd)···288281 page_cache_readahead(mapping, &in->f_ra, in, index, nr_pages);289282290283 /*291291- * Now fill in the holes:292292- */293293- error = 0;294294-295295- /*296284 * Lookup the (hopefully) full range of pages we need.297285 */298286 spd.nr_pages = find_get_pages_contig(mapping, index, nr_pages, pages);299287300288 /*301289 * If find_get_pages_contig() returned fewer pages than we needed,302302- * allocate the rest.290290+ * allocate the rest and fill in the holes.303291 */292292+ error = 0;304293 index += spd.nr_pages;305294 while (spd.nr_pages < nr_pages) {306295 /*···458455/**459456 * generic_file_splice_read - splice data from file to a pipe460457 * @in: file to splice from458458+ * @ppos: position in @in461459 * @pipe: pipe to splice to462460 * @len: number of bytes to splice463461 * @flags: splice modifier flags464462 *465465- * Will read pages from given file and fill them into a pipe.463463+ * Description:464464+ * Will read pages from given file and fill them into a pipe. Can be465465+ * used as long as the address_space operations for the source implements466466+ * a readpage() hook.467467+ *466468 */467469ssize_t generic_file_splice_read(struct file *in, loff_t *ppos,468470 struct pipe_inode_info *pipe, size_t len,···656648 return ret;657649}658650659659-/*660660- * Pipe input worker. Most of this logic works like a regular pipe, the661661- * key here is the 'actor' worker passed in that actually moves the data662662- * to the wanted destination. See pipe_to_file/pipe_to_sendpage above.651651+/**652652+ * __splice_from_pipe - splice data from a pipe to given actor653653+ * @pipe: pipe to splice from654654+ * @sd: information to @actor655655+ * @actor: handler that splices the data656656+ *657657+ * Description:658658+ * This function does little more than loop over the pipe and call659659+ * @actor to do the actual moving of a single struct pipe_buffer to660660+ * the desired destination. See pipe_to_file, pipe_to_sendpage, or661661+ * pipe_to_user.662662+ *663663 */664664ssize_t __splice_from_pipe(struct pipe_inode_info *pipe, struct splice_desc *sd,665665 splice_actor *actor)···760744}761745EXPORT_SYMBOL(__splice_from_pipe);762746747747+/**748748+ * splice_from_pipe - splice data from a pipe to a file749749+ * @pipe: pipe to splice from750750+ * @out: file to splice to751751+ * @ppos: position in @out752752+ * @len: how many bytes to splice753753+ * @flags: splice modifier flags754754+ * @actor: handler that splices the data755755+ *756756+ * Description:757757+ * See __splice_from_pipe. This function locks the input and output inodes,758758+ * otherwise it's identical to __splice_from_pipe().759759+ *760760+ */763761ssize_t splice_from_pipe(struct pipe_inode_info *pipe, struct file *out,764762 loff_t *ppos, size_t len, unsigned int flags,765763 splice_actor *actor)···804774 * generic_file_splice_write_nolock - generic_file_splice_write without mutexes805775 * @pipe: pipe info806776 * @out: file to write to777777+ * @ppos: position in @out807778 * @len: number of bytes to splice808779 * @flags: splice modifier flags809780 *810810- * Will either move or copy pages (determined by @flags options) from811811- * the given pipe inode to the given file. The caller is responsible812812- * for acquiring i_mutex on both inodes.781781+ * Description:782782+ * Will either move or copy pages (determined by @flags options) from783783+ * the given pipe inode to the given file. The caller is responsible784784+ * for acquiring i_mutex on both inodes.813785 *814786 */815787ssize_t···863831 * generic_file_splice_write - splice data from a pipe to a file864832 * @pipe: pipe info865833 * @out: file to write to834834+ * @ppos: position in @out866835 * @len: number of bytes to splice867836 * @flags: splice modifier flags868837 *869869- * Will either move or copy pages (determined by @flags options) from870870- * the given pipe inode to the given file.838838+ * Description:839839+ * Will either move or copy pages (determined by @flags options) from840840+ * the given pipe inode to the given file.871841 *872842 */873843ssize_t···920886921887/**922888 * generic_splice_sendpage - splice data from a pipe to a socket923923- * @inode: pipe inode889889+ * @pipe: pipe to splice from924890 * @out: socket to write to891891+ * @ppos: position in @out925892 * @len: number of bytes to splice926893 * @flags: splice modifier flags927894 *928928- * Will send @len bytes from the pipe to a network socket. No data copying929929- * is involved.895895+ * Description:896896+ * Will send @len bytes from the pipe to a network socket. No data copying897897+ * is involved.930898 *931899 */932900ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe, struct file *out,···982946 return in->f_op->splice_read(in, ppos, pipe, len, flags);983947}984948985985-/*986986- * Splices from an input file to an actor, using a 'direct' pipe.949949+/**950950+ * splice_direct_to_actor - splices data directly between two non-pipes951951+ * @in: file to splice from952952+ * @sd: actor information on where to splice to953953+ * @actor: handles the data splicing954954+ *955955+ * Description:956956+ * This is a special case helper to splice directly between two957957+ * points, without requiring an explicit pipe. Internally an allocated958958+ * pipe is cached in the process, and reused during the life time of959959+ * that process.960960+ *987961 */988962ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,989963 splice_direct_actor *actor)···11231077 return do_splice_from(pipe, file, &sd->pos, sd->total_len, sd->flags);11241078}1125107910801080+/**10811081+ * do_splice_direct - splices data directly between two files10821082+ * @in: file to splice from10831083+ * @ppos: input file offset10841084+ * @out: file to splice to10851085+ * @len: number of bytes to splice10861086+ * @flags: splice modifier flags10871087+ *10881088+ * Description:10891089+ * For use by do_sendfile(). splice can easily emulate sendfile, but10901090+ * doing it in the application would incur an extra system call10911091+ * (splice in + splice out, as compared to just sendfile()). So this helper10921092+ * can splice directly through a process-private pipe.10931093+ *10941094+ */11261095long do_splice_direct(struct file *in, loff_t *ppos, struct file *out,11271096 size_t len, unsigned int flags)11281097{