summaryrefslogtreecommitdiffstats
path: root/fs/ext2
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext2')
-rw-r--r--fs/ext2/Makefile2
-rw-r--r--fs/ext2/balloc.c23
-rw-r--r--fs/ext2/bitmap.c32
-rw-r--r--fs/ext2/dir.c6
-rw-r--r--fs/ext2/ext2.h6
-rw-r--r--fs/ext2/fsync.c2
-rw-r--r--fs/ext2/ialloc.c4
-rw-r--r--fs/ext2/inode.c6
-rw-r--r--fs/ext2/super.c40
-rw-r--r--fs/ext2/xattr.h1
10 files changed, 52 insertions, 70 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..d4870432ecfc 100644
--- a/fs/ext2/balloc.c
+++ b/fs/ext2/balloc.c
@@ -11,7 +11,6 @@
11 * David S. Miller (davem@caip.rutgers.edu), 1995 11 * David S. Miller (davem@caip.rutgers.edu), 1995
12 */ 12 */
13 13
14#include <linux/config.h>
15#include "ext2.h" 14#include "ext2.h"
16#include <linux/quotaops.h> 15#include <linux/quotaops.h>
17#include <linux/sched.h> 16#include <linux/sched.h>
@@ -521,6 +520,26 @@ io_error:
521 goto out_release; 520 goto out_release;
522} 521}
523 522
523#ifdef EXT2FS_DEBUG
524
525static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0};
526
527unsigned long ext2_count_free (struct buffer_head * map, unsigned int numchars)
528{
529 unsigned int i;
530 unsigned long sum = 0;
531
532 if (!map)
533 return (0);
534 for (i = 0; i < numchars; i++)
535 sum += nibblemap[map->b_data[i] & 0xf] +
536 nibblemap[(map->b_data[i] >> 4) & 0xf];
537 return (sum);
538}
539
540#endif /* EXT2FS_DEBUG */
541
542/* Superblock must be locked */
524unsigned long ext2_count_free_blocks (struct super_block * sb) 543unsigned long ext2_count_free_blocks (struct super_block * sb)
525{ 544{
526 struct ext2_group_desc * desc; 545 struct ext2_group_desc * desc;
@@ -530,7 +549,6 @@ unsigned long ext2_count_free_blocks (struct super_block * sb)
530 unsigned long bitmap_count, x; 549 unsigned long bitmap_count, x;
531 struct ext2_super_block *es; 550 struct ext2_super_block *es;
532 551
533 lock_super (sb);
534 es = EXT2_SB(sb)->s_es; 552 es = EXT2_SB(sb)->s_es;
535 desc_count = 0; 553 desc_count = 0;
536 bitmap_count = 0; 554 bitmap_count = 0;
@@ -554,7 +572,6 @@ unsigned long ext2_count_free_blocks (struct super_block * sb)
554 printk("ext2_count_free_blocks: stored = %lu, computed = %lu, %lu\n", 572 printk("ext2_count_free_blocks: stored = %lu, computed = %lu, %lu\n",
555 (long)le32_to_cpu(es->s_free_blocks_count), 573 (long)le32_to_cpu(es->s_free_blocks_count),
556 desc_count, bitmap_count); 574 desc_count, bitmap_count);
557 unlock_super (sb);
558 return bitmap_count; 575 return bitmap_count;
559#else 576#else
560 for (i = 0; i < EXT2_SB(sb)->s_groups_count; i++) { 577 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/dir.c b/fs/ext2/dir.c
index d672aa9f4061..92ea8265d7d5 100644
--- a/fs/ext2/dir.c
+++ b/fs/ext2/dir.c
@@ -159,8 +159,7 @@ fail:
159static struct page * ext2_get_page(struct inode *dir, unsigned long n) 159static struct page * ext2_get_page(struct inode *dir, unsigned long n)
160{ 160{
161 struct address_space *mapping = dir->i_mapping; 161 struct address_space *mapping = dir->i_mapping;
162 struct page *page = read_cache_page(mapping, n, 162 struct page *page = read_mapping_page(mapping, n, NULL);
163 (filler_t*)mapping->a_ops->readpage, NULL);
164 if (!IS_ERR(page)) { 163 if (!IS_ERR(page)) {
165 wait_on_page_locked(page); 164 wait_on_page_locked(page);
166 kmap(page); 165 kmap(page);
@@ -400,8 +399,7 @@ ino_t ext2_inode_by_name(struct inode * dir, struct dentry *dentry)
400 de = ext2_find_entry (dir, dentry, &page); 399 de = ext2_find_entry (dir, dentry, &page);
401 if (de) { 400 if (de) {
402 res = le32_to_cpu(de->inode); 401 res = le32_to_cpu(de->inode);
403 kunmap(page); 402 ext2_put_page(page);
404 page_cache_release(page);
405 } 403 }
406 return res; 404 return res;
407} 405}
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
index 9f74a62be555..e65a019fc7a5 100644
--- a/fs/ext2/ext2.h
+++ b/fs/ext2/ext2.h
@@ -162,9 +162,9 @@ extern const struct file_operations ext2_file_operations;
162extern const struct file_operations ext2_xip_file_operations; 162extern const struct file_operations ext2_xip_file_operations;
163 163
164/* inode.c */ 164/* inode.c */
165extern struct address_space_operations ext2_aops; 165extern const struct address_space_operations ext2_aops;
166extern struct address_space_operations ext2_aops_xip; 166extern const struct address_space_operations ext2_aops_xip;
167extern struct address_space_operations ext2_nobh_aops; 167extern const struct address_space_operations ext2_nobh_aops;
168 168
169/* namei.c */ 169/* namei.c */
170extern struct inode_operations ext2_dir_inode_operations; 170extern struct inode_operations ext2_dir_inode_operations;
diff --git a/fs/ext2/fsync.c b/fs/ext2/fsync.c
index c9c2e5ffa48e..7806b9e8155b 100644
--- a/fs/ext2/fsync.c
+++ b/fs/ext2/fsync.c
@@ -24,7 +24,7 @@
24 24
25#include "ext2.h" 25#include "ext2.h"
26#include <linux/smp_lock.h> 26#include <linux/smp_lock.h>
27#include <linux/buffer_head.h> /* for fsync_inode_buffers() */ 27#include <linux/buffer_head.h> /* for sync_mapping_buffers() */
28 28
29 29
30/* 30/*
diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c
index e52765219e16..de85c61c58c5 100644
--- a/fs/ext2/ialloc.c
+++ b/fs/ext2/ialloc.c
@@ -12,7 +12,6 @@
12 * David S. Miller (davem@caip.rutgers.edu), 1995 12 * David S. Miller (davem@caip.rutgers.edu), 1995
13 */ 13 */
14 14
15#include <linux/config.h>
16#include <linux/quotaops.h> 15#include <linux/quotaops.h>
17#include <linux/sched.h> 16#include <linux/sched.h>
18#include <linux/backing-dev.h> 17#include <linux/backing-dev.h>
@@ -638,6 +637,7 @@ fail:
638 return ERR_PTR(err); 637 return ERR_PTR(err);
639} 638}
640 639
640/* Superblock must be locked */
641unsigned long ext2_count_free_inodes (struct super_block * sb) 641unsigned long ext2_count_free_inodes (struct super_block * sb)
642{ 642{
643 struct ext2_group_desc *desc; 643 struct ext2_group_desc *desc;
@@ -649,7 +649,6 @@ unsigned long ext2_count_free_inodes (struct super_block * sb)
649 unsigned long bitmap_count = 0; 649 unsigned long bitmap_count = 0;
650 struct buffer_head *bitmap_bh = NULL; 650 struct buffer_head *bitmap_bh = NULL;
651 651
652 lock_super (sb);
653 es = EXT2_SB(sb)->s_es; 652 es = EXT2_SB(sb)->s_es;
654 for (i = 0; i < EXT2_SB(sb)->s_groups_count; i++) { 653 for (i = 0; i < EXT2_SB(sb)->s_groups_count; i++) {
655 unsigned x; 654 unsigned x;
@@ -672,7 +671,6 @@ unsigned long ext2_count_free_inodes (struct super_block * sb)
672 printk("ext2_count_free_inodes: stored = %lu, computed = %lu, %lu\n", 671 printk("ext2_count_free_inodes: stored = %lu, computed = %lu, %lu\n",
673 percpu_counter_read(&EXT2_SB(sb)->s_freeinodes_counter), 672 percpu_counter_read(&EXT2_SB(sb)->s_freeinodes_counter),
674 desc_count, bitmap_count); 673 desc_count, bitmap_count);
675 unlock_super(sb);
676 return desc_count; 674 return desc_count;
677#else 675#else
678 for (i = 0; i < EXT2_SB(sb)->s_groups_count; i++) { 676 for (i = 0; i < EXT2_SB(sb)->s_groups_count; i++) {
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index 04af9c45dce2..fb4d3220eb8d 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -684,7 +684,7 @@ ext2_writepages(struct address_space *mapping, struct writeback_control *wbc)
684 return mpage_writepages(mapping, wbc, ext2_get_block); 684 return mpage_writepages(mapping, wbc, ext2_get_block);
685} 685}
686 686
687struct address_space_operations ext2_aops = { 687const struct address_space_operations ext2_aops = {
688 .readpage = ext2_readpage, 688 .readpage = ext2_readpage,
689 .readpages = ext2_readpages, 689 .readpages = ext2_readpages,
690 .writepage = ext2_writepage, 690 .writepage = ext2_writepage,
@@ -697,12 +697,12 @@ struct address_space_operations ext2_aops = {
697 .migratepage = buffer_migrate_page, 697 .migratepage = buffer_migrate_page,
698}; 698};
699 699
700struct address_space_operations ext2_aops_xip = { 700const struct address_space_operations ext2_aops_xip = {
701 .bmap = ext2_bmap, 701 .bmap = ext2_bmap,
702 .get_xip_page = ext2_get_xip_page, 702 .get_xip_page = ext2_get_xip_page,
703}; 703};
704 704
705struct address_space_operations ext2_nobh_aops = { 705const struct address_space_operations ext2_nobh_aops = {
706 .readpage = ext2_readpage, 706 .readpage = ext2_readpage,
707 .readpages = ext2_readpages, 707 .readpages = ext2_readpages,
708 .writepage = ext2_nobh_writepage, 708 .writepage = ext2_nobh_writepage,
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 7e30bae174ed..9f43879d6d68 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -16,7 +16,6 @@
16 * David S. Miller (davem@caip.rutgers.edu), 1995 16 * David S. Miller (davem@caip.rutgers.edu), 1995
17 */ 17 */
18 18
19#include <linux/config.h>
20#include <linux/module.h> 19#include <linux/module.h>
21#include <linux/string.h> 20#include <linux/string.h>
22#include <linux/fs.h> 21#include <linux/fs.h>
@@ -39,7 +38,7 @@
39static void ext2_sync_super(struct super_block *sb, 38static void ext2_sync_super(struct super_block *sb,
40 struct ext2_super_block *es); 39 struct ext2_super_block *es);
41static int ext2_remount (struct super_block * sb, int * flags, char * data); 40static int ext2_remount (struct super_block * sb, int * flags, char * data);
42static int ext2_statfs (struct super_block * sb, struct kstatfs * buf); 41static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf);
43 42
44void ext2_error (struct super_block * sb, const char * function, 43void ext2_error (struct super_block * sb, const char * function,
45 const char * fmt, ...) 44 const char * fmt, ...)
@@ -834,9 +833,6 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
834 printk ("EXT2-fs: not enough memory\n"); 833 printk ("EXT2-fs: not enough memory\n");
835 goto failed_mount; 834 goto failed_mount;
836 } 835 }
837 percpu_counter_init(&sbi->s_freeblocks_counter);
838 percpu_counter_init(&sbi->s_freeinodes_counter);
839 percpu_counter_init(&sbi->s_dirs_counter);
840 bgl_lock_init(&sbi->s_blockgroup_lock); 836 bgl_lock_init(&sbi->s_blockgroup_lock);
841 sbi->s_debts = kmalloc(sbi->s_groups_count * sizeof(*sbi->s_debts), 837 sbi->s_debts = kmalloc(sbi->s_groups_count * sizeof(*sbi->s_debts),
842 GFP_KERNEL); 838 GFP_KERNEL);
@@ -857,12 +853,18 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
857 } 853 }
858 if (!ext2_check_descriptors (sb)) { 854 if (!ext2_check_descriptors (sb)) {
859 printk ("EXT2-fs: group descriptors corrupted!\n"); 855 printk ("EXT2-fs: group descriptors corrupted!\n");
860 db_count = i;
861 goto failed_mount2; 856 goto failed_mount2;
862 } 857 }
863 sbi->s_gdb_count = db_count; 858 sbi->s_gdb_count = db_count;
864 get_random_bytes(&sbi->s_next_generation, sizeof(u32)); 859 get_random_bytes(&sbi->s_next_generation, sizeof(u32));
865 spin_lock_init(&sbi->s_next_gen_lock); 860 spin_lock_init(&sbi->s_next_gen_lock);
861
862 percpu_counter_init(&sbi->s_freeblocks_counter,
863 ext2_count_free_blocks(sb));
864 percpu_counter_init(&sbi->s_freeinodes_counter,
865 ext2_count_free_inodes(sb));
866 percpu_counter_init(&sbi->s_dirs_counter,
867 ext2_count_dirs(sb));
866 /* 868 /*
867 * set up enough so that it can read an inode 869 * set up enough so that it can read an inode
868 */ 870 */
@@ -874,24 +876,18 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
874 if (!sb->s_root) { 876 if (!sb->s_root) {
875 iput(root); 877 iput(root);
876 printk(KERN_ERR "EXT2-fs: get root inode failed\n"); 878 printk(KERN_ERR "EXT2-fs: get root inode failed\n");
877 goto failed_mount2; 879 goto failed_mount3;
878 } 880 }
879 if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { 881 if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) {
880 dput(sb->s_root); 882 dput(sb->s_root);
881 sb->s_root = NULL; 883 sb->s_root = NULL;
882 printk(KERN_ERR "EXT2-fs: corrupt root inode, run e2fsck\n"); 884 printk(KERN_ERR "EXT2-fs: corrupt root inode, run e2fsck\n");
883 goto failed_mount2; 885 goto failed_mount3;
884 } 886 }
885 if (EXT2_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL)) 887 if (EXT2_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL))
886 ext2_warning(sb, __FUNCTION__, 888 ext2_warning(sb, __FUNCTION__,
887 "mounting ext3 filesystem as ext2"); 889 "mounting ext3 filesystem as ext2");
888 ext2_setup_super (sb, es, sb->s_flags & MS_RDONLY); 890 ext2_setup_super (sb, es, sb->s_flags & MS_RDONLY);
889 percpu_counter_mod(&sbi->s_freeblocks_counter,
890 ext2_count_free_blocks(sb));
891 percpu_counter_mod(&sbi->s_freeinodes_counter,
892 ext2_count_free_inodes(sb));
893 percpu_counter_mod(&sbi->s_dirs_counter,
894 ext2_count_dirs(sb));
895 return 0; 891 return 0;
896 892
897cantfind_ext2: 893cantfind_ext2:
@@ -899,7 +895,10 @@ cantfind_ext2:
899 printk("VFS: Can't find an ext2 filesystem on dev %s.\n", 895 printk("VFS: Can't find an ext2 filesystem on dev %s.\n",
900 sb->s_id); 896 sb->s_id);
901 goto failed_mount; 897 goto failed_mount;
902 898failed_mount3:
899 percpu_counter_destroy(&sbi->s_freeblocks_counter);
900 percpu_counter_destroy(&sbi->s_freeinodes_counter);
901 percpu_counter_destroy(&sbi->s_dirs_counter);
903failed_mount2: 902failed_mount2:
904 for (i = 0; i < db_count; i++) 903 for (i = 0; i < db_count; i++)
905 brelse(sbi->s_group_desc[i]); 904 brelse(sbi->s_group_desc[i]);
@@ -1038,12 +1037,14 @@ restore_opts:
1038 return err; 1037 return err;
1039} 1038}
1040 1039
1041static int ext2_statfs (struct super_block * sb, struct kstatfs * buf) 1040static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf)
1042{ 1041{
1042 struct super_block *sb = dentry->d_sb;
1043 struct ext2_sb_info *sbi = EXT2_SB(sb); 1043 struct ext2_sb_info *sbi = EXT2_SB(sb);
1044 unsigned long overhead; 1044 unsigned long overhead;
1045 int i; 1045 int i;
1046 1046
1047 lock_super(sb);
1047 if (test_opt (sb, MINIX_DF)) 1048 if (test_opt (sb, MINIX_DF))
1048 overhead = 0; 1049 overhead = 0;
1049 else { 1050 else {
@@ -1084,13 +1085,14 @@ static int ext2_statfs (struct super_block * sb, struct kstatfs * buf)
1084 buf->f_files = le32_to_cpu(sbi->s_es->s_inodes_count); 1085 buf->f_files = le32_to_cpu(sbi->s_es->s_inodes_count);
1085 buf->f_ffree = ext2_count_free_inodes (sb); 1086 buf->f_ffree = ext2_count_free_inodes (sb);
1086 buf->f_namelen = EXT2_NAME_LEN; 1087 buf->f_namelen = EXT2_NAME_LEN;
1088 unlock_super(sb);
1087 return 0; 1089 return 0;
1088} 1090}
1089 1091
1090static struct super_block *ext2_get_sb(struct file_system_type *fs_type, 1092static int ext2_get_sb(struct file_system_type *fs_type,
1091 int flags, const char *dev_name, void *data) 1093 int flags, const char *dev_name, void *data, struct vfsmount *mnt)
1092{ 1094{
1093 return get_sb_bdev(fs_type, flags, dev_name, data, ext2_fill_super); 1095 return get_sb_bdev(fs_type, flags, dev_name, data, ext2_fill_super, mnt);
1094} 1096}
1095 1097
1096#ifdef CONFIG_QUOTA 1098#ifdef CONFIG_QUOTA
diff --git a/fs/ext2/xattr.h b/fs/ext2/xattr.h
index 67cfeb66e897..bf8175b2ced9 100644
--- a/fs/ext2/xattr.h
+++ b/fs/ext2/xattr.h
@@ -6,7 +6,6 @@
6 (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org> 6 (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
7*/ 7*/
8 8
9#include <linux/config.h>
10#include <linux/init.h> 9#include <linux/init.h>
11#include <linux/xattr.h> 10#include <linux/xattr.h>
12 11