From 117844711cb2aa61ea3a27941856fd45c4a58970 Mon Sep 17 00:00:00 2001 From: Jeff Moyer Date: Thu, 1 May 2008 04:35:08 -0700 Subject: [PATCH] --- yaml --- r: 95678 b: refs/heads/master c: 033790449ba9c4dcf8478a87693d33df625c23b5 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/fs/autofs4/root.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 5a2d2b71a715..bf85be4f728c 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: cab0936aac8aa907c6bb814c2cf26385478f254b +refs/heads/master: 033790449ba9c4dcf8478a87693d33df625c23b5 diff --git a/trunk/fs/autofs4/root.c b/trunk/fs/autofs4/root.c index aa4c5ff8a40d..0533d37c73ae 100644 --- a/trunk/fs/autofs4/root.c +++ b/trunk/fs/autofs4/root.c @@ -242,6 +242,7 @@ static int try_to_fill_dentry(struct dentry *dentry, int flags) { struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); struct autofs_info *ino = autofs4_dentry_ino(dentry); + struct dentry *new; int status = 0; /* Block on any pending expiry here; invalidate the dentry @@ -318,6 +319,27 @@ static int try_to_fill_dentry(struct dentry *dentry, int flags) spin_lock(&dentry->d_lock); dentry->d_flags &= ~DCACHE_AUTOFS_PENDING; spin_unlock(&dentry->d_lock); + + /* + * The dentry that is passed in from lookup may not be the one + * we end up using, as mkdir can create a new one. If this + * happens, and another process tries the lookup at the same time, + * it will set the PENDING flag on this new dentry, but add itself + * to our waitq. Then, if after the lookup succeeds, the first + * process that requested the mount performs another lookup of the + * same directory, it will show up as still pending! So, we need + * to redo the lookup here and clear pending on that dentry. + */ + if (d_unhashed(dentry)) { + new = d_lookup(dentry->d_parent, &dentry->d_name); + if (new) { + spin_lock(&new->d_lock); + new->d_flags &= ~DCACHE_AUTOFS_PENDING; + spin_unlock(&new->d_lock); + dput(new); + } + } + return status; }