aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2007-07-20 13:13:28 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2007-10-09 17:15:18 -0400
commited90ef51a33f572fa7d00c8b05f7457be727e74f (patch)
tree4c41336dd045cd9a857454a5d8a595288d64d6e1
parent90e9a3f9b0a14198a8ae5a0a5c13ad30f0b8b40d (diff)
NFS: Clean up NFS writeback flush code
The only user of nfs_sync_mapping_range() is nfs_getattr(), which uses it to flush out the entire inode without sending a commit. We therefore replace nfs_sync_mapping_range with a more appropriate helper. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r--fs/nfs/inode.c2
-rw-r--r--fs/nfs/write.c41
-rw-r--r--include/linux/nfs_fs.h2
3 files changed, 16 insertions, 29 deletions
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 71a49c3acabd..119fefef13f3 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -431,7 +431,7 @@ int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
431 431
432 /* Flush out writes to the server in order to update c/mtime */ 432 /* Flush out writes to the server in order to update c/mtime */
433 if (S_ISREG(inode->i_mode)) 433 if (S_ISREG(inode->i_mode))
434 nfs_sync_mapping_range(inode->i_mapping, 0, 0, FLUSH_NOCOMMIT); 434 nfs_wb_nocommit(inode);
435 435
436 /* 436 /*
437 * We may force a getattr if the user cares about atime. 437 * We may force a getattr if the user cares about atime.
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 667ff27ef235..75adb8e78db9 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -1325,12 +1325,8 @@ long nfs_sync_mapping_wait(struct address_space *mapping, struct writeback_contr
1325 return ret; 1325 return ret;
1326} 1326}
1327 1327
1328/* 1328static int nfs_write_mapping(struct address_space *mapping, int how)
1329 * flush the inode to disk.
1330 */
1331int nfs_wb_all(struct inode *inode)
1332{ 1329{
1333 struct address_space *mapping = inode->i_mapping;
1334 struct writeback_control wbc = { 1330 struct writeback_control wbc = {
1335 .bdi = mapping->backing_dev_info, 1331 .bdi = mapping->backing_dev_info,
1336 .sync_mode = WB_SYNC_ALL, 1332 .sync_mode = WB_SYNC_ALL,
@@ -1343,35 +1339,26 @@ int nfs_wb_all(struct inode *inode)
1343 ret = nfs_writepages(mapping, &wbc); 1339 ret = nfs_writepages(mapping, &wbc);
1344 if (ret < 0) 1340 if (ret < 0)
1345 goto out; 1341 goto out;
1346 ret = nfs_sync_mapping_wait(mapping, &wbc, 0); 1342 ret = nfs_sync_mapping_wait(mapping, &wbc, how);
1347 if (ret >= 0) 1343 if (ret < 0)
1348 return 0; 1344 goto out;
1345 return 0;
1349out: 1346out:
1350 __mark_inode_dirty(mapping->host, I_DIRTY_PAGES); 1347 __mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
1351 return ret; 1348 return ret;
1352} 1349}
1353 1350
1354int nfs_sync_mapping_range(struct address_space *mapping, loff_t range_start, loff_t range_end, int how) 1351/*
1352 * flush the inode to disk.
1353 */
1354int nfs_wb_all(struct inode *inode)
1355{ 1355{
1356 struct writeback_control wbc = { 1356 return nfs_write_mapping(inode->i_mapping, 0);
1357 .bdi = mapping->backing_dev_info, 1357}
1358 .sync_mode = WB_SYNC_ALL,
1359 .nr_to_write = LONG_MAX,
1360 .range_start = range_start,
1361 .range_end = range_end,
1362 .for_writepages = 1,
1363 };
1364 int ret;
1365 1358
1366 ret = nfs_writepages(mapping, &wbc); 1359int nfs_wb_nocommit(struct inode *inode)
1367 if (ret < 0) 1360{
1368 goto out; 1361 return nfs_write_mapping(inode->i_mapping, FLUSH_NOCOMMIT);
1369 ret = nfs_sync_mapping_wait(mapping, &wbc, how);
1370 if (ret >= 0)
1371 return 0;
1372out:
1373 __mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
1374 return ret;
1375} 1362}
1376 1363
1377int nfs_wb_page_cancel(struct inode *inode, struct page *page) 1364int nfs_wb_page_cancel(struct inode *inode, struct page *page)
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index 32bd5d38cdfd..15eec27cb60b 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -426,8 +426,8 @@ extern void nfs_writedata_release(void *);
426 * return value!) 426 * return value!)
427 */ 427 */
428extern long nfs_sync_mapping_wait(struct address_space *, struct writeback_control *, int); 428extern long nfs_sync_mapping_wait(struct address_space *, struct writeback_control *, int);
429extern int nfs_sync_mapping_range(struct address_space *, loff_t, loff_t, int);
430extern int nfs_wb_all(struct inode *inode); 429extern int nfs_wb_all(struct inode *inode);
430extern int nfs_wb_nocommit(struct inode *inode);
431extern int nfs_wb_page(struct inode *inode, struct page* page); 431extern int nfs_wb_page(struct inode *inode, struct page* page);
432extern int nfs_wb_page_priority(struct inode *inode, struct page* page, int how); 432extern int nfs_wb_page_priority(struct inode *inode, struct page* page, int how);
433extern int nfs_wb_page_cancel(struct inode *inode, struct page* page); 433extern int nfs_wb_page_cancel(struct inode *inode, struct page* page);