aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@primarydata.com>2015-03-25 16:38:33 -0400
committerTrond Myklebust <trond.myklebust@primarydata.com>2015-03-27 12:39:36 -0400
commit4d346bea8f0bf6d6351037899586a85435c15b9b (patch)
tree0f9013afeb766093dd8f1244e96259a5b844e05e /fs/nfs
parent67af7611ec57dbcbc96f9d9daa4d3c7b0999aa73 (diff)
NFS: Add a helper to sync both O_DIRECT and buffered writes
Then apply it to nfs_setattr() and nfs_getattr(). Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/inode.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index d42dff6d5e98..60f907666697 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -133,6 +133,12 @@ void nfs_evict_inode(struct inode *inode)
133 nfs_clear_inode(inode); 133 nfs_clear_inode(inode);
134} 134}
135 135
136static int nfs_sync_inode(struct inode *inode)
137{
138 nfs_inode_dio_wait(inode);
139 return nfs_wb_all(inode);
140}
141
136/** 142/**
137 * nfs_sync_mapping - helper to flush all mmapped dirty data to disk 143 * nfs_sync_mapping - helper to flush all mmapped dirty data to disk
138 */ 144 */
@@ -525,10 +531,8 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr)
525 trace_nfs_setattr_enter(inode); 531 trace_nfs_setattr_enter(inode);
526 532
527 /* Write all dirty data */ 533 /* Write all dirty data */
528 if (S_ISREG(inode->i_mode)) { 534 if (S_ISREG(inode->i_mode))
529 nfs_inode_dio_wait(inode); 535 nfs_sync_inode(inode);
530 nfs_wb_all(inode);
531 }
532 536
533 fattr = nfs_alloc_fattr(); 537 fattr = nfs_alloc_fattr();
534 if (fattr == NULL) 538 if (fattr == NULL)
@@ -644,8 +648,7 @@ int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
644 trace_nfs_getattr_enter(inode); 648 trace_nfs_getattr_enter(inode);
645 /* Flush out writes to the server in order to update c/mtime. */ 649 /* Flush out writes to the server in order to update c/mtime. */
646 if (S_ISREG(inode->i_mode)) { 650 if (S_ISREG(inode->i_mode)) {
647 nfs_inode_dio_wait(inode); 651 err = nfs_sync_inode(inode);
648 err = filemap_write_and_wait(inode->i_mapping);
649 if (err) 652 if (err)
650 goto out; 653 goto out;
651 } 654 }