diff --git a/fs/ext2/Makefile b/fs/ext2/Makefile index c5d02da73bc3dd192d42465bc544f719ab2cba90..e0b2b43c1fdb956115e18423d19f886ca6c7272d 100644 --- a/fs/ext2/Makefile +++ b/fs/ext2/Makefile @@ -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 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c index 2c00953d4b0b909b483f05f94b33da7f893c3acf..433a213a8bd9450f7f1ab3e7926002217d6cf1f9 100644 --- a/fs/ext2/balloc.c +++ b/fs/ext2/balloc.c @@ -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; @@ -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++) { diff --git a/fs/ext2/bitmap.c b/fs/ext2/bitmap.c deleted file mode 100644 index e9983a0dd39674fe68133ac741a09385e384d61d..0000000000000000000000000000000000000000 --- a/fs/ext2/bitmap.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * linux/fs/ext2/bitmap.c - * - * Copyright (C) 1992, 1993, 1994, 1995 - * Remy Card (card@masi.ibp.fr) - * Laboratoire MASI - Institut Blaise Pascal - * Universite Pierre et Marie Curie (Paris VI) - */ - -#ifdef EXT2FS_DEBUG - -#include - -#include "ext2.h" - -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 */ - diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c index e52765219e165eb866c4a0dafd120ce1d966806c..308c252568c6ed131a74377a0ebf9e2262002037 100644 --- a/fs/ext2/ialloc.c +++ b/fs/ext2/ialloc.c @@ -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; @@ -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; @@ -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++) { diff --git a/fs/ext2/super.c b/fs/ext2/super.c index fec55ff23deac9812726ff2f2c1ca14c5f5d5424..d4233b2e6436ec3926110bb7c5160060ba6dd239 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) unsigned long overhead; int i; + lock_super(sb); if (test_opt (sb, MINIX_DF)) overhead = 0; else { @@ -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; }