fs/mbcache.c: make count_objects() more robust
PATCH 19/28 fs/mbcache.c: make count_objects() more robust
From: Jiang Biao <[email protected]>
Subject: fs/mbcache.c: make count_objects() more robust
When running ltp stress test for 7*24 hours, vmscan occasionally emits the following warning continuously:
mb_cache_scan+0x0/0x3f0 negative objects to delete nr=-9232265467809300450
...
Tracing shows the freeable(mb_cache_count returns) is -1, which causes the continuous accumulation and overflow of total_scan.
This patch makes sure that mb_cache_count() cannot return a negative value, which makes the mbcache shrinker more robust.
Signed-off-by Jiang Biao <[email protected]>
Cc Al Viro <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Michal Hocko <[email protected]>
Cc <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
fs/mbcache.c | 3 +++ 1 file changed, 3 insertions(+)
fs/mbcache.c renamed from fs/mbcache.c~fs-mbcache-make-count_objects-more-robust +3 -0
@@ -269,6 +269,9 @@ static unsigned long mb_cache_count(stru struct mb_cache *cache = container_of(shrink, struct mb_cache, c_shrink); +/* Unlikely, but not impossible */ +if (unlikely (cache->c_entry_count <0 )) +return 0 ;return cache->c_entry_count; }
_