Commit 97c0e195 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Fix another lockdep splat

vfree() can allocate memory, so we need to call memalloc_nofs_save().
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 505b7a4c
......@@ -253,7 +253,7 @@ static unsigned long bch2_btree_cache_scan(struct shrinker *shrink,
unsigned long can_free;
unsigned long touched = 0;
unsigned long freed = 0;
unsigned i;
unsigned i, flags;
if (btree_shrinker_disabled(c))
return SHRINK_STOP;
......@@ -264,6 +264,8 @@ static unsigned long bch2_btree_cache_scan(struct shrinker *shrink,
else if (!mutex_trylock(&bc->lock))
return -1;
flags = memalloc_nofs_save();
/*
* It's _really_ critical that we don't free too many btree nodes - we
* have to always leave ourselves a reserve. The reserve is how we
......@@ -327,6 +329,7 @@ static unsigned long bch2_btree_cache_scan(struct shrinker *shrink,
clear_btree_node_accessed(b);
}
memalloc_nofs_restore(flags);
mutex_unlock(&bc->lock);
out:
return (unsigned long) freed * btree_pages(c);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment