aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--fs/ext2/Makefile2
-rw-r--r--fs/ext2/balloc.c22
-rw-r--r--fs/ext2/bitmap.c32
-rw-r--r--fs/ext2/ialloc.c3
-rw-r--r--fs/ext2/super.c2
5 files changed, 24 insertions, 37 deletions
diff --git a/fs/ext2/Makefile b/fs/ext2/Makefile
index c5d02da73bc3..e0b2b43c1fdb 100644
--- a/fs/ext2/Makefile
+++ b/fs/ext2/Makefile
@@ -4,7 +4,7 @@
4 4
5obj-$(CONFIG_EXT2_FS) += ext2.o 5obj-$(CONFIG_EXT2_FS) += ext2.o
6 6
7ext2-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \ 7ext2-y := balloc.o dir.o file.o fsync.o ialloc.o inode.o \
8 ioctl.o namei.o super.o symlink.o 8 ioctl.o namei.o super.o symlink.o
9 9
10ext2-$(CONFIG_EXT2_FS_XATTR) += xattr.o xattr_user.o xattr_trusted.o 10ext2-$(CONFIG_EXT2_FS_XATTR) += xattr.o xattr_user.o xattr_trusted.o
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++) {
diff --git a/fs/ext2/bitmap.c b/fs/ext2/bitmap.c
deleted file mode 100644
index e9983a0dd396..000000000000
--- a/fs/ext2/bitmap.c
+++ /dev/null
@@ -1,32 +0,0 @@
1/*
2 * linux/fs/ext2/bitmap.c
3 *
4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 */
9
10#ifdef EXT2FS_DEBUG
11
12#include <linux/buffer_head.h>
13
14#include "ext2.h"
15
16static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0};
17
18unsigned long ext2_count_free (struct buffer_head * map, unsigned int numchars)
19{
20 unsigned int i;
21 unsigned long sum = 0;
22
23 if (!map)
24 return (0);
25 for (i = 0; i < numchars; i++)
26 sum += nibblemap[map->b_data[i] & 0xf] +
27 nibblemap[(map->b_data[i] >> 4) & 0xf];
28 return (sum);
29}
30
31#endif /* EXT2FS_DEBUG */
32
diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c
index e52765219e16..308c252568c6 100644
--- a/fs/ext2/ialloc.c
+++ b/fs/ext2/ialloc.c
@@ -638,6 +638,7 @@ fail:
638 return ERR_PTR(err); 638 return ERR_PTR(err);
639} 639}
640 640
641/* Superblock must be locked */
641unsigned long ext2_count_free_inodes (struct super_block * sb) 642unsigned long ext2_count_free_inodes (struct super_block * sb)
642{ 643{
643 struct ext2_group_desc *desc; 644 struct ext2_group_desc *desc;
@@ -649,7 +650,6 @@ unsigned long ext2_count_free_inodes (struct super_block * sb)
649 unsigned long bitmap_count = 0; 650 unsigned long bitmap_count = 0;
650 struct buffer_head *bitmap_bh = NULL; 651 struct buffer_head *bitmap_bh = NULL;
651 652
652 lock_super (sb);
653 es = EXT2_SB(sb)->s_es; 653 es = EXT2_SB(sb)->s_es;
654 for (i = 0; i < EXT2_SB(sb)->s_groups_count; i++) { 654 for (i = 0; i < EXT2_SB(sb)->s_groups_count; i++) {
655 unsigned x; 655 unsigned x;
@@ -672,7 +672,6 @@ unsigned long ext2_count_free_inodes (struct super_block * sb)
672 printk("ext2_count_free_inodes: stored = %lu, computed = %lu, %lu\n", 672 printk("ext2_count_free_inodes: stored = %lu, computed = %lu, %lu\n",
673 percpu_counter_read(&EXT2_SB(sb)->s_freeinodes_counter), 673 percpu_counter_read(&EXT2_SB(sb)->s_freeinodes_counter),
674 desc_count, bitmap_count); 674 desc_count, bitmap_count);
675 unlock_super(sb);
676 return desc_count; 675 return desc_count;
677#else 676#else
678 for (i = 0; i < EXT2_SB(sb)->s_groups_count; i++) { 677 for (i = 0; i < EXT2_SB(sb)->s_groups_count; i++) {
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index fec55ff23dea..d4233b2e6436 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -1045,6 +1045,7 @@ static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf)
1045 unsigned long overhead; 1045 unsigned long overhead;
1046 int i; 1046 int i;
1047 1047
1048 lock_super(sb);
1048 if (test_opt (sb, MINIX_DF)) 1049 if (test_opt (sb, MINIX_DF))
1049 overhead = 0; 1050 overhead = 0;
1050 else { 1051 else {
@@ -1085,6 +1086,7 @@ static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf)
1085 buf->f_files = le32_to_cpu(sbi->s_es->s_inodes_count); 1086 buf->f_files = le32_to_cpu(sbi->s_es->s_inodes_count);
1086 buf->f_ffree = ext2_count_free_inodes (sb); 1087 buf->f_ffree = ext2_count_free_inodes (sb);
1087 buf->f_namelen = EXT2_NAME_LEN; 1088 buf->f_namelen = EXT2_NAME_LEN;
1089 unlock_super(sb);
1088 return 0; 1090 return 0;
1089} 1091}
1090 1092