summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2006-03-25 14:06:36 +0300
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-25 19:22:49 +0300
commit214fda1f6e1b8ef2a5292b0372744037fc80d318 (patch)
tree4cf0a18632cc663fcd75a1e23e357ec39c0c3b37 /fs
parent7d99b7d634d81bb372e03e4561c80430aa4cfac2 (diff)
downloadlinux-214fda1f6e1b8ef2a5292b0372744037fc80d318.tar.xz
[PATCH] Optimise d_find_alias()
The attached patch optimises d_find_alias() to only take the spinlock if there's anything in the the inode's alias list. If there isn't, it returns NULL immediately. With respect to the superblock sharing patch, this should reduce by one the number of times the dcache_lock is taken by nfs_lookup() for ordinary directory lookups. Only in the case where there's already a dentry for particular directory inode (such as might happen when another mountpoint is rooted at that dentry) will the lock then be taken the extra time. Signed-off-by: David Howells <dhowells@redhat.com> Cc: Trond Myklebust <trond.myklebust@fys.uio.no> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/dcache.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/fs/dcache.c b/fs/dcache.c
index 653f64ce98e2..139e5fd22fa6 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -325,10 +325,13 @@ static struct dentry * __d_find_alias(struct inode *inode, int want_discon)
struct dentry * d_find_alias(struct inode *inode)
{
- struct dentry *de;
- spin_lock(&dcache_lock);
- de = __d_find_alias(inode, 0);
- spin_unlock(&dcache_lock);
+ struct dentry *de = NULL;
+
+ if (!list_empty(&inode->i_dentry)) {
+ spin_lock(&dcache_lock);
+ de = __d_find_alias(inode, 0);
+ spin_unlock(&dcache_lock);
+ }
return de;
}