From: David Howells <dhowells@redhat.com>
To: torvalds@osdl.org, akpm@osdl.org, steved@redhat.com,
trond.myklebust@fys.uio.no, aviro@redhat.com
Cc: linux-fsdevel@vger.kernel.org, linux-cachefs@redhat.com,
nfsv4@linux-nfs.org, linux-kernel@vger.kernel.org
Subject: [PATCH 6/6] Optimise d_find_alias() [try #6]
Date: Tue, 07 Mar 2006 11:34:04 +0000 [thread overview]
Message-ID: <20060307113404.23330.71158.stgit@warthog.cambridge.redhat.com> (raw)
In-Reply-To: <20060307113352.23330.80913.stgit@warthog.cambridge.redhat.com>
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>
---
fs/dcache.c | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/fs/dcache.c b/fs/dcache.c
index 97e1e44..32051ba 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -325,10 +325,13 @@ static struct dentry * __d_find_alias(st
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;
+ smp_rmb();
+ if (!list_empty(&inode->i_dentry)) {
+ spin_lock(&dcache_lock);
+ de = __d_find_alias(inode, 0);
+ spin_unlock(&dcache_lock);
+ }
return de;
}
next prev parent reply other threads:[~2006-03-07 11:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-07 11:33 [PATCH 1/6] NFS: Permit filesystem to override root dentry on mount [try #6] David Howells
2006-03-07 11:33 ` [PATCH 2/6] 9p: Fix error handling on superblock alloc failure " David Howells
2006-03-07 11:33 ` [PATCH 3/6] NFS: Abstract out namespace initialisation " David Howells
2006-03-07 11:52 ` Christoph Hellwig
2006-03-07 11:33 ` [PATCH 4/6] NFS: Add dentry materialisation op " David Howells
2006-03-07 11:34 ` [PATCH 5/6] NFS: Unify NFS superblocks per-protocol per-server " David Howells
2006-03-07 11:34 ` David Howells [this message]
2006-03-07 12:03 ` [PATCH 6/6] Optimise d_find_alias() " Nick Piggin
2006-03-07 13:24 ` David Howells
2006-03-08 8:22 ` Nick Piggin
2006-03-08 12:14 ` Matthew Wilcox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060307113404.23330.71158.stgit@warthog.cambridge.redhat.com \
--to=dhowells@redhat.com \
--cc=akpm@osdl.org \
--cc=aviro@redhat.com \
--cc=linux-cachefs@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nfsv4@linux-nfs.org \
--cc=steved@redhat.com \
--cc=torvalds@osdl.org \
--cc=trond.myklebust@fys.uio.no \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).