Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 01370f06 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'splice-2.6.23' of git://git.kernel.dk/data/git/linux-2.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
parents 5cbc39a7 0845718d
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -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>
+44 −20
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@
#include <linux/highmem.h>
#include <linux/gfp.h>
#include <linux/kthread.h>
#include <linux/splice.h>

#include <asm/uaccess.h>

@@ -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;
	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
@@ -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 */
@@ -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;
+1 −1
Original line number Diff line number Diff line
@@ -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>
+1 −1
Original line number Diff line number Diff line
@@ -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 = {
+1 −1
Original line number Diff line number Diff line
@@ -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 = {
Loading