Commit 214fda1f authored by David Howells's avatar David Howells Committed by Linus Torvalds

[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: default avatarDavid Howells <dhowells@redhat.com>
Cc: Trond Myklebust <trond.myklebust@fys.uio.no>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 7d99b7d6
...@@ -325,10 +325,13 @@ static struct dentry * __d_find_alias(struct inode *inode, int want_discon) ...@@ -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 * d_find_alias(struct inode *inode)
{ {
struct dentry *de; struct dentry *de = NULL;
spin_lock(&dcache_lock);
de = __d_find_alias(inode, 0); if (!list_empty(&inode->i_dentry)) {
spin_unlock(&dcache_lock); spin_lock(&dcache_lock);
de = __d_find_alias(inode, 0);
spin_unlock(&dcache_lock);
}
return de; return de;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment