From ac48c0dd475ea672113ccb0d3bc2ef41dc3f85ac Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Sun, 18 Jan 2004 18:39:05 -0800 Subject: [PATCH] [PATCH] nfs: Optimize away unnecessary NFSv3 COMMIT calls. 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 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 5f4403e2f2363..37a4177cc98eb 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -1074,9 +1074,12 @@ int nfs_commit_file(struct inode *inode, struct file *file, unsigned long idx_st 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; -- 2.53.0