ext4: fix freespace accounting with mballoc on 32bit From: Eric Sandeen On a 32bit machine, passing the negative unsigned long fe_len into percpu_counter_add (which expects s64) messes up the counters: [root@bear-05 linux-2.6.23-rc7]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sdb7 97G -149P 149P - /mnt/test Patch below fixes this. Signed-off-by: Eric Sandeen Signed-off-by: Mingming Cao --- fs/ext4/mballoc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: linux-2.6.24-rc3/fs/ext4/mballoc.c =================================================================== --- linux-2.6.24-rc3.orig/fs/ext4/mballoc.c 2007-12-03 16:06:43.000000000 -0800 +++ linux-2.6.24-rc3/fs/ext4/mballoc.c 2007-12-03 16:06:45.000000000 -0800 @@ -3012,7 +3012,7 @@ static int ext4_mb_mark_diskspace_used(s - ac->ac_b_ex.fe_len); gdp->bg_checksum = ext4_group_desc_csum(sbi, ac->ac_b_ex.fe_group, gdp); spin_unlock(sb_bgl_lock(sbi, ac->ac_b_ex.fe_group)); - percpu_counter_add(&sbi->s_freeblocks_counter, - ac->ac_b_ex.fe_len); + percpu_counter_sub(&sbi->s_freeblocks_counter, ac->ac_b_ex.fe_len); err = ext4_journal_dirty_metadata(handle, bitmap_bh); if (err)