diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2007-10-17 02:25:42 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-17 11:42:44 -0400 |
commit | 3cb4f9fa0c5f3ded9f70f85b70ee6d429834f911 (patch) | |
tree | d1f45445fa98bd41a2f8986781f7c62b470a6b8d /fs/ext3/balloc.c | |
parent | aa0dff2d09bfa50b7d02714a45920c64568e699d (diff) |
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 <a.p.zijlstra@chello.nl>
Cc: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ext3/balloc.c')
-rw-r--r-- | fs/ext3/balloc.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c index df575673e02d..d3758ee9cb5b 100644 --- a/fs/ext3/balloc.c +++ b/fs/ext3/balloc.c | |||
@@ -1633,7 +1633,7 @@ allocated: | |||
1633 | gdp->bg_free_blocks_count = | 1633 | gdp->bg_free_blocks_count = |
1634 | cpu_to_le16(le16_to_cpu(gdp->bg_free_blocks_count)-num); | 1634 | cpu_to_le16(le16_to_cpu(gdp->bg_free_blocks_count)-num); |
1635 | spin_unlock(sb_bgl_lock(sbi, group_no)); | 1635 | spin_unlock(sb_bgl_lock(sbi, group_no)); |
1636 | percpu_counter_add(&sbi->s_freeblocks_counter, -num); | 1636 | percpu_counter_sub(&sbi->s_freeblocks_counter, num); |
1637 | 1637 | ||
1638 | BUFFER_TRACE(gdp_bh, "journal_dirty_metadata for group descriptor"); | 1638 | BUFFER_TRACE(gdp_bh, "journal_dirty_metadata for group descriptor"); |
1639 | err = ext3_journal_dirty_metadata(handle, gdp_bh); | 1639 | err = ext3_journal_dirty_metadata(handle, gdp_bh); |