diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-12-05 00:35:41 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-12-06 10:46:39 -0500 |
commit | 4d770ccf4257b23a7ca2a85de1b1c22657b581d8 (patch) | |
tree | 6d4002f6a9497e3eb3dd5dee6b27e9c5dc28e46e /fs/nfs | |
parent | 1a54533ec8d92a5edae97ec6ae10023ee71c4b46 (diff) |
NFS: Ensure that nfs_wb_page() calls writepage when necessary.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r-- | fs/nfs/write.c | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 266fea71cfc0..0eca6a542106 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c | |||
@@ -247,7 +247,7 @@ static int wb_priority(struct writeback_control *wbc) | |||
247 | /* | 247 | /* |
248 | * Write an mmapped page to the server. | 248 | * Write an mmapped page to the server. |
249 | */ | 249 | */ |
250 | int nfs_writepage(struct page *page, struct writeback_control *wbc) | 250 | static int nfs_writepage_locked(struct page *page, struct writeback_control *wbc) |
251 | { | 251 | { |
252 | struct nfs_open_context *ctx; | 252 | struct nfs_open_context *ctx; |
253 | struct inode *inode = page->mapping->host; | 253 | struct inode *inode = page->mapping->host; |
@@ -265,7 +265,7 @@ int nfs_writepage(struct page *page, struct writeback_control *wbc) | |||
265 | if (!flushme) | 265 | if (!flushme) |
266 | goto out; | 266 | goto out; |
267 | /* Ensure we've flushed out the invalid write */ | 267 | /* Ensure we've flushed out the invalid write */ |
268 | nfs_wb_page_priority(inode, page, wb_priority(wbc)); | 268 | nfs_wb_page_priority(inode, page, wb_priority(wbc) | FLUSH_STABLE | FLUSH_NOWRITEPAGE); |
269 | } | 269 | } |
270 | 270 | ||
271 | offset = nfs_page_length(page); | 271 | offset = nfs_page_length(page); |
@@ -283,6 +283,14 @@ int nfs_writepage(struct page *page, struct writeback_control *wbc) | |||
283 | out: | 283 | out: |
284 | if (!wbc->for_writepages) | 284 | if (!wbc->for_writepages) |
285 | nfs_flush_mapping(page->mapping, wbc, wb_priority(wbc)); | 285 | nfs_flush_mapping(page->mapping, wbc, wb_priority(wbc)); |
286 | return err; | ||
287 | } | ||
288 | |||
289 | int nfs_writepage(struct page *page, struct writeback_control *wbc) | ||
290 | { | ||
291 | int err; | ||
292 | |||
293 | err = nfs_writepage_locked(page, wbc); | ||
286 | unlock_page(page); | 294 | unlock_page(page); |
287 | return err; | 295 | return err; |
288 | } | 296 | } |
@@ -1435,8 +1443,26 @@ static int nfs_wb_page_priority(struct inode *inode, struct page *page, int how) | |||
1435 | { | 1443 | { |
1436 | loff_t range_start = page_offset(page); | 1444 | loff_t range_start = page_offset(page); |
1437 | loff_t range_end = range_start + (loff_t)(PAGE_CACHE_SIZE - 1); | 1445 | loff_t range_end = range_start + (loff_t)(PAGE_CACHE_SIZE - 1); |
1446 | struct writeback_control wbc = { | ||
1447 | .bdi = page->mapping->backing_dev_info, | ||
1448 | .sync_mode = WB_SYNC_ALL, | ||
1449 | .nr_to_write = LONG_MAX, | ||
1450 | .range_start = range_start, | ||
1451 | .range_end = range_end, | ||
1452 | }; | ||
1453 | int ret; | ||
1438 | 1454 | ||
1439 | return nfs_sync_mapping_range(inode->i_mapping, range_start, range_end, how | FLUSH_STABLE); | 1455 | BUG_ON(!PageLocked(page)); |
1456 | if (!(how & FLUSH_NOWRITEPAGE) && clear_page_dirty_for_io(page)) { | ||
1457 | ret = nfs_writepage_locked(page, &wbc); | ||
1458 | if (ret < 0) | ||
1459 | goto out; | ||
1460 | } | ||
1461 | ret = nfs_sync_mapping_wait(page->mapping, &wbc, how); | ||
1462 | if (ret >= 0) | ||
1463 | return 0; | ||
1464 | out: | ||
1465 | return ret; | ||
1440 | } | 1466 | } |
1441 | 1467 | ||
1442 | /* | 1468 | /* |
@@ -1444,7 +1470,7 @@ static int nfs_wb_page_priority(struct inode *inode, struct page *page, int how) | |||
1444 | */ | 1470 | */ |
1445 | int nfs_wb_page(struct inode *inode, struct page* page) | 1471 | int nfs_wb_page(struct inode *inode, struct page* page) |
1446 | { | 1472 | { |
1447 | return nfs_wb_page_priority(inode, page, 0); | 1473 | return nfs_wb_page_priority(inode, page, FLUSH_STABLE); |
1448 | } | 1474 | } |
1449 | 1475 | ||
1450 | int nfs_set_page_dirty(struct page *page) | 1476 | int nfs_set_page_dirty(struct page *page) |