From: Al Viro <viro@ZenIV.linux.org.uk>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] fs: fold _d_rehash into d_rehash
Date: Thu, 2 Oct 2014 18:49:47 +0100 [thread overview]
Message-ID: <20141002174947.GV7996@ZenIV.linux.org.uk> (raw)
In-Reply-To: <1412271264-32362-1-git-send-email-hch@lst.de>
On Thu, Oct 02, 2014 at 07:34:24PM +0200, Christoph Hellwig wrote:
FWIW, I already have something stronger in my tree. Look: the only reason
to have separate __d_rehash() is doing it early in __d_move(). Move that
past the place where we change names and locations and you get this:
diff --git a/fs/dcache.c b/fs/dcache.c
index e605b6d..2041261 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -2345,8 +2345,9 @@ again:
}
EXPORT_SYMBOL(d_delete);
-static void __d_rehash(struct dentry * entry, struct hlist_bl_head *b)
+static void __d_rehash(struct dentry *entry)
{
+ struct hlist_bl_head *b = d_hash(entry->d_parent, entry->d_name.hash);
BUG_ON(!d_unhashed(entry));
hlist_bl_lock(b);
entry->d_flags |= DCACHE_RCUACCESS;
@@ -2354,11 +2355,6 @@ static void __d_rehash(struct dentry * entry, struct hlist_bl_head *b)
hlist_bl_unlock(b);
}
-static void _d_rehash(struct dentry * entry)
-{
- __d_rehash(entry, d_hash(entry->d_parent, entry->d_name.hash));
-}
-
/**
* d_rehash - add an entry back to the hash
* @entry: dentry to add to the hash
@@ -2369,7 +2365,7 @@ static void _d_rehash(struct dentry * entry)
void d_rehash(struct dentry * entry)
{
spin_lock(&entry->d_lock);
- _d_rehash(entry);
+ __d_rehash(entry);
spin_unlock(&entry->d_lock);
}
EXPORT_SYMBOL(d_rehash);
@@ -2545,17 +2541,12 @@ static void __d_move(struct dentry *dentry, struct dentry *target,
* for the same hash queue because of how unlikely it is.
*/
__d_drop(dentry);
- __d_rehash(dentry, d_hash(target->d_parent, target->d_name.hash));
/*
* Unhash the target (d_delete() is not usable here). If exchanging
* the two dentries, then rehash onto the other's hash queue.
*/
__d_drop(target);
- if (exchange) {
- __d_rehash(target,
- d_hash(dentry->d_parent, dentry->d_name.hash));
- }
/* Switch the names.. */
if (exchange)
@@ -2579,6 +2570,9 @@ static void __d_move(struct dentry *dentry, struct dentry *target,
fsnotify_d_move(target);
fsnotify_d_move(dentry);
}
+ __d_rehash(dentry);
+ if (exchange)
+ __d_rehash(target);
write_seqcount_end(&target->d_seq);
write_seqcount_end(&dentry->d_seq);
prev parent reply other threads:[~2014-10-02 17:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-02 17:34 [PATCH] fs: fold _d_rehash into d_rehash Christoph Hellwig
2014-10-02 17:49 ` Al Viro [this message]
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=20141002174947.GV7996@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
/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).