Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1c4344a5 authored by Ian Kent's avatar Ian Kent Committed by Al Viro
Browse files

autofs - dont hold spin lock over direct mount expire



Commit 7cbdb4a2 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: default avatarIan 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>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 455e8f10
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -310,26 +310,29 @@ struct dentry *autofs4_expire_direct(struct super_block *sb,
	now = jiffies;
	timeout = sbi->exp_timeout;

	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)
		if (ino->flags & AUTOFS_INF_PENDING) {
			spin_unlock(&sbi->fs_lock);
			goto out;
	if (!autofs4_direct_busy(mnt, root, timeout, do_now)) {
		}
		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;