Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions | Variables
splice.c File Reference
#include <linux/fs.h>
#include <linux/file.h>
#include <linux/pagemap.h>
#include <linux/splice.h>
#include <linux/memcontrol.h>
#include <linux/mm_inline.h>
#include <linux/swap.h>
#include <linux/writeback.h>
#include <linux/export.h>
#include <linux/syscalls.h>
#include <linux/uio.h>
#include <linux/security.h>
#include <linux/gfp.h>
#include <linux/socket.h>

Go to the source code of this file.

Functions

ssize_t splice_to_pipe (struct pipe_inode_info *pipe, struct splice_pipe_desc *spd)
 
void spd_release_page (struct splice_pipe_desc *spd, unsigned int i)
 
int splice_grow_spd (const struct pipe_inode_info *pipe, struct splice_pipe_desc *spd)
 
void splice_shrink_spd (struct splice_pipe_desc *spd)
 
ssize_t generic_file_splice_read (struct file *in, loff_t *ppos, struct pipe_inode_info *pipe, size_t len, unsigned int flags)
 
 EXPORT_SYMBOL (generic_file_splice_read)
 
ssize_t default_file_splice_read (struct file *in, loff_t *ppos, struct pipe_inode_info *pipe, size_t len, unsigned int flags)
 
 EXPORT_SYMBOL (default_file_splice_read)
 
int pipe_to_file (struct pipe_inode_info *pipe, struct pipe_buffer *buf, struct splice_desc *sd)
 
 EXPORT_SYMBOL (pipe_to_file)
 
int splice_from_pipe_feed (struct pipe_inode_info *pipe, struct splice_desc *sd, splice_actor *actor)
 
 EXPORT_SYMBOL (splice_from_pipe_feed)
 
int splice_from_pipe_next (struct pipe_inode_info *pipe, struct splice_desc *sd)
 
 EXPORT_SYMBOL (splice_from_pipe_next)
 
void splice_from_pipe_begin (struct splice_desc *sd)
 
 EXPORT_SYMBOL (splice_from_pipe_begin)
 
void splice_from_pipe_end (struct pipe_inode_info *pipe, struct splice_desc *sd)
 
 EXPORT_SYMBOL (splice_from_pipe_end)
 
ssize_t __splice_from_pipe (struct pipe_inode_info *pipe, struct splice_desc *sd, splice_actor *actor)
 
 EXPORT_SYMBOL (__splice_from_pipe)
 
ssize_t splice_from_pipe (struct pipe_inode_info *pipe, struct file *out, loff_t *ppos, size_t len, unsigned int flags, splice_actor *actor)
 
ssize_t generic_file_splice_write (struct pipe_inode_info *pipe, struct file *out, loff_t *ppos, size_t len, unsigned int flags)
 
 EXPORT_SYMBOL (generic_file_splice_write)
 
ssize_t generic_splice_sendpage (struct pipe_inode_info *pipe, struct file *out, loff_t *ppos, size_t len, unsigned int flags)
 
 EXPORT_SYMBOL (generic_splice_sendpage)
 
ssize_t splice_direct_to_actor (struct file *in, struct splice_desc *sd, splice_direct_actor *actor)
 
 EXPORT_SYMBOL (splice_direct_to_actor)
 
long do_splice_direct (struct file *in, loff_t *ppos, struct file *out, size_t len, unsigned int flags)
 
 SYSCALL_DEFINE4 (vmsplice, int, fd, const struct iovec __user *, iov, unsigned long, nr_segs, unsigned int, flags)
 
 SYSCALL_DEFINE6 (splice, int, fd_in, loff_t __user *, off_in, int, fd_out, loff_t __user *, off_out, size_t, len, unsigned int, flags)
 
 SYSCALL_DEFINE4 (tee, int, fdin, int, fdout, size_t, len, unsigned int, flags)
 

Variables

struct pipe_buf_operations page_cache_pipe_buf_ops
 

Function Documentation

ssize_t __splice_from_pipe ( struct pipe_inode_info pipe,
struct splice_desc sd,
splice_actor actor 
)

__splice_from_pipe - splice data from a pipe to given actor : pipe to splice from : information to : handler that splices the data

Description: This function does little more than loop over the pipe and call to do the actual moving of a single struct pipe_buffer to the desired destination. See pipe_to_file, pipe_to_sendpage, or pipe_to_user.

Definition at line 922 of file splice.c.

ssize_t default_file_splice_read ( struct file in,
loff_t *  ppos,
struct pipe_inode_info pipe,
size_t  len,
unsigned int  flags 
)

Definition at line 587 of file splice.c.

long do_splice_direct ( struct file in,
loff_t *  ppos,
struct file out,
size_t  len,
unsigned int  flags 
)

do_splice_direct - splices data directly between two files : file to splice from : input file offset : file to splice to : number of bytes to splice : splice modifier flags

Description: For use by do_sendfile(). splice can easily emulate sendfile, but doing it in the application would incur an extra system call (splice in + splice out, as compared to just sendfile()). So this helper can splice directly through a process-private pipe.

Definition at line 1293 of file splice.c.

EXPORT_SYMBOL ( generic_file_splice_read  )
EXPORT_SYMBOL ( default_file_splice_read  )
EXPORT_SYMBOL ( pipe_to_file  )
EXPORT_SYMBOL ( splice_from_pipe_feed  )
EXPORT_SYMBOL ( splice_from_pipe_next  )
EXPORT_SYMBOL ( splice_from_pipe_begin  )
EXPORT_SYMBOL ( splice_from_pipe_end  )
EXPORT_SYMBOL ( __splice_from_pipe  )
EXPORT_SYMBOL ( generic_file_splice_write  )
EXPORT_SYMBOL ( generic_splice_sendpage  )
EXPORT_SYMBOL ( splice_direct_to_actor  )
ssize_t generic_file_splice_read ( struct file in,
loff_t *  ppos,
struct pipe_inode_info pipe,
size_t  len,
unsigned int  flags 
)

generic_file_splice_read - splice data from file to a pipe : file to splice from : position in : pipe to splice to : number of bytes to splice : splice modifier flags

Description: Will read pages from given file and fill them into a pipe. Can be used as long as the address_space operations for the source implements a readpage() hook.

Definition at line 521 of file splice.c.

ssize_t generic_file_splice_write ( struct pipe_inode_info pipe,
struct file out,
loff_t *  ppos,
size_t  len,
unsigned int  flags 
)

generic_file_splice_write - splice data from a pipe to a file : pipe info : file to write to : position in : number of bytes to splice : splice modifier flags

Description: Will either move or copy pages (determined by options) from the given pipe inode to the given file.

Definition at line 986 of file splice.c.

ssize_t generic_splice_sendpage ( struct pipe_inode_info pipe,
struct file out,
loff_t *  ppos,
size_t  len,
unsigned int  flags 
)

generic_splice_sendpage - splice data from a pipe to a socket : pipe to splice from : socket to write to : position in : number of bytes to splice : splice modifier flags

Description: Will send bytes from the pipe to a network socket. No data copying is involved.

Definition at line 1085 of file splice.c.

int pipe_to_file ( struct pipe_inode_info pipe,
struct pipe_buffer buf,
struct splice_desc sd 
)

Definition at line 725 of file splice.c.

void spd_release_page ( struct splice_pipe_desc spd,
unsigned int  i 
)

Definition at line 267 of file splice.c.

ssize_t splice_direct_to_actor ( struct file in,
struct splice_desc sd,
splice_direct_actor actor 
)

splice_direct_to_actor - splices data directly between two non-pipes : file to splice from : actor information on where to splice to : handles the data splicing

Description: This is a special case helper to splice directly between two points, without requiring an explicit pipe. Internally an allocated pipe is cached in the process, and reused during the lifetime of that process.

Definition at line 1160 of file splice.c.

ssize_t splice_from_pipe ( struct pipe_inode_info pipe,
struct file out,
loff_t *  ppos,
size_t  len,
unsigned int  flags,
splice_actor actor 
)

splice_from_pipe - splice data from a pipe to a file : pipe to splice from : file to splice to : position in : how many bytes to splice : splice modifier flags : handler that splices the data

Description: See __splice_from_pipe. This function locks the pipe inode, otherwise it's identical to __splice_from_pipe().

Definition at line 953 of file splice.c.

void splice_from_pipe_begin ( struct splice_desc sd)

splice_from_pipe_begin - start splicing from pipe : information about the splice operation

Description: This function should be called before a loop containing splice_from_pipe_next() and splice_from_pipe_feed() to initialize the necessary fields of .

Definition at line 885 of file splice.c.

void splice_from_pipe_end ( struct pipe_inode_info pipe,
struct splice_desc sd 
)

splice_from_pipe_end - finish splicing from pipe : pipe to splice from : information about the splice operation

Description: This function will wake up pipe writers if necessary. It should be called after a loop containing splice_from_pipe_next() and splice_from_pipe_feed().

Definition at line 902 of file splice.c.

int splice_from_pipe_feed ( struct pipe_inode_info pipe,
struct splice_desc sd,
splice_actor actor 
)

splice_from_pipe_feed - feed available data from a pipe to a file : pipe to splice from : information to : handler that splices the data

Description: This function loops over the pipe and calls to do the actual moving of a single struct pipe_buffer to the desired destination. It returns when there's no more buffers left in the pipe or if the requested number of bytes (->total_len) have been copied. It returns a positive number (one) if the pipe needs to be filled with more data, zero if the required number of bytes have been copied and -errno on error.

This, together with splice_from_pipe_{begin,end,next}, may be used to implement the functionality of __splice_from_pipe() when locking is required around copying the pipe buffers to the destination.

Definition at line 790 of file splice.c.

int splice_from_pipe_next ( struct pipe_inode_info pipe,
struct splice_desc sd 
)

splice_from_pipe_next - wait for some data to splice from : pipe to splice from : information about the splice operation

Description: This function will wait for some data and return a positive value (one) if pipe buffers are available. It will return zero or -errno if no more data needs to be spliced.

Definition at line 849 of file splice.c.

int splice_grow_spd ( const struct pipe_inode_info pipe,
struct splice_pipe_desc spd 
)

Definition at line 276 of file splice.c.

void splice_shrink_spd ( struct splice_pipe_desc spd)

Definition at line 295 of file splice.c.

ssize_t splice_to_pipe ( struct pipe_inode_info pipe,
struct splice_pipe_desc spd 
)

splice_to_pipe - fill passed data into a pipe : pipe to fill : data to fill

Description: contains a map of pages and len/offset tuples, along with the struct pipe_buf_operations associated with these pages. This function will link that data to the pipe.

Definition at line 184 of file splice.c.

SYSCALL_DEFINE4 ( vmsplice  ,
int  ,
fd  ,
const struct iovec __user ,
iov  ,
unsigned  long,
nr_segs  ,
unsigned  int,
flags   
)

Definition at line 1666 of file splice.c.

SYSCALL_DEFINE4 ( tee  ,
int  ,
fdin  ,
int  ,
fdout  ,
size_t  ,
len  ,
unsigned  int,
flags   
)

Definition at line 2024 of file splice.c.

SYSCALL_DEFINE6 ( splice  ,
int  ,
fd_in  ,
loff_t __user ,
off_in  ,
int  ,
fd_out  ,
loff_t __user ,
off_out  ,
size_t  ,
len  ,
unsigned  int,
flags   
)

Definition at line 1691 of file splice.c.

Variable Documentation

struct pipe_buf_operations page_cache_pipe_buf_ops
Initial value:
= {
.can_merge = 0,
.confirm = page_cache_pipe_buf_confirm,
.release = page_cache_pipe_buf_release,
.steal = page_cache_pipe_buf_steal,
}

Definition at line 135 of file splice.c.