Skip to content

Commit

Permalink
Merge branch 'splice-2.6.23' of git://git.kernel.dk/data/git/linux-2.…
Browse files Browse the repository at this point in the history
…6-block

* 'splice-2.6.23' of git://git.kernel.dk/data/git/linux-2.6-block:
  pipe: add documentation and comments
  pipe: change the ->pin() operation to ->confirm()
  Remove remnants of sendfile()
  xip sendfile removal
  splice: completely document external interface with kerneldoc
  sendfile: remove bad_sendfile() from bad_file_ops
  shmem: convert to using splice instead of sendfile()
  relay: use splice_to_pipe() instead of open-coding the pipe loop
  pipe: allow passing around of ops private pointer
  splice: divorce the splice structure/function definitions from the pipe header
  splice: relay support
  sendfile: convert nfsd to splice_direct_to_actor()
  sendfile: convert nfs to using splice_read()
  loop: convert to using splice_direct_to_actor() instead of sendfile()
  splice: add void cookie to the actor data
  sendfile: kill generic_file_sendfile()
  sendfile: remove .sendfile from filesystems that use generic_file_sendfile()
  sys_sendfile: switch to using ->splice_read, if available
  vmsplice: add vmsplice-to-user support
  splice: abstract out actor data
  • Loading branch information
Linus Torvalds committed Jul 10, 2007
2 parents 5cbc39a + 0845718 commit 01370f0
Show file tree
Hide file tree
Showing 56 changed files with 874 additions and 459 deletions.
11 changes: 11 additions & 0 deletions Documentation/DocBook/kernel-api.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -643,4 +643,15 @@ X!Idrivers/video/console/fonts.c
!Edrivers/spi/spi.c
</chapter>

<chapter id="splice">
<title>splice API</title>
<para>)
splice is a method for moving blocks of data around inside the
kernel, without continually transferring it between the kernel
and user space.
</para>
!Iinclude/linux/splice.h
!Ffs/splice.c
</chapter>

</book>
64 changes: 44 additions & 20 deletions drivers/block/loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
#include <linux/highmem.h>
#include <linux/gfp.h>
#include <linux/kthread.h>
#include <linux/splice.h>

#include <asm/uaccess.h>

Expand Down Expand Up @@ -401,50 +402,73 @@ struct lo_read_data {
};

static int
lo_read_actor(read_descriptor_t *desc, struct page *page,
unsigned long offset, unsigned long size)
lo_splice_actor(struct pipe_inode_info *pipe, struct pipe_buffer *buf,
struct splice_desc *sd)
{
unsigned long count = desc->count;
struct lo_read_data *p = desc->arg.data;
struct lo_read_data *p = sd->u.data;
struct loop_device *lo = p->lo;
struct page *page = buf->page;
sector_t IV;
size_t size;
int ret;

IV = ((sector_t) page->index << (PAGE_CACHE_SHIFT - 9))+(offset >> 9);
ret = buf->ops->confirm(pipe, buf);
if (unlikely(ret))
return ret;

if (size > count)
size = count;
IV = ((sector_t) page->index << (PAGE_CACHE_SHIFT - 9)) +
(buf->offset >> 9);
size = sd->len;
if (size > p->bsize)
size = p->bsize;

if (lo_do_transfer(lo, READ, page, offset, p->page, p->offset, size, IV)) {
size = 0;
if (lo_do_transfer(lo, READ, page, buf->offset, p->page, p->offset, size, IV)) {
printk(KERN_ERR "loop: transfer error block %ld\n",
page->index);
desc->error = -EINVAL;
size = -EINVAL;
}

flush_dcache_page(p->page);

desc->count = count - size;
desc->written += size;
p->offset += size;
if (size > 0)
p->offset += size;

return size;
}

static int
lo_direct_splice_actor(struct pipe_inode_info *pipe, struct splice_desc *sd)
{
return __splice_from_pipe(pipe, sd, lo_splice_actor);
}

static int
do_lo_receive(struct loop_device *lo,
struct bio_vec *bvec, int bsize, loff_t pos)
{
struct lo_read_data cookie;
struct splice_desc sd;
struct file *file;
int retval;
long retval;

cookie.lo = lo;
cookie.page = bvec->bv_page;
cookie.offset = bvec->bv_offset;
cookie.bsize = bsize;

sd.len = 0;
sd.total_len = bvec->bv_len;
sd.flags = 0;
sd.pos = pos;
sd.u.data = &cookie;

file = lo->lo_backing_file;
retval = file->f_op->sendfile(file, &pos, bvec->bv_len,
lo_read_actor, &cookie);
return (retval < 0)? retval: 0;
retval = splice_direct_to_actor(file, &sd, lo_direct_splice_actor);

if (retval < 0)
return retval;

return 0;
}

static int
Expand Down Expand Up @@ -679,8 +703,8 @@ static int loop_change_fd(struct loop_device *lo, struct file *lo_file,
if (!S_ISREG(inode->i_mode) && !S_ISBLK(inode->i_mode))
goto out_putf;

/* new backing store needs to support loop (eg sendfile) */
if (!inode->i_fop->sendfile)
/* new backing store needs to support loop (eg splice_read) */
if (!inode->i_fop->splice_read)
goto out_putf;

/* size of the new backing store needs to be the same */
Expand Down Expand Up @@ -760,7 +784,7 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
* If we can't read - sorry. If we only can't write - well,
* it's going to be read-only.
*/
if (!file->f_op->sendfile)
if (!file->f_op->splice_read)
goto out_putf;
if (aops->prepare_write && aops->commit_write)
lo_flags |= LO_FLAGS_USE_AOPS;
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <linux/crash_dump.h>
#include <linux/backing-dev.h>
#include <linux/bootmem.h>
#include <linux/pipe_fs_i.h>
#include <linux/splice.h>
#include <linux/pfn.h>

#include <asm/uaccess.h>
Expand Down
2 changes: 1 addition & 1 deletion fs/adfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const struct file_operations adfs_file_operations = {
.fsync = file_fsync,
.write = do_sync_write,
.aio_write = generic_file_aio_write,
.sendfile = generic_file_sendfile,
.splice_read = generic_file_splice_read,
};

const struct inode_operations adfs_file_inode_operations = {
Expand Down
2 changes: 1 addition & 1 deletion fs/affs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const struct file_operations affs_file_operations = {
.open = affs_file_open,
.release = affs_file_release,
.fsync = file_fsync,
.sendfile = generic_file_sendfile,
.splice_read = generic_file_splice_read,
};

const struct inode_operations affs_file_inode_operations = {
Expand Down
2 changes: 1 addition & 1 deletion fs/afs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const struct file_operations afs_file_operations = {
.aio_read = generic_file_aio_read,
.aio_write = afs_file_write,
.mmap = generic_file_readonly_mmap,
.sendfile = generic_file_sendfile,
.splice_read = generic_file_splice_read,
.fsync = afs_fsync,
};

Expand Down
7 changes: 0 additions & 7 deletions fs/bad_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,6 @@ static int bad_file_lock(struct file *file, int cmd, struct file_lock *fl)
return -EIO;
}

static ssize_t bad_file_sendfile(struct file *in_file, loff_t *ppos,
size_t count, read_actor_t actor, void *target)
{
return -EIO;
}

static ssize_t bad_file_sendpage(struct file *file, struct page *page,
int off, size_t len, loff_t *pos, int more)
{
Expand Down Expand Up @@ -182,7 +176,6 @@ static const struct file_operations bad_file_ops =
.aio_fsync = bad_file_aio_fsync,
.fasync = bad_file_fasync,
.lock = bad_file_lock,
.sendfile = bad_file_sendfile,
.sendpage = bad_file_sendpage,
.get_unmapped_area = bad_file_get_unmapped_area,
.check_flags = bad_file_check_flags,
Expand Down
2 changes: 1 addition & 1 deletion fs/bfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const struct file_operations bfs_file_operations = {
.write = do_sync_write,
.aio_write = generic_file_aio_write,
.mmap = generic_file_mmap,
.sendfile = generic_file_sendfile,
.splice_read = generic_file_splice_read,
};

static int bfs_move_block(unsigned long from, unsigned long to, struct super_block *sb)
Expand Down
1 change: 0 additions & 1 deletion fs/block_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,6 @@ const struct file_operations def_blk_fops = {
#ifdef CONFIG_COMPAT
.compat_ioctl = compat_blkdev_ioctl,
#endif
.sendfile = generic_file_sendfile,
.splice_read = generic_file_splice_read,
.splice_write = generic_file_splice_write,
};
Expand Down
8 changes: 4 additions & 4 deletions fs/cifs/cifsfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ const struct file_operations cifs_file_ops = {
.fsync = cifs_fsync,
.flush = cifs_flush,
.mmap = cifs_file_mmap,
.sendfile = generic_file_sendfile,
.splice_read = generic_file_splice_read,
.llseek = cifs_llseek,
#ifdef CONFIG_CIFS_POSIX
.ioctl = cifs_ioctl,
Expand All @@ -637,7 +637,7 @@ const struct file_operations cifs_file_direct_ops = {
.lock = cifs_lock,
.fsync = cifs_fsync,
.flush = cifs_flush,
.sendfile = generic_file_sendfile, /* BB removeme BB */
.splice_read = generic_file_splice_read,
#ifdef CONFIG_CIFS_POSIX
.ioctl = cifs_ioctl,
#endif /* CONFIG_CIFS_POSIX */
Expand All @@ -656,7 +656,7 @@ const struct file_operations cifs_file_nobrl_ops = {
.fsync = cifs_fsync,
.flush = cifs_flush,
.mmap = cifs_file_mmap,
.sendfile = generic_file_sendfile,
.splice_read = generic_file_splice_read,
.llseek = cifs_llseek,
#ifdef CONFIG_CIFS_POSIX
.ioctl = cifs_ioctl,
Expand All @@ -676,7 +676,7 @@ const struct file_operations cifs_file_direct_nobrl_ops = {
.release = cifs_close,
.fsync = cifs_fsync,
.flush = cifs_flush,
.sendfile = generic_file_sendfile, /* BB removeme BB */
.splice_read = generic_file_splice_read,
#ifdef CONFIG_CIFS_POSIX
.ioctl = cifs_ioctl,
#endif /* CONFIG_CIFS_POSIX */
Expand Down
11 changes: 6 additions & 5 deletions fs/coda/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ coda_file_read(struct file *coda_file, char __user *buf, size_t count, loff_t *p
}

static ssize_t
coda_file_sendfile(struct file *coda_file, loff_t *ppos, size_t count,
read_actor_t actor, void *target)
coda_file_splice_read(struct file *coda_file, loff_t *ppos,
struct pipe_inode_info *pipe, size_t count,
unsigned int flags)
{
struct coda_file_info *cfi;
struct file *host_file;
Expand All @@ -57,10 +58,10 @@ coda_file_sendfile(struct file *coda_file, loff_t *ppos, size_t count,
BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
host_file = cfi->cfi_container;

if (!host_file->f_op || !host_file->f_op->sendfile)
if (!host_file->f_op || !host_file->f_op->splice_read)
return -EINVAL;

return host_file->f_op->sendfile(host_file, ppos, count, actor, target);
return host_file->f_op->splice_read(host_file, ppos, pipe, count,flags);
}

static ssize_t
Expand Down Expand Up @@ -295,6 +296,6 @@ const struct file_operations coda_file_operations = {
.flush = coda_flush,
.release = coda_release,
.fsync = coda_fsync,
.sendfile = coda_file_sendfile,
.splice_read = coda_file_splice_read,
};

15 changes: 8 additions & 7 deletions fs/ecryptfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,16 +338,17 @@ static int ecryptfs_fasync(int fd, struct file *file, int flag)
return rc;
}

static ssize_t ecryptfs_sendfile(struct file *file, loff_t * ppos,
size_t count, read_actor_t actor, void *target)
static ssize_t ecryptfs_splice_read(struct file *file, loff_t * ppos,
struct pipe_inode_info *pipe, size_t count,
unsigned int flags)
{
struct file *lower_file = NULL;
int rc = -EINVAL;

lower_file = ecryptfs_file_to_lower(file);
if (lower_file->f_op && lower_file->f_op->sendfile)
rc = lower_file->f_op->sendfile(lower_file, ppos, count,
actor, target);
if (lower_file->f_op && lower_file->f_op->splice_read)
rc = lower_file->f_op->splice_read(lower_file, ppos, pipe,
count, flags);

return rc;
}
Expand All @@ -364,7 +365,7 @@ const struct file_operations ecryptfs_dir_fops = {
.release = ecryptfs_release,
.fsync = ecryptfs_fsync,
.fasync = ecryptfs_fasync,
.sendfile = ecryptfs_sendfile,
.splice_read = ecryptfs_splice_read,
};

const struct file_operations ecryptfs_main_fops = {
Expand All @@ -381,7 +382,7 @@ const struct file_operations ecryptfs_main_fops = {
.release = ecryptfs_release,
.fsync = ecryptfs_fsync,
.fasync = ecryptfs_fasync,
.sendfile = ecryptfs_sendfile,
.splice_read = ecryptfs_splice_read,
};

static int
Expand Down
2 changes: 0 additions & 2 deletions fs/ext2/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ const struct file_operations ext2_file_operations = {
.open = generic_file_open,
.release = ext2_release_file,
.fsync = ext2_sync_file,
.sendfile = generic_file_sendfile,
.splice_read = generic_file_splice_read,
.splice_write = generic_file_splice_write,
};
Expand All @@ -71,7 +70,6 @@ const struct file_operations ext2_xip_file_operations = {
.open = generic_file_open,
.release = ext2_release_file,
.fsync = ext2_sync_file,
.sendfile = xip_file_sendfile,
};
#endif

Expand Down
1 change: 0 additions & 1 deletion fs/ext3/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ const struct file_operations ext3_file_operations = {
.open = generic_file_open,
.release = ext3_release_file,
.fsync = ext3_sync_file,
.sendfile = generic_file_sendfile,
.splice_read = generic_file_splice_read,
.splice_write = generic_file_splice_write,
};
Expand Down
1 change: 0 additions & 1 deletion fs/ext4/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ const struct file_operations ext4_file_operations = {
.open = generic_file_open,
.release = ext4_release_file,
.fsync = ext4_sync_file,
.sendfile = generic_file_sendfile,
.splice_read = generic_file_splice_read,
.splice_write = generic_file_splice_write,
};
Expand Down
2 changes: 1 addition & 1 deletion fs/fat/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const struct file_operations fat_file_operations = {
.release = fat_file_release,
.ioctl = fat_generic_ioctl,
.fsync = file_fsync,
.sendfile = generic_file_sendfile,
.splice_read = generic_file_splice_read,
};

static int fat_cont_expand(struct inode *inode, loff_t size)
Expand Down
4 changes: 2 additions & 2 deletions fs/fuse/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ static const struct file_operations fuse_file_operations = {
.release = fuse_release,
.fsync = fuse_fsync,
.lock = fuse_file_lock,
.sendfile = generic_file_sendfile,
.splice_read = generic_file_splice_read,
};

static const struct file_operations fuse_direct_io_file_operations = {
Expand All @@ -814,7 +814,7 @@ static const struct file_operations fuse_direct_io_file_operations = {
.release = fuse_release,
.fsync = fuse_fsync,
.lock = fuse_file_lock,
/* no mmap and sendfile */
/* no mmap and splice_read */
};

static const struct address_space_operations fuse_file_aops = {
Expand Down
1 change: 0 additions & 1 deletion fs/gfs2/ops_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,6 @@ const struct file_operations gfs2_file_fops = {
.release = gfs2_close,
.fsync = gfs2_fsync,
.lock = gfs2_lock,
.sendfile = generic_file_sendfile,
.flock = gfs2_flock,
.splice_read = generic_file_splice_read,
.splice_write = generic_file_splice_write,
Expand Down
2 changes: 1 addition & 1 deletion fs/hfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ static const struct file_operations hfs_file_operations = {
.write = do_sync_write,
.aio_write = generic_file_aio_write,
.mmap = generic_file_mmap,
.sendfile = generic_file_sendfile,
.splice_read = generic_file_splice_read,
.fsync = file_fsync,
.open = hfs_file_open,
.release = hfs_file_release,
Expand Down
Loading

0 comments on commit 01370f0

Please sign in to comment.