aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/inode.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2005-12-13 16:13:54 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2005-12-19 23:12:09 -0500
commit29884df0d89c1df0dec3449405bc41569bb44800 (patch)
treeb836dc3ece80a901d1b7a9e946bf0d51ec0c8c4f /fs/nfs/inode.c
parentb079fa7baa86b47579f3f60f86d03d21c76159b8 (diff)
NFS: Fix another O_DIRECT race
Ensure we call unmap_mapping_range() and sync dirty pages to disk before doing an NFS direct write. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/inode.c')
-rw-r--r--fs/nfs/inode.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index afd75d0463fd..432f41cd75e6 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -640,6 +640,27 @@ static int nfs_show_options(struct seq_file *m, struct vfsmount *mnt)
640 return 0; 640 return 0;
641} 641}
642 642
643/**
644 * nfs_sync_mapping - helper to flush all mmapped dirty data to disk
645 */
646int nfs_sync_mapping(struct address_space *mapping)
647{
648 int ret;
649
650 if (mapping->nrpages == 0)
651 return 0;
652 unmap_mapping_range(mapping, 0, 0, 0);
653 ret = filemap_fdatawrite(mapping);
654 if (ret != 0)
655 goto out;
656 ret = filemap_fdatawait(mapping);
657 if (ret != 0)
658 goto out;
659 ret = nfs_wb_all(mapping->host);
660out:
661 return ret;
662}
663
643/* 664/*
644 * Invalidate the local caches 665 * Invalidate the local caches
645 */ 666 */
@@ -1179,11 +1200,8 @@ void nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping)
1179 struct nfs_inode *nfsi = NFS_I(inode); 1200 struct nfs_inode *nfsi = NFS_I(inode);
1180 1201
1181 if (nfsi->cache_validity & NFS_INO_INVALID_DATA) { 1202 if (nfsi->cache_validity & NFS_INO_INVALID_DATA) {
1182 if (S_ISREG(inode->i_mode)) { 1203 if (S_ISREG(inode->i_mode))
1183 if (filemap_fdatawrite(mapping) == 0) 1204 nfs_sync_mapping(mapping);
1184 filemap_fdatawait(mapping);
1185 nfs_wb_all(inode);
1186 }
1187 invalidate_inode_pages2(mapping); 1205 invalidate_inode_pages2(mapping);
1188 1206
1189 spin_lock(&inode->i_lock); 1207 spin_lock(&inode->i_lock);