linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ian Kent <raven@themaw.net>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: autofs mailing list <autofs@vger.kernel.org>,
	Kernel Mailing List <linux-kernel@vger.kernel.org>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	Omar Sandoval <osandov@osandov.com>,
	Al Viro <viro@ZenIV.linux.org.uk>
Subject: [PATCH 6/7] autofs - dont hold spin lock over direct mount expire
Date: Mon, 28 Nov 2016 10:12:14 +0800	[thread overview]
Message-ID: <148029913453.27779.15747032937407838983.stgit@pluto.themaw.net> (raw)
In-Reply-To: <148029910861.27779.4517883721395202453.stgit@pluto.themaw.net>

From: Ian Kent <ikent@redhat.com>

Commit 7cbdb4a286 altered the autofs indirect mount expire to
not hold a spin lock during the expire check.

The direct mount expire needs the same treatment because to
make autofs expires namespace aware may_umount_tree() needs to
to use a similar method to may_umount() when checking if a mount
tree is in use.

This means may_umount_tree() will end up taking the namespace_sem
for the check so the autofs direct mount expire won't be allowed
to hold a spin lock over the check.

Signed-off-by: Ian Kent <raven@themaw.net>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: Omar Sandoval <osandov@osandov.com>
---
 fs/autofs4/expire.c |   17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/fs/autofs4/expire.c b/fs/autofs4/expire.c
index 13178bf..57725d4 100644
--- a/fs/autofs4/expire.c
+++ b/fs/autofs4/expire.c
@@ -310,26 +310,29 @@ struct dentry *autofs4_expire_direct(struct super_block *sb,
 	now = jiffies;
 	timeout = sbi->exp_timeout;
 
-	spin_lock(&sbi->fs_lock);
-	ino = autofs4_dentry_ino(root);
-	/* No point expiring a pending mount */
-	if (ino->flags & AUTOFS_INF_PENDING)
-		goto out;
 	if (!autofs4_direct_busy(mnt, root, timeout, do_now)) {
+		spin_lock(&sbi->fs_lock);
+		ino = autofs4_dentry_ino(root);
+		/* No point expiring a pending mount */
+		if (ino->flags & AUTOFS_INF_PENDING) {
+			spin_unlock(&sbi->fs_lock);
+			goto out;
+		}
 		ino->flags |= AUTOFS_INF_WANT_EXPIRE;
 		spin_unlock(&sbi->fs_lock);
 		synchronize_rcu();
-		spin_lock(&sbi->fs_lock);
 		if (!autofs4_direct_busy(mnt, root, timeout, do_now)) {
+			spin_lock(&sbi->fs_lock);
 			ino->flags |= AUTOFS_INF_EXPIRING;
 			init_completion(&ino->expire_complete);
 			spin_unlock(&sbi->fs_lock);
 			return root;
 		}
+		spin_lock(&sbi->fs_lock);
 		ino->flags &= ~AUTOFS_INF_WANT_EXPIRE;
+		spin_unlock(&sbi->fs_lock);
 	}
 out:
-	spin_unlock(&sbi->fs_lock);
 	dput(root);
 
 	return NULL;

  parent reply	other threads:[~2016-11-28  2:12 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-28  2:11 [PATCH 1/7] vfs - merge path_is_mountpoint() and path_is_mountpoint_rcu() Ian Kent
2016-11-28  2:11 ` [PATCH 2/7] autofs - make struct path const in autofs4_dir_open() Ian Kent
2016-11-28  2:11 ` [PATCH 3/7] autofs - change struct path to const in autofs4_expire_wait() and autofs4_wait() Ian Kent
2016-11-28  2:12 ` [PATCH 4/7] vfs - change struct path to const in d_manage() Ian Kent
2016-11-28  2:12 ` [PATCH 5/7] vfs - constify path parameter of path_has_submounts() Ian Kent
2016-11-28  2:12 ` Ian Kent [this message]
2016-11-28  2:12 ` [PATCH 7/7] vfs - make may_umount_tree() mount propogation aware Ian Kent
2016-11-30 22:22 ` [PATCH 1/7] vfs - merge path_is_mountpoint() and path_is_mountpoint_rcu() Andrew Morton
2016-12-01  0:13   ` Ian Kent
2016-12-03  5:13 ` Al Viro
2016-12-03 23:29   ` Al Viro
2016-12-04  2:18     ` Ian Kent
2016-12-05  2:50       ` Ian Kent
2016-12-04  2:07   ` Ian Kent
2016-12-06  9:37   ` Ian Kent
2016-12-07 21:30     ` Eric W. Biederman
2016-12-08  3:29       ` Ian Kent
2016-12-08  4:28         ` Eric W. Biederman
2016-12-08  6:18           ` 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=148029913453.27779.15747032937407838983.stgit@pluto.themaw.net \
    --to=raven@themaw.net \
    --cc=akpm@linux-foundation.org \
    --cc=autofs@vger.kernel.org \
    --cc=ebiederm@xmission.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=osandov@osandov.com \
    --cc=viro@ZenIV.linux.org.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;
as well as URLs for NNTP newsgroup(s).