aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/write.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2007-07-22 19:27:32 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2007-10-09 17:15:13 -0400
commitf758c885199611504ff681e3ba66c410b4e9e995 (patch)
tree8e68116aec5f0d99ce721d45f5ee299e52940284 /fs/nfs/write.c
parent9cccef95052c7169040c3577e17d4f6fa230cc28 (diff)
NFS: Clean up nfs_writepages()
Just call write_cache_pages directly instead of hacking the writeback control structure in order to find out if we were called from writepages() or directly from the VM. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/write.c')
-rw-r--r--fs/nfs/write.c57
1 files changed, 33 insertions, 24 deletions
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 0c346d79fb34..667ff27ef235 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -292,41 +292,51 @@ static int nfs_page_async_flush(struct nfs_pageio_descriptor *pgio,
292 return 0; 292 return 0;
293} 293}
294 294
295/* 295static int nfs_do_writepage(struct page *page, struct writeback_control *wbc, struct nfs_pageio_descriptor *pgio)
296 * Write an mmapped page to the server.
297 */
298static int nfs_writepage_locked(struct page *page, struct writeback_control *wbc)
299{ 296{
300 struct nfs_pageio_descriptor mypgio, *pgio;
301 struct inode *inode = page->mapping->host; 297 struct inode *inode = page->mapping->host;
302 int err;
303 298
304 nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGE); 299 nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGE);
305 nfs_add_stats(inode, NFSIOS_WRITEPAGES, 1); 300 nfs_add_stats(inode, NFSIOS_WRITEPAGES, 1);
306 301
307 if (wbc->for_writepages)
308 pgio = wbc->fs_private;
309 else {
310 nfs_pageio_init_write(&mypgio, inode, wb_priority(wbc));
311 pgio = &mypgio;
312 }
313
314 nfs_pageio_cond_complete(pgio, page->index); 302 nfs_pageio_cond_complete(pgio, page->index);
303 return nfs_page_async_flush(pgio, page);
304}
315 305
316 err = nfs_page_async_flush(pgio, page); 306/*
307 * Write an mmapped page to the server.
308 */
309static int nfs_writepage_locked(struct page *page, struct writeback_control *wbc)
310{
311 struct nfs_pageio_descriptor pgio;
312 int err;
317 313
318 if (!wbc->for_writepages) 314 nfs_pageio_init_write(&pgio, page->mapping->host, wb_priority(wbc));
319 nfs_pageio_complete(pgio); 315 err = nfs_do_writepage(page, wbc, &pgio);
320 return err; 316 nfs_pageio_complete(&pgio);
317 if (err < 0)
318 return err;
319 if (pgio.pg_error < 0)
320 return pgio.pg_error;
321 return 0;
321} 322}
322 323
323int nfs_writepage(struct page *page, struct writeback_control *wbc) 324int nfs_writepage(struct page *page, struct writeback_control *wbc)
324{ 325{
325 int err; 326 int ret;
326 327
327 err = nfs_writepage_locked(page, wbc); 328 ret = nfs_writepage_locked(page, wbc);
328 unlock_page(page); 329 unlock_page(page);
329 return err; 330 return ret;
331}
332
333static int nfs_writepages_callback(struct page *page, struct writeback_control *wbc, void *data)
334{
335 int ret;
336
337 ret = nfs_do_writepage(page, wbc, data);
338 unlock_page(page);
339 return ret;
330} 340}
331 341
332int nfs_writepages(struct address_space *mapping, struct writeback_control *wbc) 342int nfs_writepages(struct address_space *mapping, struct writeback_control *wbc)
@@ -338,12 +348,11 @@ int nfs_writepages(struct address_space *mapping, struct writeback_control *wbc)
338 nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGES); 348 nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGES);
339 349
340 nfs_pageio_init_write(&pgio, inode, wb_priority(wbc)); 350 nfs_pageio_init_write(&pgio, inode, wb_priority(wbc));
341 wbc->fs_private = &pgio; 351 err = write_cache_pages(mapping, wbc, nfs_writepages_callback, &pgio);
342 err = generic_writepages(mapping, wbc);
343 nfs_pageio_complete(&pgio); 352 nfs_pageio_complete(&pgio);
344 if (err) 353 if (err < 0)
345 return err; 354 return err;
346 if (pgio.pg_error) 355 if (pgio.pg_error < 0)
347 return pgio.pg_error; 356 return pgio.pg_error;
348 return 0; 357 return 0;
349} 358}