summaryrefslogtreecommitdiff
path: root/fs/ext2/balloc.c
diff options
context:
space:
mode:
authorValerie Henson <val_henson@linux.intel.com>2006-06-25 12:48:12 (GMT)
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-25 17:01:12 (GMT)
commit21730eed11de42f22afcbd43f450a1872a0b5ea1 (patch)
treef695865bce3b87bbc9e1f0a8e61eaeecf8442b06 /fs/ext2/balloc.c
parent42225a359aa8094242651191ad0ac9c338503d81 (diff)
downloadlinux-21730eed11de42f22afcbd43f450a1872a0b5ea1.tar.xz
[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 2c00953..433a213 100644
--- a/fs/ext2/balloc.c
+++ b/fs/ext2/balloc.c
@@ -521,6 +521,26 @@ 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 */
+
+/* Superblock must be locked */
unsigned long ext2_count_free_blocks (struct super_block * sb)
{
struct ext2_group_desc * desc;
@@ -530,7 +550,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;
@@ -554,7 +573,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++) {