summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDipankar Sarma <dipankar@in.ibm.com>2004-10-18 18:14:01 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-10-18 18:14:01 -0700
commit61f969b4ed29ebd4882702b9550c242ff68e0c8a (patch)
treefa5b8d48f902a69b390abc46987d54474c22bc6a
parentc979aaea590dff9fc872b6f938c6cf045afdd2fc (diff)
[PATCH] Fix dcache lookup
__d_lookup() has leftover stuff from earlier code to protect it against rename. The smp_rmb() there was needed for the sequence counter logic. Original dcache_rcu had : + move_count = dentry->d_move_count; + smp_rmb(); + if (dentry->d_name.hash != hash) continue; if (dentry->d_parent != parent) continue; This was to make sure that comparisons didn't happen before before the sequence counter was snapshotted. This logic is now gone and memory barrier is not needed. Removing this should also improve performance. The other change is the leftover smp_read_barrier_depends(), later converted to rcu_dereference(). Originally, the name comparison was not protected against d_move() and there could have been a mismatch of allocation size of the name string and dentry->d_name.len. This was avoided by making the qstr update in dentry atomic using a d_qstr pointer. Now, we do ->d_compare() or memcmp() with the d_lock held and it is safe against d_move(). So, there is no need to rcu_dereference() anything. In fact, the current code is meaningless. Signed-off-by: Dipankar Sarma <dipankar@in.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--fs/dcache.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/fs/dcache.c b/fs/dcache.c
index 3c17f9815b7e..e9285720356f 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -979,8 +979,6 @@ struct dentry * __d_lookup(struct dentry * parent, struct qstr * name)
dentry = hlist_entry(node, struct dentry, d_hash);
- smp_rmb();
-
if (dentry->d_name.hash != hash)
continue;
if (dentry->d_parent != parent)
@@ -1003,7 +1001,11 @@ struct dentry * __d_lookup(struct dentry * parent, struct qstr * name)
if (dentry->d_parent != parent)
goto next;
- qstr = rcu_dereference(&dentry->d_name);
+ /*
+ * It is safe to compare names since d_move() cannot
+ * change the qstr (protected by d_lock).
+ */
+ qstr = &dentry->d_name;
if (parent->d_op && parent->d_op->d_compare) {
if (parent->d_op->d_compare(parent, qstr, name))
goto next;