Browse Source

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>
Trond Myklebust 8 years ago
parent
commit
1403390d83
1 changed files with 3 additions and 5 deletions
  1. 3 5
      fs/nfs/write.c

+ 3 - 5
fs/nfs/write.c

@@ -1097,13 +1097,12 @@ static struct nfs_page *nfs_try_to_update_request(struct inode *inode,
 	unsigned int end;
 	unsigned int end;
 	int error;
 	int error;
 
 
-	if (!PagePrivate(page))
-		return NULL;
-
 	end = offset + bytes;
 	end = offset + bytes;
-	spin_lock(&inode->i_lock);
 
 
 	for (;;) {
 	for (;;) {
+		if (!(PagePrivate(page) || PageSwapCache(page)))
+			return NULL;
+		spin_lock(&inode->i_lock);
 		req = nfs_page_find_head_request_locked(NFS_I(inode), page);
 		req = nfs_page_find_head_request_locked(NFS_I(inode), page);
 		if (req == NULL)
 		if (req == NULL)
 			goto out_unlock;
 			goto out_unlock;
@@ -1132,7 +1131,6 @@ static struct nfs_page *nfs_try_to_update_request(struct inode *inode,
 		nfs_release_request(req);
 		nfs_release_request(req);
 		if (error != 0)
 		if (error != 0)
 			goto out_err;
 			goto out_err;
-		spin_lock(&inode->i_lock);
 	}
 	}
 
 
 	/* Okay, the request matches. Update the region */
 	/* Okay, the request matches. Update the region */