mbcache: fix shrinker function return value
The shrinker function is supposed to return the number of cache entries after shrinking, not before shrinking. Fix that. Based on a patch from Wang Sheng-Hui <crosslonelyover@gmail.com>. Signed-off-by: Andreas Gruenbacher <agruen@suse.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
committed by
Al Viro
parent
2aec7c5232
commit
e566d48c9b
29
fs/mbcache.c
29
fs/mbcache.c
@@ -176,22 +176,12 @@ static int
|
|||||||
mb_cache_shrink_fn(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask)
|
mb_cache_shrink_fn(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask)
|
||||||
{
|
{
|
||||||
LIST_HEAD(free_list);
|
LIST_HEAD(free_list);
|
||||||
struct list_head *l, *ltmp;
|
struct mb_cache *cache;
|
||||||
|
struct mb_cache_entry *entry, *tmp;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
spin_lock(&mb_cache_spinlock);
|
|
||||||
list_for_each(l, &mb_cache_list) {
|
|
||||||
struct mb_cache *cache =
|
|
||||||
list_entry(l, struct mb_cache, c_cache_list);
|
|
||||||
mb_debug("cache %s (%d)", cache->c_name,
|
|
||||||
atomic_read(&cache->c_entry_count));
|
|
||||||
count += atomic_read(&cache->c_entry_count);
|
|
||||||
}
|
|
||||||
mb_debug("trying to free %d entries", nr_to_scan);
|
mb_debug("trying to free %d entries", nr_to_scan);
|
||||||
if (nr_to_scan == 0) {
|
spin_lock(&mb_cache_spinlock);
|
||||||
spin_unlock(&mb_cache_spinlock);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
while (nr_to_scan-- && !list_empty(&mb_cache_lru_list)) {
|
while (nr_to_scan-- && !list_empty(&mb_cache_lru_list)) {
|
||||||
struct mb_cache_entry *ce =
|
struct mb_cache_entry *ce =
|
||||||
list_entry(mb_cache_lru_list.next,
|
list_entry(mb_cache_lru_list.next,
|
||||||
@@ -199,12 +189,15 @@ mb_cache_shrink_fn(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask)
|
|||||||
list_move_tail(&ce->e_lru_list, &free_list);
|
list_move_tail(&ce->e_lru_list, &free_list);
|
||||||
__mb_cache_entry_unhash(ce);
|
__mb_cache_entry_unhash(ce);
|
||||||
}
|
}
|
||||||
spin_unlock(&mb_cache_spinlock);
|
list_for_each_entry(cache, &mb_cache_list, c_cache_list) {
|
||||||
list_for_each_safe(l, ltmp, &free_list) {
|
mb_debug("cache %s (%d)", cache->c_name,
|
||||||
__mb_cache_entry_forget(list_entry(l, struct mb_cache_entry,
|
atomic_read(&cache->c_entry_count));
|
||||||
e_lru_list), gfp_mask);
|
count += atomic_read(&cache->c_entry_count);
|
||||||
|
}
|
||||||
|
spin_unlock(&mb_cache_spinlock);
|
||||||
|
list_for_each_entry_safe(entry, tmp, &free_list, e_lru_list) {
|
||||||
|
__mb_cache_entry_forget(entry, gfp_mask);
|
||||||
}
|
}
|
||||||
out:
|
|
||||||
return (count / 100) * sysctl_vfs_cache_pressure;
|
return (count / 100) * sysctl_vfs_cache_pressure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user