Commit 731cf67c authored by Andrew Morton's avatar Andrew Morton Committed by James Bottomley

[PATCH] Implement sendfile() for NFS

Patch from Trond Myklebust <trond.myklebust@fys.uio.no>

Implement sendfile() for the NFS client.  This is required for loop-on-NFS
support.
parent 96552156
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#define NFSDBG_FACILITY NFSDBG_FILE #define NFSDBG_FACILITY NFSDBG_FILE
static int nfs_file_mmap(struct file *, struct vm_area_struct *); static int nfs_file_mmap(struct file *, struct vm_area_struct *);
static ssize_t nfs_file_sendfile(struct file *, loff_t *, size_t, read_actor_t, void *);
static ssize_t nfs_file_read(struct kiocb *, char *, size_t, loff_t); static ssize_t nfs_file_read(struct kiocb *, char *, size_t, loff_t);
static ssize_t nfs_file_write(struct kiocb *, const char *, size_t, loff_t); static ssize_t nfs_file_write(struct kiocb *, const char *, size_t, loff_t);
static int nfs_file_flush(struct file *); static int nfs_file_flush(struct file *);
...@@ -52,6 +53,7 @@ struct file_operations nfs_file_operations = { ...@@ -52,6 +53,7 @@ struct file_operations nfs_file_operations = {
.release = nfs_release, .release = nfs_release,
.fsync = nfs_fsync, .fsync = nfs_fsync,
.lock = nfs_lock, .lock = nfs_lock,
.sendfile = nfs_file_sendfile,
}; };
struct inode_operations nfs_file_inode_operations = { struct inode_operations nfs_file_inode_operations = {
...@@ -102,6 +104,24 @@ nfs_file_read(struct kiocb *iocb, char * buf, size_t count, loff_t pos) ...@@ -102,6 +104,24 @@ nfs_file_read(struct kiocb *iocb, char * buf, size_t count, loff_t pos)
return result; return result;
} }
static ssize_t
nfs_file_sendfile(struct file *filp, loff_t *ppos, size_t count,
read_actor_t actor, void *target)
{
struct dentry *dentry = filp->f_dentry;
struct inode *inode = dentry->d_inode;
ssize_t res;
dfprintk(VFS, "nfs: sendfile(%s/%s, %lu@%Lu)\n",
dentry->d_parent->d_name.name, dentry->d_name.name,
(unsigned long) count, (unsigned long long) *ppos);
res = nfs_revalidate_inode(NFS_SERVER(inode), inode);
if (!res)
res = generic_file_sendfile(filp, ppos, count, actor, target);
return res;
}
static int static int
nfs_file_mmap(struct file * file, struct vm_area_struct * vma) nfs_file_mmap(struct file * file, struct vm_area_struct * vma)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment