linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Linux Kernel <linux-kernel@vger.kernel.org>,
	torvalds@transmeta.com, autofs@linux.kernel.org
Subject: Fix for SMP deadlock in autofs4
Date: Fri, 20 Apr 2001 01:49:40 -0700	[thread overview]
Message-ID: <20010420014940.F8578@goop.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 1013 bytes --]

This is a fix for a potential deadlock in autofs4's expire routine.
It tries to use dput() while holding the dcache_lock.  This isn't a
problem in principle since dput() should only try to take the dcache_lock
when the counter makes a transition to zero, which can't happen in
this case.  Unfortunately the generic (and only) implementation of
atomic_dec_and_lock always takes the lock, so deadlocks.

Obviously, this only effects SMP.  UP's wise avoidance of spinlocks
saves it once again.

The simple solution is simply to replace dput() with atomic_dec().
The count can't reach zero because we did a dget_locked() and held
dcache_lock the whole time, so we never need to worry about the rest of
the dput() logic.

--- ../2.4/fs/autofs4/expire.c	Wed Jan 31 00:20:50 2001
+++ fs/autofs4/expire.c	Fri Apr 20 01:29:53 2001
@@ -223,7 +223,8 @@
 			mntput(p);
 			return dentry;
 		}
-		dput(d);
+
+		atomic_dec(&d->d_count); /* dput(), but we'll never hit zero */
 		mntput(p);
 	}
 	spin_unlock(&dcache_lock);

	J

[-- Attachment #2: Type: application/pgp-signature, Size: 240 bytes --]

             reply	other threads:[~2001-04-20  8:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-20  8:49 Jeremy Fitzhardinge [this message]
2001-04-20  9:00 ` Fix for SMP deadlock in autofs4 Alexander Viro
2001-04-20  9:11   ` Jeremy Fitzhardinge
2001-04-20 19:01 ` Linus Torvalds
2001-04-20 19:53   ` Alexander Viro
2001-04-21  1:46     ` Jeremy Fitzhardinge
2001-04-21  5:59       ` Linus Torvalds
2001-04-21  6:21         ` Alexander Viro
2001-04-21  7:04           ` Jeremy Fitzhardinge
2001-04-21  7:02         ` Jeremy Fitzhardinge

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=20010420014940.F8578@goop.org \
    --to=jeremy@goop.org \
    --cc=autofs@linux.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /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).