linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ian Kent <raven@themaw.net>
To: Sage Weil <sage@newdream.net>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: Al Viro <viro@ZenIV.linux.org.uk>,
	Christoph Hellwig <hch@infradead.org>,
	Andreas Dilger <adilger@sun.com>,
	Yehuda Saheh <yehuda@newdream.net>,
	Jim Garlick <garlick@llnl.gov>
Subject: [RFC PATCH 08/11] autofs4 - eliminate d_unhashed in path walk checks
Date: Thu, 24 Sep 2009 16:22:12 +0800	[thread overview]
Message-ID: <20090924082212.22151.76953.stgit@zeus.themaw.net> (raw)
In-Reply-To: <20090924082036.22151.85151.stgit@zeus.themaw.net>

We unhash the dentry (in a subsequent patch) in ->d_revalidate() in
order to send mount requests to ->lookup(). But then we can not rely
on d_unhased() to give reliable results because it may be called at
any time by any code path. The d_unhashed() function is used by
__simple_empty() in the path walking callbacks but autofs mount
point dentrys should have no directories at all so a list_empty()
on d_subdirs should be (and is) sufficient.

Signed-off-by: Ian Kent <raven@themaw.net>
---

 fs/autofs4/root.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index 81700f4..b6530f3 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -133,7 +133,7 @@ static int autofs4_dir_open(struct inode *inode, struct file *file)
 	 * it.
 	 */
 	spin_lock(&dcache_lock);
-	if (!d_mountpoint(dentry) && __simple_empty(dentry)) {
+	if (!d_mountpoint(dentry) && list_empty(&dentry->d_subdirs)) {
 		spin_unlock(&dcache_lock);
 		return -ENOENT;
 	}
@@ -257,7 +257,7 @@ static void *autofs4_follow_link(struct dentry *dentry, struct nameidata *nd)
 	 * mount it again.
 	 */
 	if (ino->flags & AUTOFS_INF_PENDING ||
-	    (!d_mountpoint(dentry) && __simple_empty(dentry))) {
+	    (!d_mountpoint(dentry) && list_empty(&dentry->d_subdirs))) {
 		spin_unlock(&dcache_lock);
 		spin_unlock(&sbi->fs_lock);
 
@@ -340,8 +340,7 @@ static int autofs4_revalidate(struct dentry *dentry, struct nameidata *nd)
 	/* Check for a non-mountpoint directory with no contents */
 	spin_lock(&dcache_lock);
 	if (S_ISDIR(dentry->d_inode->i_mode) &&
-	    !d_mountpoint(dentry) && 
-	    __simple_empty(dentry)) {
+	    !d_mountpoint(dentry) && list_empty(&dentry->d_subdirs)) {
 		DPRINTK("dentry=%p %.*s, emptydir",
 			 dentry, dentry->d_name.len, dentry->d_name.name);
 		spin_unlock(&dcache_lock);


  parent reply	other threads:[~2009-09-24  8:31 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-24  8:21 [RFC PATCH 00/11] autofs4 - update autofs4 to deal with VFS locking change Ian Kent
2009-09-24  8:21 ` [RFC PATCH 01/11] Subject: [PATCH] vfs: make real_lookup do dentry revalidation with i_mutex held Ian Kent
2009-09-24  8:21 ` [RFC PATCH 02/11] autofs4 - use macros for active list handling Ian Kent
2009-09-24  8:21 ` [RFC PATCH 03/11] autofs4 - use macros for expiring list Ian Kent
2009-09-24  8:21 ` [RFC PATCH 04/11] autofs4 - use macro for need mount check Ian Kent
2009-09-24  8:21 ` [RFC PATCH 05/11] autofs4 - use autofs_info for pending flag Ian Kent
2009-09-24  8:21 ` [RFC PATCH 06/11] autofs4 - renamer unhashed to active in autofs4_lookup() Ian Kent
2009-09-24  8:22 ` [RFC PATCH 07/11] autofs4 - cleanup active and expire lookup Ian Kent
2009-09-24  8:22 ` Ian Kent [this message]
2009-09-24  8:22 ` [RFC PATCH 09/11] autofs4 - rename dentry to active in autofs4_lookup_active() Ian Kent
2009-09-24  8:22 ` [RFC PATCH 10/11] autofs4 - rename dentry to expiring in autofs4_lookup_expiring() Ian Kent
2009-09-24  8:22 ` [RFC PATCH 11/11] autofs4 - always use lookup for lookup Ian Kent
2009-09-24  9:19 ` [RFC PATCH 00/11] autofs4 - update autofs4 to deal with VFS locking change Ian Kent
2009-09-24 16:10 ` Sage Weil
2009-09-28  7:41   ` Ian Kent
2009-09-28  7:53   ` Ian Kent

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=20090924082212.22151.76953.stgit@zeus.themaw.net \
    --to=raven@themaw.net \
    --cc=adilger@sun.com \
    --cc=garlick@llnl.gov \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sage@newdream.net \
    --cc=viro@ZenIV.linux.org.uk \
    --cc=yehuda@newdream.net \
    /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).