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.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index cec79392e4ba..0abf3f331f56 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -64,11 +64,7 @@ const struct file_operations nfs_file_operations = {
64 .write = do_sync_write, 64 .write = do_sync_write,
65 .aio_read = nfs_file_read, 65 .aio_read = nfs_file_read,
66 .aio_write = nfs_file_write, 66 .aio_write = nfs_file_write,
67#ifdef CONFIG_MMU
68 .mmap = nfs_file_mmap, 67 .mmap = nfs_file_mmap,
69#else
70 .mmap = generic_file_mmap,
71#endif
72 .open = nfs_file_open, 68 .open = nfs_file_open,
73 .flush = nfs_file_flush, 69 .flush = nfs_file_flush,
74 .release = nfs_file_release, 70 .release = nfs_file_release,
@@ -141,9 +137,6 @@ nfs_file_release(struct inode *inode, struct file *filp)
141 dentry->d_parent->d_name.name, 137 dentry->d_parent->d_name.name,
142 dentry->d_name.name); 138 dentry->d_name.name);
143 139
144 /* Ensure that dirty pages are flushed out with the right creds */
145 if (filp->f_mode & FMODE_WRITE)
146 nfs_wb_all(dentry->d_inode);
147 nfs_inc_stats(inode, NFSIOS_VFSRELEASE); 140 nfs_inc_stats(inode, NFSIOS_VFSRELEASE);
148 return nfs_release(inode, filp); 141 return nfs_release(inode, filp);
149} 142}
@@ -235,7 +228,6 @@ nfs_file_flush(struct file *file, fl_owner_t id)
235 struct nfs_open_context *ctx = nfs_file_open_context(file); 228 struct nfs_open_context *ctx = nfs_file_open_context(file);
236 struct dentry *dentry = file->f_path.dentry; 229 struct dentry *dentry = file->f_path.dentry;
237 struct inode *inode = dentry->d_inode; 230 struct inode *inode = dentry->d_inode;
238 int status;
239 231
240 dprintk("NFS: flush(%s/%s)\n", 232 dprintk("NFS: flush(%s/%s)\n",
241 dentry->d_parent->d_name.name, 233 dentry->d_parent->d_name.name,
@@ -245,11 +237,8 @@ nfs_file_flush(struct file *file, fl_owner_t id)
245 return 0; 237 return 0;
246 nfs_inc_stats(inode, NFSIOS_VFSFLUSH); 238 nfs_inc_stats(inode, NFSIOS_VFSFLUSH);
247 239
248 /* Ensure that data+attribute caches are up to date after close() */ 240 /* Flush writes to the server and return any errors */
249 status = nfs_do_fsync(ctx, inode); 241 return nfs_do_fsync(ctx, inode);
250 if (!status)
251 nfs_revalidate_inode(NFS_SERVER(inode), inode);
252 return status;
253} 242}
254 243
255static ssize_t 244static ssize_t
@@ -304,11 +293,13 @@ nfs_file_mmap(struct file * file, struct vm_area_struct * vma)
304 dprintk("NFS: mmap(%s/%s)\n", 293 dprintk("NFS: mmap(%s/%s)\n",
305 dentry->d_parent->d_name.name, dentry->d_name.name); 294 dentry->d_parent->d_name.name, dentry->d_name.name);
306 295
307 status = nfs_revalidate_mapping(inode, file->f_mapping); 296 /* Note: generic_file_mmap() returns ENOSYS on nommu systems
297 * so we call that before revalidating the mapping
298 */
299 status = generic_file_mmap(file, vma);
308 if (!status) { 300 if (!status) {
309 vma->vm_ops = &nfs_file_vm_ops; 301 vma->vm_ops = &nfs_file_vm_ops;
310 vma->vm_flags |= VM_CAN_NONLINEAR; 302 status = nfs_revalidate_mapping(inode, file->f_mapping);
311 file_accessed(file);
312 } 303 }
313 return status; 304 return status;
314} 305}
@@ -354,6 +345,15 @@ static int nfs_write_begin(struct file *file, struct address_space *mapping,
354 file->f_path.dentry->d_name.name, 345 file->f_path.dentry->d_name.name,
355 mapping->host->i_ino, len, (long long) pos); 346 mapping->host->i_ino, len, (long long) pos);
356 347
348 /*
349 * Prevent starvation issues if someone is doing a consistency
350 * sync-to-disk
351 */
352 ret = wait_on_bit(&NFS_I(mapping->host)->flags, NFS_INO_FLUSHING,
353 nfs_wait_bit_killable, TASK_KILLABLE);
354 if (ret)
355 return ret;
356
357 page = grab_cache_page_write_begin(mapping, index, flags); 357 page = grab_cache_page_write_begin(mapping, index, flags);
358 if (!page) 358 if (!page)
359 return -ENOMEM; 359 return -ENOMEM;