public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dipankar Sarma <dipankar@in.ibm.com>
To: Alexander Viro <viro@parcelfarce.linux.theplanet.co.uk>
Cc: Andrew Morton <akpm@osdl.org>, linux-kernel@vger.kernel.org
Subject: [patch 1/3] Fix dcache lookup
Date: Mon, 20 Sep 2004 22:34:39 +0530	[thread overview]
Message-ID: <20040920170439.GA5181@in.ibm.com> (raw)

This patchset fixes a few things left over from the last changes
Andrew made to dcache lookup. I have tested them on a 2-way system
using normal sanity tests, dcachebench and a very heavy rename
test that we had earlier used for testing RCU-based dcache patches.
These should spend some longish time in -mm.

Thanks
Dipankar



__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>


 fs/dcache.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff -puN fs/dcache.c~dcache-fix-lookup fs/dcache.c
--- linux-2.6.9-rc2-dcache/fs/dcache.c~dcache-fix-lookup	2004-09-17 23:35:44.000000000 +0530
+++ linux-2.6.9-rc2-dcache-dipankar/fs/dcache.c	2004-09-17 23:39:29.000000000 +0530
@@ -978,8 +978,6 @@ struct dentry * __d_lookup(struct dentry
 
 		dentry = hlist_entry(node, struct dentry, d_hash);
 
-		smp_rmb();
-
 		if (dentry->d_name.hash != hash)
 			continue;
 		if (dentry->d_parent != parent)
@@ -1002,7 +1000,11 @@ struct dentry * __d_lookup(struct dentry
 		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;

_

             reply	other threads:[~2004-09-20 17:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-20 17:04 Dipankar Sarma [this message]
2004-09-20 17:09 ` [patch 2/3] Remove d_bucket Dipankar Sarma
2004-09-20 17:11   ` [patch 3/3] Document RCU based dcache lookup Dipankar Sarma
     [not found]   ` <20040920170225.GB5112@logos.cnet>
2004-09-20 18:49     ` [patch 2/3] Remove d_bucket Dipankar Sarma

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=20040920170439.GA5181@in.ibm.com \
    --to=dipankar@in.ibm.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@parcelfarce.linux.theplanet.co.uk \
    /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