From 3cb4f9fa0c5f3ded9f70f85b70ee6d429834f911 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Tue, 16 Oct 2007 23:25:42 -0700 Subject: lib: percpu_counter_sub Hugh spotted that some code does: percpu_counter_add(&counter, -unsignedlong) which, when the amount argument is of type s32, sort-of works thanks to two's-complement. However when we'd change the type to s64 this breaks on 32bit machines, because the promotion rules zero extend the unsigned number. Provide percpu_counter_sub() to hide the s64 cast. That is: percpu_counter_sub(&counter, foo) is equal to: percpu_counter_add(&counter, -(s64)foo); Signed-off-by: Peter Zijlstra Cc: Hugh Dickins Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/ext2/balloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs/ext2') diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c index 53be25158560..9157fcf887bc 100644 --- a/fs/ext2/balloc.c +++ b/fs/ext2/balloc.c @@ -124,7 +124,7 @@ static int reserve_blocks(struct super_block *sb, int count) return 0; } - percpu_counter_add(&sbi->s_freeblocks_counter, -count); + percpu_counter_sub(&sbi->s_freeblocks_counter, count); sb->s_dirt = 1; return count; } -- cgit v1.2.3