Fix for SMP deadlock in autofs4

Jeremy Fitzhardinge (jeremy@goop.org)
Fri, 20 Apr 2001 01:49:40 -0700


--2fHTh5uZTiUOsy+g
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

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

--2fHTh5uZTiUOsy+g
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iEYEARECAAYFAjrf+CQACgkQf6p1nWJ6IgLy2gCfYxkeZks6pS8ZeI3KajQHsPV7
WigAoISarCrRCAdenygR4Hlsw55/zftC
=BRGC
-----END PGP SIGNATURE-----

--2fHTh5uZTiUOsy+g--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/