Don't allow shrinking a PF_FSTRANS context

Avoid deadlocks when entering the shrinker from a PF_FSTRANS context.

This patch also reverts commit d0d5dd7 which added MUTEX_FSTRANS.  Its
use has been deprecated within ZFS as it was an ineffective mechanism
to eliminate deadlocks.  Among other things, it introduced the need for
strict ordering of mutex locking and unlocking in order that the
PF_FSTRANS flag wouldn't set incorrectly.

Signed-off-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #446
This commit is contained in:
Tim Chase
2015-03-31 07:49:15 -05:00
committed by Brian Behlendorf
parent c089961110
commit ae26dd0039
2 changed files with 27 additions and 35 deletions
+6
View File
@@ -1574,6 +1574,12 @@ __spl_kmem_cache_generic_shrinker(struct shrinker *shrink,
spl_kmem_cache_t *skc;
int alloc = 0;
/*
* No shrinking in a transaction context. Can cause deadlocks.
*/
if (sc->nr_to_scan && spl_fstrans_check())
return (SHRINK_STOP);
down_read(&spl_kmem_cache_sem);
list_for_each_entry(skc, &spl_kmem_cache_list, skc_list) {
if (sc->nr_to_scan) {