Skip to content

Commit

Permalink
[PATCH] Optimise d_find_alias()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David Howells authored and Linus Torvalds committed Mar 25, 2006
1 parent 7d99b7d commit 214fda1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions fs/dcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 214fda1

Please sign in to comment.