Skip to content

Commit

Permalink
UBIFS: fix shrinker object count reports
Browse files Browse the repository at this point in the history
Sometimes VM asks the shrinker to return amount of objects it can shrink,
and we return the ubifs_clean_zn_cnt in that case. However, it is possible
that this counter is negative for a short period of time, due to the way
UBIFS TNC code updates it. And I can observe the following warnings sometimes:

shrink_slab: ubifs_shrinker+0x0/0x2b7 [ubifs] negative objects to delete nr=-8541616642706119788

This patch makes sure UBIFS never returns negative count of objects.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Cc: stable@kernel.org
  • Loading branch information
Artem Bityutskiy authored and Artem Bityutskiy committed Jun 3, 2011
1 parent da8b94e commit cf610bf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fs/ubifs/shrinker.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,11 @@ int ubifs_shrinker(struct shrinker *shrink, struct shrink_control *sc)
long clean_zn_cnt = atomic_long_read(&ubifs_clean_zn_cnt);

if (nr == 0)
return clean_zn_cnt;
/*
* Due to the way UBIFS updates the clean znode counter it may
* temporarily be negative.
*/
return clean_zn_cnt >= 0 ? clean_zn_cnt : 1;

if (!clean_zn_cnt) {
/*
Expand Down

0 comments on commit cf610bf

Please sign in to comment.