Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 58519
b: refs/heads/master
c: 534f2aa
h: refs/heads/master
i:
  58517: 4b8ecc6
  58515: b897f31
  58511: b5fee78
v: v3
  • Loading branch information
Jens Axboe committed Jul 10, 2007
1 parent da15133 commit 31f2184
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6a14b90bb6bc7cd83e2a444bf457a2ea645cbfe7
refs/heads/master: 534f2aaa6ab07cd71164180bc958a7dcde41db11
24 changes: 20 additions & 4 deletions trunk/fs/read_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <linux/module.h>
#include <linux/syscalls.h>
#include <linux/pagemap.h>
#include <linux/pipe_fs_i.h>
#include "read_write.h"

#include <asm/uaccess.h>
Expand All @@ -25,7 +26,7 @@ const struct file_operations generic_ro_fops = {
.read = do_sync_read,
.aio_read = generic_file_aio_read,
.mmap = generic_file_readonly_mmap,
.sendfile = generic_file_sendfile,
.splice_read = generic_file_splice_read,
};

EXPORT_SYMBOL(generic_ro_fops);
Expand Down Expand Up @@ -708,7 +709,7 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos,
struct inode * in_inode, * out_inode;
loff_t pos;
ssize_t retval;
int fput_needed_in, fput_needed_out;
int fput_needed_in, fput_needed_out, fl;

/*
* Get input file, and verify that it is ok..
Expand All @@ -723,7 +724,8 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos,
in_inode = in_file->f_path.dentry->d_inode;
if (!in_inode)
goto fput_in;
if (!in_file->f_op || !in_file->f_op->sendfile)
if (!in_file->f_op || (!in_file->f_op->sendfile &&
!in_file->f_op->splice_read))
goto fput_in;
retval = -ESPIPE;
if (!ppos)
Expand Down Expand Up @@ -776,7 +778,21 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos,
count = max - pos;
}

retval = in_file->f_op->sendfile(in_file, ppos, count, file_send_actor, out_file);
if (in_file->f_op->splice_read) {
fl = 0;
#if 0
/*
* We need to debate whether we can enable this or not. The
* man page documents EAGAIN return for the output at least,
* and the application is arguably buggy if it doesn't expect
* EAGAIN on a non-blocking file descriptor.
*/
if (in_file->f_flags & O_NONBLOCK)
fl = SPLICE_F_NONBLOCK;
#endif
retval = do_splice_direct(in_file, ppos, out_file, count, fl);
} else
retval = in_file->f_op->sendfile(in_file, ppos, count, file_send_actor, out_file);

if (retval > 0) {
add_rchar(current, retval);
Expand Down

0 comments on commit 31f2184

Please sign in to comment.