aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext2/balloc.c
diff options
context:
space:
mode:
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++) {