diff options
Diffstat (limited to 'fs/nfs/inode.c')
-rw-r--r-- | fs/nfs/inode.c | 28 |
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 | */ | ||
646 | int 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); | ||
660 | out: | ||
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); |