aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext2/balloc.c
diff options
context:
space:
mode:
authorValerie Henson <val_henson@linux.intel.com>2006-06-25 08:48:12 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-25 13:01:12 -0400
commit21730eed11de42f22afcbd43f450a1872a0b5ea1 (patch)
treef695865bce3b87bbc9e1f0a8e61eaeecf8442b06 /fs/ext2/balloc.c
parent42225a359aa8094242651191ad0ac9c338503d81 (diff)
[PATCH] Make EXT2_DEBUG work again
This patch makes EXT2_DEBUG work again. Due to lack of proper include file, EXT2_DEBUG was undefined in bitmap.c and ext2_count_free() is left out. Moved to balloc.c and removed bitmap.c entirely. Second, debug versions of ext2_count_free_{inodes/blocks} reacquires superblock lock. Moved lock into callers. Signed-off-by: Val Henson <val_henson@linux.intel.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/ext2/balloc.c')
-rw-r--r--fs/ext2/balloc.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
index 2c00953d4b0b..433a213a8bd9 100644
--- a/fs/ext2/balloc.c
+++ b/fs/ext2/balloc.c
@@ -521,6 +521,26 @@ io_error:
521 goto out_release; 521 goto out_release;
522} 522}
523 523
524#ifdef EXT2FS_DEBUG
525
526static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0};
527
528unsigned long ext2_count_free (struct buffer_head * map, unsigned int numchars)
529{
530 unsigned int i;
531 unsigned long sum = 0;
532
533 if (!map)
534 return (0);
535 for (i = 0; i < numchars; i++)
536 sum += nibblemap[map->b_data[i] & 0xf] +
537 nibblemap[(map->b_data[i] >> 4) & 0xf];
538 return (sum);
539}
540
541#endif /* EXT2FS_DEBUG */
542
543/* Superblock must be locked */
524unsigned long ext2_count_free_blocks (struct super_block * sb) 544unsigned long ext2_count_free_blocks (struct super_block * sb)
525{ 545{
526 struct ext2_group_desc * desc; 546 struct ext2_group_desc * desc;
@@ -530,7 +550,6 @@ unsigned long ext2_count_free_blocks (struct super_block * sb)
530 unsigned long bitmap_count, x; 550 unsigned long bitmap_count, x;
531 struct ext2_super_block *es; 551 struct ext2_super_block *es;
532 552
533 lock_super (sb);
534 es = EXT2_SB(sb)->s_es; 553 es = EXT2_SB(sb)->s_es;
535 desc_count = 0; 554 desc_count = 0;
536 bitmap_count = 0; 555 bitmap_count = 0;
@@ -554,7 +573,6 @@ unsigned long ext2_count_free_blocks (struct super_block * sb)
554 printk("ext2_count_free_blocks: stored = %lu, computed = %lu, %lu\n", 573 printk("ext2_count_free_blocks: stored = %lu, computed = %lu, %lu\n",
555 (long)le32_to_cpu(es->s_free_blocks_count), 574 (long)le32_to_cpu(es->s_free_blocks_count),
556 desc_count, bitmap_count); 575 desc_count, bitmap_count);
557 unlock_super (sb);
558 return bitmap_count; 576 return bitmap_count;
559#else 577#else
560 for (i = 0; i < EXT2_SB(sb)->s_groups_count; i++) { 578 for (i = 0; i < EXT2_SB(sb)->s_groups_count; i++) {