diff options
Diffstat (limited to 'fs/ext2')
-rw-r--r-- | fs/ext2/Makefile | 2 | ||||
-rw-r--r-- | fs/ext2/balloc.c | 22 | ||||
-rw-r--r-- | fs/ext2/bitmap.c | 32 | ||||
-rw-r--r-- | fs/ext2/dir.c | 6 | ||||
-rw-r--r-- | fs/ext2/ext2.h | 6 | ||||
-rw-r--r-- | fs/ext2/fsync.c | 2 | ||||
-rw-r--r-- | fs/ext2/ialloc.c | 3 | ||||
-rw-r--r-- | fs/ext2/inode.c | 6 | ||||
-rw-r--r-- | fs/ext2/super.c | 39 |
9 files changed, 52 insertions, 66 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 | ||
5 | obj-$(CONFIG_EXT2_FS) += ext2.o | 5 | obj-$(CONFIG_EXT2_FS) += ext2.o |
6 | 6 | ||
7 | ext2-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \ | 7 | ext2-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 | ||
10 | ext2-$(CONFIG_EXT2_FS_XATTR) += xattr.o xattr_user.o xattr_trusted.o | 10 | 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 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 | |||
526 | static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0}; | ||
527 | |||
528 | unsigned 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 */ | ||
524 | unsigned long ext2_count_free_blocks (struct super_block * sb) | 544 | unsigned 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 | |||
16 | static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0}; | ||
17 | |||
18 | unsigned 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: | |||
159 | static struct page * ext2_get_page(struct inode *dir, unsigned long n) | 159 | static 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; | |||
162 | extern const struct file_operations ext2_xip_file_operations; | 162 | extern const struct file_operations ext2_xip_file_operations; |
163 | 163 | ||
164 | /* inode.c */ | 164 | /* inode.c */ |
165 | extern struct address_space_operations ext2_aops; | 165 | extern const struct address_space_operations ext2_aops; |
166 | extern struct address_space_operations ext2_aops_xip; | 166 | extern const struct address_space_operations ext2_aops_xip; |
167 | extern struct address_space_operations ext2_nobh_aops; | 167 | extern const struct address_space_operations ext2_nobh_aops; |
168 | 168 | ||
169 | /* namei.c */ | 169 | /* namei.c */ |
170 | extern struct inode_operations ext2_dir_inode_operations; | 170 | extern 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..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 */ | ||
641 | unsigned long ext2_count_free_inodes (struct super_block * sb) | 642 | unsigned 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/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 | ||
687 | struct address_space_operations ext2_aops = { | 687 | const 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 | ||
700 | struct address_space_operations ext2_aops_xip = { | 700 | const 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 | ||
705 | struct address_space_operations ext2_nobh_aops = { | 705 | const 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..d4233b2e6436 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c | |||
@@ -39,7 +39,7 @@ | |||
39 | static void ext2_sync_super(struct super_block *sb, | 39 | static void ext2_sync_super(struct super_block *sb, |
40 | struct ext2_super_block *es); | 40 | struct ext2_super_block *es); |
41 | static int ext2_remount (struct super_block * sb, int * flags, char * data); | 41 | static int ext2_remount (struct super_block * sb, int * flags, char * data); |
42 | static int ext2_statfs (struct super_block * sb, struct kstatfs * buf); | 42 | static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf); |
43 | 43 | ||
44 | void ext2_error (struct super_block * sb, const char * function, | 44 | void ext2_error (struct super_block * sb, const char * function, |
45 | const char * fmt, ...) | 45 | const char * fmt, ...) |
@@ -834,9 +834,6 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
834 | printk ("EXT2-fs: not enough memory\n"); | 834 | printk ("EXT2-fs: not enough memory\n"); |
835 | goto failed_mount; | 835 | goto failed_mount; |
836 | } | 836 | } |
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); | 837 | bgl_lock_init(&sbi->s_blockgroup_lock); |
841 | sbi->s_debts = kmalloc(sbi->s_groups_count * sizeof(*sbi->s_debts), | 838 | sbi->s_debts = kmalloc(sbi->s_groups_count * sizeof(*sbi->s_debts), |
842 | GFP_KERNEL); | 839 | GFP_KERNEL); |
@@ -857,12 +854,18 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
857 | } | 854 | } |
858 | if (!ext2_check_descriptors (sb)) { | 855 | if (!ext2_check_descriptors (sb)) { |
859 | printk ("EXT2-fs: group descriptors corrupted!\n"); | 856 | printk ("EXT2-fs: group descriptors corrupted!\n"); |
860 | db_count = i; | ||
861 | goto failed_mount2; | 857 | goto failed_mount2; |
862 | } | 858 | } |
863 | sbi->s_gdb_count = db_count; | 859 | sbi->s_gdb_count = db_count; |
864 | get_random_bytes(&sbi->s_next_generation, sizeof(u32)); | 860 | get_random_bytes(&sbi->s_next_generation, sizeof(u32)); |
865 | spin_lock_init(&sbi->s_next_gen_lock); | 861 | spin_lock_init(&sbi->s_next_gen_lock); |
862 | |||
863 | percpu_counter_init(&sbi->s_freeblocks_counter, | ||
864 | ext2_count_free_blocks(sb)); | ||
865 | percpu_counter_init(&sbi->s_freeinodes_counter, | ||
866 | ext2_count_free_inodes(sb)); | ||
867 | percpu_counter_init(&sbi->s_dirs_counter, | ||
868 | ext2_count_dirs(sb)); | ||
866 | /* | 869 | /* |
867 | * set up enough so that it can read an inode | 870 | * set up enough so that it can read an inode |
868 | */ | 871 | */ |
@@ -874,24 +877,18 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
874 | if (!sb->s_root) { | 877 | if (!sb->s_root) { |
875 | iput(root); | 878 | iput(root); |
876 | printk(KERN_ERR "EXT2-fs: get root inode failed\n"); | 879 | printk(KERN_ERR "EXT2-fs: get root inode failed\n"); |
877 | goto failed_mount2; | 880 | goto failed_mount3; |
878 | } | 881 | } |
879 | if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { | 882 | if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { |
880 | dput(sb->s_root); | 883 | dput(sb->s_root); |
881 | sb->s_root = NULL; | 884 | sb->s_root = NULL; |
882 | printk(KERN_ERR "EXT2-fs: corrupt root inode, run e2fsck\n"); | 885 | printk(KERN_ERR "EXT2-fs: corrupt root inode, run e2fsck\n"); |
883 | goto failed_mount2; | 886 | goto failed_mount3; |
884 | } | 887 | } |
885 | if (EXT2_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL)) | 888 | if (EXT2_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL)) |
886 | ext2_warning(sb, __FUNCTION__, | 889 | ext2_warning(sb, __FUNCTION__, |
887 | "mounting ext3 filesystem as ext2"); | 890 | "mounting ext3 filesystem as ext2"); |
888 | ext2_setup_super (sb, es, sb->s_flags & MS_RDONLY); | 891 | 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; | 892 | return 0; |
896 | 893 | ||
897 | cantfind_ext2: | 894 | cantfind_ext2: |
@@ -899,7 +896,10 @@ cantfind_ext2: | |||
899 | printk("VFS: Can't find an ext2 filesystem on dev %s.\n", | 896 | printk("VFS: Can't find an ext2 filesystem on dev %s.\n", |
900 | sb->s_id); | 897 | sb->s_id); |
901 | goto failed_mount; | 898 | goto failed_mount; |
902 | 899 | failed_mount3: | |
900 | percpu_counter_destroy(&sbi->s_freeblocks_counter); | ||
901 | percpu_counter_destroy(&sbi->s_freeinodes_counter); | ||
902 | percpu_counter_destroy(&sbi->s_dirs_counter); | ||
903 | failed_mount2: | 903 | failed_mount2: |
904 | for (i = 0; i < db_count; i++) | 904 | for (i = 0; i < db_count; i++) |
905 | brelse(sbi->s_group_desc[i]); | 905 | brelse(sbi->s_group_desc[i]); |
@@ -1038,12 +1038,14 @@ restore_opts: | |||
1038 | return err; | 1038 | return err; |
1039 | } | 1039 | } |
1040 | 1040 | ||
1041 | static int ext2_statfs (struct super_block * sb, struct kstatfs * buf) | 1041 | static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf) |
1042 | { | 1042 | { |
1043 | struct super_block *sb = dentry->d_sb; | ||
1043 | struct ext2_sb_info *sbi = EXT2_SB(sb); | 1044 | struct ext2_sb_info *sbi = EXT2_SB(sb); |
1044 | unsigned long overhead; | 1045 | unsigned long overhead; |
1045 | int i; | 1046 | int i; |
1046 | 1047 | ||
1048 | lock_super(sb); | ||
1047 | if (test_opt (sb, MINIX_DF)) | 1049 | if (test_opt (sb, MINIX_DF)) |
1048 | overhead = 0; | 1050 | overhead = 0; |
1049 | else { | 1051 | else { |
@@ -1084,13 +1086,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); | 1086 | buf->f_files = le32_to_cpu(sbi->s_es->s_inodes_count); |
1085 | buf->f_ffree = ext2_count_free_inodes (sb); | 1087 | buf->f_ffree = ext2_count_free_inodes (sb); |
1086 | buf->f_namelen = EXT2_NAME_LEN; | 1088 | buf->f_namelen = EXT2_NAME_LEN; |
1089 | unlock_super(sb); | ||
1087 | return 0; | 1090 | return 0; |
1088 | } | 1091 | } |
1089 | 1092 | ||
1090 | static struct super_block *ext2_get_sb(struct file_system_type *fs_type, | 1093 | static int ext2_get_sb(struct file_system_type *fs_type, |
1091 | int flags, const char *dev_name, void *data) | 1094 | int flags, const char *dev_name, void *data, struct vfsmount *mnt) |
1092 | { | 1095 | { |
1093 | return get_sb_bdev(fs_type, flags, dev_name, data, ext2_fill_super); | 1096 | return get_sb_bdev(fs_type, flags, dev_name, data, ext2_fill_super, mnt); |
1094 | } | 1097 | } |
1095 | 1098 | ||
1096 | #ifdef CONFIG_QUOTA | 1099 | #ifdef CONFIG_QUOTA |