Skip to content

Commit

Permalink
[PATCH] Make EXT2_DEBUG work again
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Valerie Henson authored and Linus Torvalds committed Jun 25, 2006
1 parent 42225a3 commit 21730ee
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 37 deletions.
2 changes: 1 addition & 1 deletion fs/ext2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

obj-$(CONFIG_EXT2_FS) += ext2.o

ext2-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
ext2-y := balloc.o dir.o file.o fsync.o ialloc.o inode.o \
ioctl.o namei.o super.o symlink.o

ext2-$(CONFIG_EXT2_FS_XATTR) += xattr.o xattr_user.o xattr_trusted.o
Expand Down
22 changes: 20 additions & 2 deletions fs/ext2/balloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,26 @@ int ext2_new_block(struct inode *inode, unsigned long goal,
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;
Expand All @@ -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;
Expand All @@ -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++) {
Expand Down
32 changes: 0 additions & 32 deletions fs/ext2/bitmap.c

This file was deleted.

3 changes: 1 addition & 2 deletions fs/ext2/ialloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ struct inode *ext2_new_inode(struct inode *dir, int mode)
return ERR_PTR(err);
}

/* Superblock must be locked */
unsigned long ext2_count_free_inodes (struct super_block * sb)
{
struct ext2_group_desc *desc;
Expand All @@ -649,7 +650,6 @@ unsigned long ext2_count_free_inodes (struct super_block * sb)
unsigned long bitmap_count = 0;
struct buffer_head *bitmap_bh = NULL;

lock_super (sb);
es = EXT2_SB(sb)->s_es;
for (i = 0; i < EXT2_SB(sb)->s_groups_count; i++) {
unsigned x;
Expand All @@ -672,7 +672,6 @@ unsigned long ext2_count_free_inodes (struct super_block * sb)
printk("ext2_count_free_inodes: stored = %lu, computed = %lu, %lu\n",
percpu_counter_read(&EXT2_SB(sb)->s_freeinodes_counter),
desc_count, bitmap_count);
unlock_super(sb);
return desc_count;
#else
for (i = 0; i < EXT2_SB(sb)->s_groups_count; i++) {
Expand Down
2 changes: 2 additions & 0 deletions fs/ext2/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,7 @@ static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf)
unsigned long overhead;
int i;

lock_super(sb);
if (test_opt (sb, MINIX_DF))
overhead = 0;
else {
Expand Down Expand Up @@ -1085,6 +1086,7 @@ static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf)
buf->f_files = le32_to_cpu(sbi->s_es->s_inodes_count);
buf->f_ffree = ext2_count_free_inodes (sb);
buf->f_namelen = EXT2_NAME_LEN;
unlock_super(sb);
return 0;
}

Expand Down

0 comments on commit 21730ee

Please sign in to comment.