public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Fix for SMP deadlock in autofs4
@ 2001-04-20  8:49 Jeremy Fitzhardinge
  2001-04-20  9:00 ` Alexander Viro
  2001-04-20 19:01 ` Linus Torvalds
  0 siblings, 2 replies; 10+ messages in thread
From: Jeremy Fitzhardinge @ 2001-04-20  8:49 UTC (permalink / raw)
  To: Linux Kernel, torvalds, autofs

[-- 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 --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2001-04-21  7:04 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-04-20  8:49 Fix for SMP deadlock in autofs4 Jeremy Fitzhardinge
2001-04-20  9:00 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox