percpu_counter: use correct API
PATCH 2/4 percpu_counter: use correct API
percpu_counter_sum_positive never returns negative, since there is a negative check, I changed it to percpu_counter_sum.
Signed-off-by Shaohua Li <[email protected]>
--- fs/ext4/balloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/balloc.c +1 -1
@@ -506,7 +506,7 @@ static int ext4_has_free_blocks(struct eif (free_blocks - (nblocks + root_blocks + dirty_blocks) <EXT4_FREEBLOCKS_WATERMARK ) { free_blocks =percpu_counter_sum_positive (fbc); - dirty_blocks =percpu_counter_sum_positive (dbc); + dirty_blocks =percpu_counter_sum (dbc);if (dirty_blocks <0 ) { printk(KERN_CRIT "Dirty block accounting " "went wrong %lld\n",
Quoted 14 lines · Shaohua Li
percpu_counter_sum_positivenever returns negative, since there is a negative check, I changed it topercpu_counter_sum.Signed-off-by Shaohua Li <[email protected]>--- fs/ext4/balloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Index:
linux/fs/ext4/balloc.c
===================================================================
fs/ext4/balloc.c static int ext4_has_free_blocks(struct e · line 512
Quoted 8 lines
fs/ext4/balloc.c +1
-1@@ -506,7 +506,7 @@ static int ext4_has_free_blocks(struct eif (free_blocks - (nblocks + root_blocks + dirty_blocks) <EXT4_FREEBLOCKS_WATERMARK ) { free_blocks =percpu_counter_sum_positive (fbc); - dirty_blocks =percpu_counter_sum_positive (dbc); + dirty_blocks =percpu_counter_sum (dbc);if (dirty_blocks <0 ) { printk(KERN_CRIT "Dirty block accounting " "went wrong %lld\n",
The right thing to do would be removing if (dirty_blocks < 0) and keep using _positive. perpcu_counter_sum() may return a negative number spuriously (that's the whole point of _positive functions) and may trigger the critial error path when nothing is really wrong.
Thanks.
Signature · 1 line
tejun