summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Myklebust2017-07-17 15:37:12 +0200
committerTrond Myklebust2017-08-15 17:54:46 +0200
commit1403390d8366c717139cab26b8e94d943915fa12 (patch)
tree4a254482b5f730f0927b88c0fafca3361b7f9235
parentNFS: Reduce lock contention in nfs_page_find_head_request() (diff)
downloadkernel-qcow2-linux-1403390d8366c717139cab26b8e94d943915fa12.tar.gz
kernel-qcow2-linux-1403390d8366c717139cab26b8e94d943915fa12.tar.xz
kernel-qcow2-linux-1403390d8366c717139cab26b8e94d943915fa12.zip
NFS: Reduce lock contention in nfs_try_to_update_request()
Micro-optimisation to move the lockless check into the for(;;) loop. Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
-rw-r--r--fs/nfs/write.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 06e150c4e315..bb019096c331 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -1097,13 +1097,12 @@ static struct nfs_page *nfs_try_to_update_request(struct inode *inode,
unsigned int end;
int error;
- if (!PagePrivate(page))
- return NULL;
-
end = offset + bytes;
- spin_lock(&inode->i_lock);
for (;;) {
+ if (!(PagePrivate(page) || PageSwapCache(page)))
+ return NULL;
+ spin_lock(&inode->i_lock);
req = nfs_page_find_head_request_locked(NFS_I(inode), page);
if (req == NULL)
goto out_unlock;
@@ -1132,7 +1131,6 @@ static struct nfs_page *nfs_try_to_update_request(struct inode *inode,
nfs_release_request(req);
if (error != 0)
goto out_err;
- spin_lock(&inode->i_lock);
}
/* Okay, the request matches. Update the region */