diff options
| author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-02-19 20:00:02 -0500 |
|---|---|---|
| committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-03-05 15:44:54 -0500 |
| commit | 420e3646bb7d93a571734034249fbb1ae1a7a5c7 (patch) | |
| tree | dc3328f6df5769e275253c23d862cb0a16ab50f1 | |
| parent | ff778d02bf867e1733a09b34ad6dbb723b024814 (diff) | |
NFS: Reduce the number of unnecessary COMMIT calls
If the caller is doing a non-blocking flush, and there are still writebacks
pending on the wire, we can usually defer the COMMIT call until those
writes are done.
Also ensure that we honour the wbc->nonblocking flag.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
| -rw-r--r-- | fs/nfs/write.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/fs/nfs/write.c b/fs/nfs/write.c index dc08a6fbde67..fc05e35da6a9 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c | |||
| @@ -1415,12 +1415,30 @@ static int nfs_commit_inode(struct inode *inode, int how) | |||
| 1415 | 1415 | ||
| 1416 | static int nfs_commit_unstable_pages(struct inode *inode, struct writeback_control *wbc) | 1416 | static int nfs_commit_unstable_pages(struct inode *inode, struct writeback_control *wbc) |
| 1417 | { | 1417 | { |
| 1418 | int ret; | 1418 | struct nfs_inode *nfsi = NFS_I(inode); |
| 1419 | int flags = FLUSH_SYNC; | ||
| 1420 | int ret = 0; | ||
| 1419 | 1421 | ||
| 1420 | ret = nfs_commit_inode(inode, | 1422 | /* Don't commit yet if this is a non-blocking flush and there are |
| 1421 | wbc->sync_mode == WB_SYNC_ALL ? FLUSH_SYNC : 0); | 1423 | * lots of outstanding writes for this mapping. |
| 1422 | if (ret >= 0) | 1424 | */ |
| 1425 | if (wbc->sync_mode == WB_SYNC_NONE && | ||
| 1426 | nfsi->ncommit <= (nfsi->npages >> 1)) | ||
| 1427 | goto out_mark_dirty; | ||
| 1428 | |||
| 1429 | if (wbc->nonblocking) | ||
| 1430 | flags = 0; | ||
| 1431 | ret = nfs_commit_inode(inode, flags); | ||
| 1432 | if (ret >= 0) { | ||
| 1433 | if (wbc->sync_mode == WB_SYNC_NONE) { | ||
| 1434 | if (ret < wbc->nr_to_write) | ||
| 1435 | wbc->nr_to_write -= ret; | ||
| 1436 | else | ||
| 1437 | wbc->nr_to_write = 0; | ||
| 1438 | } | ||
| 1423 | return 0; | 1439 | return 0; |
| 1440 | } | ||
| 1441 | out_mark_dirty: | ||
| 1424 | __mark_inode_dirty(inode, I_DIRTY_DATASYNC); | 1442 | __mark_inode_dirty(inode, I_DIRTY_DATASYNC); |
| 1425 | return ret; | 1443 | return ret; |
| 1426 | } | 1444 | } |
