aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfs/file.c')
-rw-r--r--fs/nfs/file.c110
1 files changed, 56 insertions, 54 deletions
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 28b8c3f3cda3..eca56d4b39c0 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -40,48 +40,8 @@
40 40
41#define NFSDBG_FACILITY NFSDBG_FILE 41#define NFSDBG_FACILITY NFSDBG_FILE
42 42
43static int nfs_file_open(struct inode *, struct file *);
44static int nfs_file_release(struct inode *, struct file *);
45static loff_t nfs_file_llseek(struct file *file, loff_t offset, int origin);
46static int nfs_file_mmap(struct file *, struct vm_area_struct *);
47static ssize_t nfs_file_splice_read(struct file *filp, loff_t *ppos,
48 struct pipe_inode_info *pipe,
49 size_t count, unsigned int flags);
50static ssize_t nfs_file_read(struct kiocb *, const struct iovec *iov,
51 unsigned long nr_segs, loff_t pos);
52static ssize_t nfs_file_splice_write(struct pipe_inode_info *pipe,
53 struct file *filp, loff_t *ppos,
54 size_t count, unsigned int flags);
55static ssize_t nfs_file_write(struct kiocb *, const struct iovec *iov,
56 unsigned long nr_segs, loff_t pos);
57static int nfs_file_flush(struct file *, fl_owner_t id);
58static int nfs_file_fsync(struct file *, loff_t, loff_t, int datasync);
59static int nfs_check_flags(int flags);
60static int nfs_lock(struct file *filp, int cmd, struct file_lock *fl);
61static int nfs_flock(struct file *filp, int cmd, struct file_lock *fl);
62static int nfs_setlease(struct file *file, long arg, struct file_lock **fl);
63
64static const struct vm_operations_struct nfs_file_vm_ops; 43static const struct vm_operations_struct nfs_file_vm_ops;
65 44
66const struct file_operations nfs_file_operations = {
67 .llseek = nfs_file_llseek,
68 .read = do_sync_read,
69 .write = do_sync_write,
70 .aio_read = nfs_file_read,
71 .aio_write = nfs_file_write,
72 .mmap = nfs_file_mmap,
73 .open = nfs_file_open,
74 .flush = nfs_file_flush,
75 .release = nfs_file_release,
76 .fsync = nfs_file_fsync,
77 .lock = nfs_lock,
78 .flock = nfs_flock,
79 .splice_read = nfs_file_splice_read,
80 .splice_write = nfs_file_splice_write,
81 .check_flags = nfs_check_flags,
82 .setlease = nfs_setlease,
83};
84
85const struct inode_operations nfs_file_inode_operations = { 45const struct inode_operations nfs_file_inode_operations = {
86 .permission = nfs_permission, 46 .permission = nfs_permission,
87 .getattr = nfs_getattr, 47 .getattr = nfs_getattr,
@@ -137,11 +97,9 @@ nfs_file_open(struct inode *inode, struct file *filp)
137static int 97static int
138nfs_file_release(struct inode *inode, struct file *filp) 98nfs_file_release(struct inode *inode, struct file *filp)
139{ 99{
140 struct dentry *dentry = filp->f_path.dentry;
141
142 dprintk("NFS: release(%s/%s)\n", 100 dprintk("NFS: release(%s/%s)\n",
143 dentry->d_parent->d_name.name, 101 filp->f_path.dentry->d_parent->d_name.name,
144 dentry->d_name.name); 102 filp->f_path.dentry->d_name.name);
145 103
146 nfs_inc_stats(inode, NFSIOS_VFSRELEASE); 104 nfs_inc_stats(inode, NFSIOS_VFSRELEASE);
147 return nfs_release(inode, filp); 105 return nfs_release(inode, filp);
@@ -180,8 +138,6 @@ force_reval:
180 138
181static loff_t nfs_file_llseek(struct file *filp, loff_t offset, int origin) 139static loff_t nfs_file_llseek(struct file *filp, loff_t offset, int origin)
182{ 140{
183 loff_t loff;
184
185 dprintk("NFS: llseek file(%s/%s, %lld, %d)\n", 141 dprintk("NFS: llseek file(%s/%s, %lld, %d)\n",
186 filp->f_path.dentry->d_parent->d_name.name, 142 filp->f_path.dentry->d_parent->d_name.name,
187 filp->f_path.dentry->d_name.name, 143 filp->f_path.dentry->d_name.name,
@@ -197,13 +153,9 @@ static loff_t nfs_file_llseek(struct file *filp, loff_t offset, int origin)
197 int retval = nfs_revalidate_file_size(inode, filp); 153 int retval = nfs_revalidate_file_size(inode, filp);
198 if (retval < 0) 154 if (retval < 0)
199 return (loff_t)retval; 155 return (loff_t)retval;
156 }
200 157
201 spin_lock(&inode->i_lock); 158 return generic_file_llseek(filp, offset, origin);
202 loff = generic_file_llseek_unlocked(filp, offset, origin);
203 spin_unlock(&inode->i_lock);
204 } else
205 loff = generic_file_llseek_unlocked(filp, offset, origin);
206 return loff;
207} 159}
208 160
209/* 161/*
@@ -234,14 +186,13 @@ nfs_file_read(struct kiocb *iocb, const struct iovec *iov,
234 struct dentry * dentry = iocb->ki_filp->f_path.dentry; 186 struct dentry * dentry = iocb->ki_filp->f_path.dentry;
235 struct inode * inode = dentry->d_inode; 187 struct inode * inode = dentry->d_inode;
236 ssize_t result; 188 ssize_t result;
237 size_t count = iov_length(iov, nr_segs);
238 189
239 if (iocb->ki_filp->f_flags & O_DIRECT) 190 if (iocb->ki_filp->f_flags & O_DIRECT)
240 return nfs_file_direct_read(iocb, iov, nr_segs, pos); 191 return nfs_file_direct_read(iocb, iov, nr_segs, pos);
241 192
242 dprintk("NFS: read(%s/%s, %lu@%lu)\n", 193 dprintk("NFS: read(%s/%s, %lu@%lu)\n",
243 dentry->d_parent->d_name.name, dentry->d_name.name, 194 dentry->d_parent->d_name.name, dentry->d_name.name,
244 (unsigned long) count, (unsigned long) pos); 195 (unsigned long) iov_length(iov, nr_segs), (unsigned long) pos);
245 196
246 result = nfs_revalidate_mapping(inode, iocb->ki_filp->f_mapping); 197 result = nfs_revalidate_mapping(inode, iocb->ki_filp->f_mapping);
247 if (!result) { 198 if (!result) {
@@ -895,3 +846,54 @@ static int nfs_setlease(struct file *file, long arg, struct file_lock **fl)
895 file->f_path.dentry->d_name.name, arg); 846 file->f_path.dentry->d_name.name, arg);
896 return -EINVAL; 847 return -EINVAL;
897} 848}
849
850const struct file_operations nfs_file_operations = {
851 .llseek = nfs_file_llseek,
852 .read = do_sync_read,
853 .write = do_sync_write,
854 .aio_read = nfs_file_read,
855 .aio_write = nfs_file_write,
856 .mmap = nfs_file_mmap,
857 .open = nfs_file_open,
858 .flush = nfs_file_flush,
859 .release = nfs_file_release,
860 .fsync = nfs_file_fsync,
861 .lock = nfs_lock,
862 .flock = nfs_flock,
863 .splice_read = nfs_file_splice_read,
864 .splice_write = nfs_file_splice_write,
865 .check_flags = nfs_check_flags,
866 .setlease = nfs_setlease,
867};
868
869#ifdef CONFIG_NFS_V4
870static int
871nfs4_file_open(struct inode *inode, struct file *filp)
872{
873 /*
874 * NFSv4 opens are handled in d_lookup and d_revalidate. If we get to
875 * this point, then something is very wrong
876 */
877 dprintk("NFS: %s called! inode=%p filp=%p\n", __func__, inode, filp);
878 return -ENOTDIR;
879}
880
881const struct file_operations nfs4_file_operations = {
882 .llseek = nfs_file_llseek,
883 .read = do_sync_read,
884 .write = do_sync_write,
885 .aio_read = nfs_file_read,
886 .aio_write = nfs_file_write,
887 .mmap = nfs_file_mmap,
888 .open = nfs4_file_open,
889 .flush = nfs_file_flush,
890 .release = nfs_file_release,
891 .fsync = nfs_file_fsync,
892 .lock = nfs_lock,
893 .flock = nfs_flock,
894 .splice_read = nfs_file_splice_read,
895 .splice_write = nfs_file_splice_write,
896 .check_flags = nfs_check_flags,
897 .setlease = nfs_setlease,
898};
899#endif /* CONFIG_NFS_V4 */