Currently, when calling nfs_commit_file(), we check the range argument,
and only commit NFS write requests that fall within the given range.
This is silly, since all servers use fsync(), to honour a COMMIT call,
and so will sync all pending writes to stable storage.

The following patch ensures that if at least one NFS write falls within
the range specified by the call to nfs_commit_file(), then we commit all
outstanding writes on that file.

This fixes a sometimes severe inefficiency when combining reads and
writes: nfs_wb_page() is used to clear out writes prior to scheduling a
read(), and can end up calling COMMIT for each page to be read.



---

 fs/nfs/write.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff -puN fs/nfs/write.c~nfs-optimise-COMMIT-calls fs/nfs/write.c
--- 25/fs/nfs/write.c~nfs-optimise-COMMIT-calls	2004-01-08 18:38:36.000000000 -0800
+++ 25-akpm/fs/nfs/write.c	2004-01-08 18:38:36.000000000 -0800
@@ -1074,9 +1074,12 @@ int nfs_commit_file(struct inode *inode,
 
 	spin_lock(&nfs_wreq_lock);
 	res = nfs_scan_commit(inode, &head, file, idx_start, npages);
-	spin_unlock(&nfs_wreq_lock);
-	if (res)
+	if (res) {
+		res += nfs_scan_commit(inode, &head, NULL, 0, 0);
+		spin_unlock(&nfs_wreq_lock);
 		error = nfs_commit_list(&head, how);
+	} else
+		spin_unlock(&nfs_wreq_lock);
 	if (error < 0)
 		return error;
 	return res;

_