aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/write.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2006-09-17 14:46:44 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2006-12-06 10:46:35 -0500
commit3f442547b76bf9fb70d7aecc41cf1980459253c9 (patch)
treeaab3982d110b01e028ce477cb02873ddf1abad36 /fs/nfs/write.c
parent28c6925fce3927a9fe3c5b44af5fb266680fdcea (diff)
NFS: Clean up nfs_scan_dirty()
Pass down struct writeback control. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/write.c')
-rw-r--r--fs/nfs/write.c54
1 files changed, 16 insertions, 38 deletions
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 1d72096c4d22..dbc89fa7e9d5 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -79,7 +79,7 @@ static struct nfs_page * nfs_update_request(struct nfs_open_context*,
79 unsigned int, unsigned int); 79 unsigned int, unsigned int);
80static int nfs_wait_on_write_congestion(struct address_space *, int); 80static int nfs_wait_on_write_congestion(struct address_space *, int);
81static int nfs_wait_on_requests(struct inode *, unsigned long, unsigned int); 81static int nfs_wait_on_requests(struct inode *, unsigned long, unsigned int);
82static int nfs_flush_mapping(struct address_space *mapping, struct writeback_control *wbc, int how); 82static long nfs_flush_mapping(struct address_space *mapping, struct writeback_control *wbc, int how);
83static const struct rpc_call_ops nfs_write_partial_ops; 83static const struct rpc_call_ops nfs_write_partial_ops;
84static const struct rpc_call_ops nfs_write_full_ops; 84static const struct rpc_call_ops nfs_write_full_ops;
85static const struct rpc_call_ops nfs_commit_ops; 85static const struct rpc_call_ops nfs_commit_ops;
@@ -400,10 +400,8 @@ int nfs_writepages(struct address_space *mapping, struct writeback_control *wbc)
400 goto out; 400 goto out;
401 } 401 }
402 err = nfs_commit_inode(inode, wb_priority(wbc)); 402 err = nfs_commit_inode(inode, wb_priority(wbc));
403 if (err > 0) { 403 if (err > 0)
404 wbc->nr_to_write -= err;
405 err = 0; 404 err = 0;
406 }
407out: 405out:
408 clear_bit(BDI_write_congested, &bdi->state); 406 clear_bit(BDI_write_congested, &bdi->state);
409 wake_up_all(&nfs_write_congestion); 407 wake_up_all(&nfs_write_congestion);
@@ -607,31 +605,6 @@ static void nfs_cancel_commit_list(struct list_head *head)
607 } 605 }
608} 606}
609 607
610/*
611 * nfs_scan_dirty - Scan an inode for dirty requests
612 * @inode: NFS inode to scan
613 * @dst: destination list
614 * @idx_start: lower bound of page->index to scan.
615 * @npages: idx_start + npages sets the upper bound to scan.
616 *
617 * Moves requests from the inode's dirty page list.
618 * The requests are *not* checked to ensure that they form a contiguous set.
619 */
620static int
621nfs_scan_dirty(struct inode *inode, struct list_head *dst, unsigned long idx_start, unsigned int npages)
622{
623 struct nfs_inode *nfsi = NFS_I(inode);
624 int res = 0;
625
626 if (nfsi->ndirty != 0) {
627 res = nfs_scan_lock_dirty(nfsi, dst, idx_start, npages);
628 nfsi->ndirty -= res;
629 if ((nfsi->ndirty == 0) != list_empty(&nfsi->dirty))
630 printk(KERN_ERR "NFS: desynchronized value of nfs_i.ndirty.\n");
631 }
632 return res;
633}
634
635#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4) 608#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
636/* 609/*
637 * nfs_scan_commit - Scan an inode for commit requests 610 * nfs_scan_commit - Scan an inode for commit requests
@@ -1467,22 +1440,19 @@ static inline int nfs_commit_list(struct inode *inode, struct list_head *head, i
1467} 1440}
1468#endif 1441#endif
1469 1442
1470static int nfs_flush_mapping(struct address_space *mapping, struct writeback_control *wbc, int how) 1443static long nfs_flush_mapping(struct address_space *mapping, struct writeback_control *wbc, int how)
1471{ 1444{
1472 struct nfs_inode *nfsi = NFS_I(mapping->host); 1445 struct nfs_inode *nfsi = NFS_I(mapping->host);
1473 LIST_HEAD(head); 1446 LIST_HEAD(head);
1474 pgoff_t index = wbc->range_start >> PAGE_CACHE_SHIFT; 1447 long res;
1475 unsigned long npages = 1 + (wbc->range_end >> PAGE_CACHE_SHIFT) - index;
1476 int res;
1477 1448
1478 spin_lock(&nfsi->req_lock); 1449 spin_lock(&nfsi->req_lock);
1479 res = nfs_scan_dirty(mapping->host, &head, index, npages); 1450 res = nfs_scan_dirty(mapping, wbc, &head);
1480 spin_unlock(&nfsi->req_lock); 1451 spin_unlock(&nfsi->req_lock);
1481 if (res) { 1452 if (res) {
1482 int error = nfs_flush_list(mapping->host, &head, res, how); 1453 int error = nfs_flush_list(mapping->host, &head, res, how);
1483 if (error < 0) 1454 if (error < 0)
1484 return error; 1455 return error;
1485 wbc->nr_to_write -= res;
1486 } 1456 }
1487 return res; 1457 return res;
1488} 1458}
@@ -1506,13 +1476,21 @@ int nfs_commit_inode(struct inode *inode, int how)
1506} 1476}
1507#endif 1477#endif
1508 1478
1509int nfs_sync_inode_wait(struct inode *inode, unsigned long idx_start, 1479long nfs_sync_inode_wait(struct inode *inode, unsigned long idx_start,
1510 unsigned int npages, int how) 1480 unsigned int npages, int how)
1511{ 1481{
1512 struct nfs_inode *nfsi = NFS_I(inode); 1482 struct nfs_inode *nfsi = NFS_I(inode);
1483 struct address_space *mapping = inode->i_mapping;
1484 struct writeback_control wbc = {
1485 .bdi = mapping->backing_dev_info,
1486 .sync_mode = WB_SYNC_ALL,
1487 .nr_to_write = LONG_MAX,
1488 .range_start = ((loff_t)idx_start) << PAGE_CACHE_SHIFT,
1489 .range_end = ((loff_t)(idx_start + npages - 1)) << PAGE_CACHE_SHIFT,
1490 };
1513 LIST_HEAD(head); 1491 LIST_HEAD(head);
1514 int nocommit = how & FLUSH_NOCOMMIT; 1492 int nocommit = how & FLUSH_NOCOMMIT;
1515 int pages, ret; 1493 long pages, ret;
1516 1494
1517 how &= ~FLUSH_NOCOMMIT; 1495 how &= ~FLUSH_NOCOMMIT;
1518 spin_lock(&nfsi->req_lock); 1496 spin_lock(&nfsi->req_lock);
@@ -1520,7 +1498,7 @@ int nfs_sync_inode_wait(struct inode *inode, unsigned long idx_start,
1520 ret = nfs_wait_on_requests_locked(inode, idx_start, npages); 1498 ret = nfs_wait_on_requests_locked(inode, idx_start, npages);
1521 if (ret != 0) 1499 if (ret != 0)
1522 continue; 1500 continue;
1523 pages = nfs_scan_dirty(inode, &head, idx_start, npages); 1501 pages = nfs_scan_dirty(mapping, &wbc, &head);
1524 if (pages != 0) { 1502 if (pages != 0) {
1525 spin_unlock(&nfsi->req_lock); 1503 spin_unlock(&nfsi->req_lock);
1526 if (how & FLUSH_INVALIDATE) { 1504 if (how & FLUSH_INVALIDATE) {