X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=fs%2Fext2%2Fballoc.c;h=53be251585603067c515f14bef2109b4ca34b64a;hb=aa0dff2d09bfa50b7d02714a45920c64568e699d;hp=bb6908066494e5dd158894b15232700f062fc8c4;hpb=b8cbfa692485bf7568eda3d2f37545a76efb7c93;p=linux-2.6 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c index bb69080664..53be251585 100644 --- a/fs/ext2/balloc.c +++ b/fs/ext2/balloc.c @@ -11,11 +11,11 @@ * David S. Miller (davem@caip.rutgers.edu), 1995 */ -#include #include "ext2.h" #include #include #include +#include /* * balloc.c contains the blocks allocation and deallocation routines @@ -29,7 +29,7 @@ * The file system contains group descriptors which are located after the * super block. Each descriptor contains the number of the bitmap block and * the free blocks count in the block. The descriptors are loaded in memory - * when a file system is mounted (see ext2_read_super). + * when a file system is mounted (see ext2_fill_super). */ @@ -124,7 +124,7 @@ static int reserve_blocks(struct super_block *sb, int count) return 0; } - percpu_counter_mod(&sbi->s_freeblocks_counter, -count); + percpu_counter_add(&sbi->s_freeblocks_counter, -count); sb->s_dirt = 1; return count; } @@ -134,7 +134,7 @@ static void release_blocks(struct super_block *sb, int count) if (count) { struct ext2_sb_info *sbi = EXT2_SB(sb); - percpu_counter_mod(&sbi->s_freeblocks_counter, count); + percpu_counter_add(&sbi->s_freeblocks_counter, count); sb->s_dirt = 1; } } @@ -520,6 +520,25 @@ io_error: goto out_release; } +#ifdef EXT2FS_DEBUG + +static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0}; + +unsigned long ext2_count_free (struct buffer_head * map, unsigned int numchars) +{ + unsigned int i; + unsigned long sum = 0; + + if (!map) + return (0); + for (i = 0; i < numchars; i++) + sum += nibblemap[map->b_data[i] & 0xf] + + nibblemap[(map->b_data[i] >> 4) & 0xf]; + return (sum); +} + +#endif /* EXT2FS_DEBUG */ + unsigned long ext2_count_free_blocks (struct super_block * sb) { struct ext2_group_desc * desc; @@ -529,7 +548,6 @@ unsigned long ext2_count_free_blocks (struct super_block * sb) unsigned long bitmap_count, x; struct ext2_super_block *es; - lock_super (sb); es = EXT2_SB(sb)->s_es; desc_count = 0; bitmap_count = 0; @@ -553,7 +571,6 @@ unsigned long ext2_count_free_blocks (struct super_block * sb) printk("ext2_count_free_blocks: stored = %lu, computed = %lu, %lu\n", (long)le32_to_cpu(es->s_free_blocks_count), desc_count, bitmap_count); - unlock_super (sb); return bitmap_count; #else for (i = 0; i < EXT2_SB(sb)->s_groups_count; i++) {