Fix for SMP deadlock in autofs4

From: Jeremy Fitzhardinge (jeremy@goop.org)
Date: Fri Apr 20 2001 - 03:49:40 EST


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



-
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/



This archive was generated by hypermail 2b29 : Mon Apr 23 2001 - 21:00:35 EST