aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/super.c117
1 files changed, 61 insertions, 56 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 91b98b58ccb9..0a97b1ad3e19 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -79,7 +79,7 @@ ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,
79{ 79{
80 return le32_to_cpu(bg->bg_block_bitmap_lo) | 80 return le32_to_cpu(bg->bg_block_bitmap_lo) |
81 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? 81 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ?
82 (ext4_fsblk_t)le32_to_cpu(bg->bg_block_bitmap_hi) << 32 : 0); 82 (ext4_fsblk_t)le32_to_cpu(bg->bg_block_bitmap_hi) << 32 : 0);
83} 83}
84 84
85ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb, 85ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb,
@@ -87,7 +87,7 @@ ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb,
87{ 87{
88 return le32_to_cpu(bg->bg_inode_bitmap_lo) | 88 return le32_to_cpu(bg->bg_inode_bitmap_lo) |
89 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? 89 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ?
90 (ext4_fsblk_t)le32_to_cpu(bg->bg_inode_bitmap_hi) << 32 : 0); 90 (ext4_fsblk_t)le32_to_cpu(bg->bg_inode_bitmap_hi) << 32 : 0);
91} 91}
92 92
93ext4_fsblk_t ext4_inode_table(struct super_block *sb, 93ext4_fsblk_t ext4_inode_table(struct super_block *sb,
@@ -95,7 +95,7 @@ ext4_fsblk_t ext4_inode_table(struct super_block *sb,
95{ 95{
96 return le32_to_cpu(bg->bg_inode_table_lo) | 96 return le32_to_cpu(bg->bg_inode_table_lo) |
97 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? 97 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ?
98 (ext4_fsblk_t)le32_to_cpu(bg->bg_inode_table_hi) << 32 : 0); 98 (ext4_fsblk_t)le32_to_cpu(bg->bg_inode_table_hi) << 32 : 0);
99} 99}
100 100
101__u32 ext4_free_blks_count(struct super_block *sb, 101__u32 ext4_free_blks_count(struct super_block *sb,
@@ -103,7 +103,7 @@ __u32 ext4_free_blks_count(struct super_block *sb,
103{ 103{
104 return le16_to_cpu(bg->bg_free_blocks_count_lo) | 104 return le16_to_cpu(bg->bg_free_blocks_count_lo) |
105 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? 105 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ?
106 (__u32)le16_to_cpu(bg->bg_free_blocks_count_hi) << 16 : 0); 106 (__u32)le16_to_cpu(bg->bg_free_blocks_count_hi) << 16 : 0);
107} 107}
108 108
109__u32 ext4_free_inodes_count(struct super_block *sb, 109__u32 ext4_free_inodes_count(struct super_block *sb,
@@ -111,7 +111,7 @@ __u32 ext4_free_inodes_count(struct super_block *sb,
111{ 111{
112 return le16_to_cpu(bg->bg_free_inodes_count_lo) | 112 return le16_to_cpu(bg->bg_free_inodes_count_lo) |
113 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? 113 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ?
114 (__u32)le16_to_cpu(bg->bg_free_inodes_count_hi) << 16 : 0); 114 (__u32)le16_to_cpu(bg->bg_free_inodes_count_hi) << 16 : 0);
115} 115}
116 116
117__u32 ext4_used_dirs_count(struct super_block *sb, 117__u32 ext4_used_dirs_count(struct super_block *sb,
@@ -119,7 +119,7 @@ __u32 ext4_used_dirs_count(struct super_block *sb,
119{ 119{
120 return le16_to_cpu(bg->bg_used_dirs_count_lo) | 120 return le16_to_cpu(bg->bg_used_dirs_count_lo) |
121 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? 121 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ?
122 (__u32)le16_to_cpu(bg->bg_used_dirs_count_hi) << 16 : 0); 122 (__u32)le16_to_cpu(bg->bg_used_dirs_count_hi) << 16 : 0);
123} 123}
124 124
125__u32 ext4_itable_unused_count(struct super_block *sb, 125__u32 ext4_itable_unused_count(struct super_block *sb,
@@ -127,7 +127,7 @@ __u32 ext4_itable_unused_count(struct super_block *sb,
127{ 127{
128 return le16_to_cpu(bg->bg_itable_unused_lo) | 128 return le16_to_cpu(bg->bg_itable_unused_lo) |
129 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? 129 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ?
130 (__u32)le16_to_cpu(bg->bg_itable_unused_hi) << 16 : 0); 130 (__u32)le16_to_cpu(bg->bg_itable_unused_hi) << 16 : 0);
131} 131}
132 132
133void ext4_block_bitmap_set(struct super_block *sb, 133void ext4_block_bitmap_set(struct super_block *sb,
@@ -207,8 +207,7 @@ handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks)
207 journal = EXT4_SB(sb)->s_journal; 207 journal = EXT4_SB(sb)->s_journal;
208 if (journal) { 208 if (journal) {
209 if (is_journal_aborted(journal)) { 209 if (is_journal_aborted(journal)) {
210 ext4_abort(sb, __func__, 210 ext4_abort(sb, __func__, "Detected aborted journal");
211 "Detected aborted journal");
212 return ERR_PTR(-EROFS); 211 return ERR_PTR(-EROFS);
213 } 212 }
214 return jbd2_journal_start(journal, nblocks); 213 return jbd2_journal_start(journal, nblocks);
@@ -436,7 +435,7 @@ void ext4_warning(struct super_block *sb, const char *function,
436} 435}
437 436
438void ext4_grp_locked_error(struct super_block *sb, ext4_group_t grp, 437void ext4_grp_locked_error(struct super_block *sb, ext4_group_t grp,
439 const char *function, const char *fmt, ...) 438 const char *function, const char *fmt, ...)
440__releases(bitlock) 439__releases(bitlock)
441__acquires(bitlock) 440__acquires(bitlock)
442{ 441{
@@ -472,7 +471,6 @@ __acquires(bitlock)
472 return; 471 return;
473} 472}
474 473
475
476void ext4_update_dynamic_rev(struct super_block *sb) 474void ext4_update_dynamic_rev(struct super_block *sb)
477{ 475{
478 struct ext4_super_block *es = EXT4_SB(sb)->s_es; 476 struct ext4_super_block *es = EXT4_SB(sb)->s_es;
@@ -638,7 +636,6 @@ static void ext4_put_super(struct super_block *sb)
638 lock_kernel(); 636 lock_kernel();
639 kfree(sbi->s_blockgroup_lock); 637 kfree(sbi->s_blockgroup_lock);
640 kfree(sbi); 638 kfree(sbi);
641 return;
642} 639}
643 640
644static struct kmem_cache *ext4_inode_cachep; 641static struct kmem_cache *ext4_inode_cachep;
@@ -653,6 +650,7 @@ static struct inode *ext4_alloc_inode(struct super_block *sb)
653 ei = kmem_cache_alloc(ext4_inode_cachep, GFP_NOFS); 650 ei = kmem_cache_alloc(ext4_inode_cachep, GFP_NOFS);
654 if (!ei) 651 if (!ei)
655 return NULL; 652 return NULL;
653
656#ifdef CONFIG_EXT4_FS_POSIX_ACL 654#ifdef CONFIG_EXT4_FS_POSIX_ACL
657 ei->i_acl = EXT4_ACL_NOT_CACHED; 655 ei->i_acl = EXT4_ACL_NOT_CACHED;
658 ei->i_default_acl = EXT4_ACL_NOT_CACHED; 656 ei->i_default_acl = EXT4_ACL_NOT_CACHED;
@@ -673,6 +671,7 @@ static struct inode *ext4_alloc_inode(struct super_block *sb)
673 ei->i_allocated_meta_blocks = 0; 671 ei->i_allocated_meta_blocks = 0;
674 ei->i_delalloc_reserved_flag = 0; 672 ei->i_delalloc_reserved_flag = 0;
675 spin_lock_init(&(ei->i_block_reservation_lock)); 673 spin_lock_init(&(ei->i_block_reservation_lock));
674
676 return &ei->vfs_inode; 675 return &ei->vfs_inode;
677} 676}
678 677
@@ -879,12 +878,12 @@ static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs)
879 seq_puts(seq, ",noauto_da_alloc"); 878 seq_puts(seq, ",noauto_da_alloc");
880 879
881 ext4_show_quota_options(seq, sb); 880 ext4_show_quota_options(seq, sb);
881
882 return 0; 882 return 0;
883} 883}
884 884
885
886static struct inode *ext4_nfs_get_inode(struct super_block *sb, 885static struct inode *ext4_nfs_get_inode(struct super_block *sb,
887 u64 ino, u32 generation) 886 u64 ino, u32 generation)
888{ 887{
889 struct inode *inode; 888 struct inode *inode;
890 889
@@ -913,14 +912,14 @@ static struct inode *ext4_nfs_get_inode(struct super_block *sb,
913} 912}
914 913
915static struct dentry *ext4_fh_to_dentry(struct super_block *sb, struct fid *fid, 914static struct dentry *ext4_fh_to_dentry(struct super_block *sb, struct fid *fid,
916 int fh_len, int fh_type) 915 int fh_len, int fh_type)
917{ 916{
918 return generic_fh_to_dentry(sb, fid, fh_len, fh_type, 917 return generic_fh_to_dentry(sb, fid, fh_len, fh_type,
919 ext4_nfs_get_inode); 918 ext4_nfs_get_inode);
920} 919}
921 920
922static struct dentry *ext4_fh_to_parent(struct super_block *sb, struct fid *fid, 921static struct dentry *ext4_fh_to_parent(struct super_block *sb, struct fid *fid,
923 int fh_len, int fh_type) 922 int fh_len, int fh_type)
924{ 923{
925 return generic_fh_to_parent(sb, fid, fh_len, fh_type, 924 return generic_fh_to_parent(sb, fid, fh_len, fh_type,
926 ext4_nfs_get_inode); 925 ext4_nfs_get_inode);
@@ -932,7 +931,8 @@ static struct dentry *ext4_fh_to_parent(struct super_block *sb, struct fid *fid,
932 * which would prevent try_to_free_buffers() from freeing them, we must use 931 * which would prevent try_to_free_buffers() from freeing them, we must use
933 * jbd2 layer's try_to_free_buffers() function to release them. 932 * jbd2 layer's try_to_free_buffers() function to release them.
934 */ 933 */
935static int bdev_try_to_free_page(struct super_block *sb, struct page *page, gfp_t wait) 934static int bdev_try_to_free_page(struct super_block *sb, struct page *page,
935 gfp_t wait)
936{ 936{
937 journal_t *journal = EXT4_SB(sb)->s_journal; 937 journal_t *journal = EXT4_SB(sb)->s_journal;
938 938
@@ -1133,8 +1133,9 @@ static ext4_fsblk_t get_sb_block(void **data)
1133 1133
1134 if (!options || strncmp(options, "sb=", 3) != 0) 1134 if (!options || strncmp(options, "sb=", 3) != 0)
1135 return 1; /* Default location */ 1135 return 1; /* Default location */
1136
1136 options += 3; 1137 options += 3;
1137 /*todo: use simple_strtoll with >32bit ext4 */ 1138 /* TODO: use simple_strtoll with >32bit ext4 */
1138 sb_block = simple_strtoul(options, &options, 0); 1139 sb_block = simple_strtoul(options, &options, 0);
1139 if (*options && *options != ',') { 1140 if (*options && *options != ',') {
1140 printk(KERN_ERR "EXT4-fs: Invalid sb specification: %s\n", 1141 printk(KERN_ERR "EXT4-fs: Invalid sb specification: %s\n",
@@ -1144,6 +1145,7 @@ static ext4_fsblk_t get_sb_block(void **data)
1144 if (*options == ',') 1145 if (*options == ',')
1145 options++; 1146 options++;
1146 *data = (void *) options; 1147 *data = (void *) options;
1148
1147 return sb_block; 1149 return sb_block;
1148} 1150}
1149 1151
@@ -1626,7 +1628,7 @@ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es,
1626 printk(KERN_WARNING 1628 printk(KERN_WARNING
1627 "EXT4-fs warning: checktime reached, " 1629 "EXT4-fs warning: checktime reached, "
1628 "running e2fsck is recommended\n"); 1630 "running e2fsck is recommended\n");
1629 if (!sbi->s_journal) 1631 if (!sbi->s_journal)
1630 es->s_state &= cpu_to_le16(~EXT4_VALID_FS); 1632 es->s_state &= cpu_to_le16(~EXT4_VALID_FS);
1631 if (!(__s16) le16_to_cpu(es->s_max_mnt_count)) 1633 if (!(__s16) le16_to_cpu(es->s_max_mnt_count))
1632 es->s_max_mnt_count = cpu_to_le16(EXT4_DFL_MAX_MNT_COUNT); 1634 es->s_max_mnt_count = cpu_to_le16(EXT4_DFL_MAX_MNT_COUNT);
@@ -1810,7 +1812,7 @@ static int ext4_check_descriptors(struct super_block *sb)
1810 } 1812 }
1811 1813
1812 ext4_free_blocks_count_set(sbi->s_es, ext4_count_free_blocks(sb)); 1814 ext4_free_blocks_count_set(sbi->s_es, ext4_count_free_blocks(sb));
1813 sbi->s_es->s_free_inodes_count = cpu_to_le32(ext4_count_free_inodes(sb)); 1815 sbi->s_es->s_free_inodes_count =cpu_to_le32(ext4_count_free_inodes(sb));
1814 return 1; 1816 return 1;
1815} 1817}
1816 1818
@@ -1926,6 +1928,7 @@ static void ext4_orphan_cleanup(struct super_block *sb,
1926#endif 1928#endif
1927 sb->s_flags = s_flags; /* Restore MS_RDONLY status */ 1929 sb->s_flags = s_flags; /* Restore MS_RDONLY status */
1928} 1930}
1931
1929/* 1932/*
1930 * Maximal extent format file size. 1933 * Maximal extent format file size.
1931 * Resulting logical blkno at s_maxbytes must fit in our on-disk 1934 * Resulting logical blkno at s_maxbytes must fit in our on-disk
@@ -1976,19 +1979,19 @@ static loff_t ext4_max_bitmap_size(int bits, int has_huge_files)
1976 loff_t res = EXT4_NDIR_BLOCKS; 1979 loff_t res = EXT4_NDIR_BLOCKS;
1977 int meta_blocks; 1980 int meta_blocks;
1978 loff_t upper_limit; 1981 loff_t upper_limit;
1979 /* This is calculated to be the largest file size for a 1982 /* This is calculated to be the largest file size for a dense, block
1980 * dense, bitmapped file such that the total number of 1983 * mapped file such that the file's total number of 512-byte sectors,
1981 * sectors in the file, including data and all indirect blocks, 1984 * including data and all indirect blocks, does not exceed (2^48 - 1).
1982 * does not exceed 2^48 -1 1985 *
1983 * __u32 i_blocks_lo and _u16 i_blocks_high representing the 1986 * __u32 i_blocks_lo and _u16 i_blocks_high represent the total
1984 * total number of 512 bytes blocks of the file 1987 * number of 512-byte sectors of the file.
1985 */ 1988 */
1986 1989
1987 if (!has_huge_files || sizeof(blkcnt_t) < sizeof(u64)) { 1990 if (!has_huge_files || sizeof(blkcnt_t) < sizeof(u64)) {
1988 /* 1991 /*
1989 * !has_huge_files or CONFIG_LBD is not enabled 1992 * !has_huge_files or CONFIG_LBD not enabled implies that
1990 * implies the inode i_block represent total blocks in 1993 * the inode i_block field represents total file blocks in
1991 * 512 bytes 32 == size of vfs inode i_blocks * 8 1994 * 2^32 512-byte sectors == size of vfs inode i_blocks * 8
1992 */ 1995 */
1993 upper_limit = (1LL << 32) - 1; 1996 upper_limit = (1LL << 32) - 1;
1994 1997
@@ -2030,7 +2033,7 @@ static loff_t ext4_max_bitmap_size(int bits, int has_huge_files)
2030} 2033}
2031 2034
2032static ext4_fsblk_t descriptor_loc(struct super_block *sb, 2035static ext4_fsblk_t descriptor_loc(struct super_block *sb,
2033 ext4_fsblk_t logical_sb_block, int nr) 2036 ext4_fsblk_t logical_sb_block, int nr)
2034{ 2037{
2035 struct ext4_sb_info *sbi = EXT4_SB(sb); 2038 struct ext4_sb_info *sbi = EXT4_SB(sb);
2036 ext4_group_t bg, first_meta_bg; 2039 ext4_group_t bg, first_meta_bg;
@@ -2044,6 +2047,7 @@ static ext4_fsblk_t descriptor_loc(struct super_block *sb,
2044 bg = sbi->s_desc_per_block * nr; 2047 bg = sbi->s_desc_per_block * nr;
2045 if (ext4_bg_has_super(sb, bg)) 2048 if (ext4_bg_has_super(sb, bg))
2046 has_super = 1; 2049 has_super = 1;
2050
2047 return (has_super + ext4_group_first_block_no(sb, bg)); 2051 return (has_super + ext4_group_first_block_no(sb, bg));
2048} 2052}
2049 2053
@@ -2148,7 +2152,7 @@ static ssize_t inode_readahead_blks_store(struct ext4_attr *a,
2148} 2152}
2149 2153
2150static ssize_t sbi_ui_show(struct ext4_attr *a, 2154static ssize_t sbi_ui_show(struct ext4_attr *a,
2151 struct ext4_sb_info *sbi, char *buf) 2155 struct ext4_sb_info *sbi, char *buf)
2152{ 2156{
2153 unsigned int *ui = (unsigned int *) (((char *) sbi) + a->offset); 2157 unsigned int *ui = (unsigned int *) (((char *) sbi) + a->offset);
2154 2158
@@ -2253,7 +2257,6 @@ static struct kobj_type ext4_ktype = {
2253static int ext4_fill_super(struct super_block *sb, void *data, int silent) 2257static int ext4_fill_super(struct super_block *sb, void *data, int silent)
2254 __releases(kernel_lock) 2258 __releases(kernel_lock)
2255 __acquires(kernel_lock) 2259 __acquires(kernel_lock)
2256
2257{ 2260{
2258 struct buffer_head *bh; 2261 struct buffer_head *bh;
2259 struct ext4_super_block *es = NULL; 2262 struct ext4_super_block *es = NULL;
@@ -2379,7 +2382,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
2379 */ 2382 */
2380 set_opt(sbi->s_mount_opt, DELALLOC); 2383 set_opt(sbi->s_mount_opt, DELALLOC);
2381 2384
2382
2383 if (!parse_options((char *) data, sb, &journal_devnum, 2385 if (!parse_options((char *) data, sb, &journal_devnum,
2384 &journal_ioprio, NULL, 0)) 2386 &journal_ioprio, NULL, 0))
2385 goto failed_mount; 2387 goto failed_mount;
@@ -2442,7 +2444,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
2442 } 2444 }
2443 2445
2444 if (sb->s_blocksize != blocksize) { 2446 if (sb->s_blocksize != blocksize) {
2445
2446 /* Validate the filesystem blocksize */ 2447 /* Validate the filesystem blocksize */
2447 if (!sb_set_blocksize(sb, blocksize)) { 2448 if (!sb_set_blocksize(sb, blocksize)) {
2448 printk(KERN_ERR "EXT4-fs: bad block size %d.\n", 2449 printk(KERN_ERR "EXT4-fs: bad block size %d.\n",
@@ -2489,6 +2490,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
2489 if (sbi->s_inode_size > EXT4_GOOD_OLD_INODE_SIZE) 2490 if (sbi->s_inode_size > EXT4_GOOD_OLD_INODE_SIZE)
2490 sb->s_time_gran = 1 << (EXT4_EPOCH_BITS - 2); 2491 sb->s_time_gran = 1 << (EXT4_EPOCH_BITS - 2);
2491 } 2492 }
2493
2492 sbi->s_desc_size = le16_to_cpu(es->s_desc_size); 2494 sbi->s_desc_size = le16_to_cpu(es->s_desc_size);
2493 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_64BIT)) { 2495 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_64BIT)) {
2494 if (sbi->s_desc_size < EXT4_MIN_DESC_SIZE_64BIT || 2496 if (sbi->s_desc_size < EXT4_MIN_DESC_SIZE_64BIT ||
@@ -2501,10 +2503,12 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
2501 } 2503 }
2502 } else 2504 } else
2503 sbi->s_desc_size = EXT4_MIN_DESC_SIZE; 2505 sbi->s_desc_size = EXT4_MIN_DESC_SIZE;
2506
2504 sbi->s_blocks_per_group = le32_to_cpu(es->s_blocks_per_group); 2507 sbi->s_blocks_per_group = le32_to_cpu(es->s_blocks_per_group);
2505 sbi->s_inodes_per_group = le32_to_cpu(es->s_inodes_per_group); 2508 sbi->s_inodes_per_group = le32_to_cpu(es->s_inodes_per_group);
2506 if (EXT4_INODE_SIZE(sb) == 0 || EXT4_INODES_PER_GROUP(sb) == 0) 2509 if (EXT4_INODE_SIZE(sb) == 0 || EXT4_INODES_PER_GROUP(sb) == 0)
2507 goto cantfind_ext4; 2510 goto cantfind_ext4;
2511
2508 sbi->s_inodes_per_block = blocksize / EXT4_INODE_SIZE(sb); 2512 sbi->s_inodes_per_block = blocksize / EXT4_INODE_SIZE(sb);
2509 if (sbi->s_inodes_per_block == 0) 2513 if (sbi->s_inodes_per_block == 0)
2510 goto cantfind_ext4; 2514 goto cantfind_ext4;
@@ -2515,6 +2519,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
2515 sbi->s_mount_state = le16_to_cpu(es->s_state); 2519 sbi->s_mount_state = le16_to_cpu(es->s_state);
2516 sbi->s_addr_per_block_bits = ilog2(EXT4_ADDR_PER_BLOCK(sb)); 2520 sbi->s_addr_per_block_bits = ilog2(EXT4_ADDR_PER_BLOCK(sb));
2517 sbi->s_desc_per_block_bits = ilog2(EXT4_DESC_PER_BLOCK(sb)); 2521 sbi->s_desc_per_block_bits = ilog2(EXT4_DESC_PER_BLOCK(sb));
2522
2518 for (i = 0; i < 4; i++) 2523 for (i = 0; i < 4; i++)
2519 sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]); 2524 sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]);
2520 sbi->s_def_hash_version = es->s_def_hash_version; 2525 sbi->s_def_hash_version = es->s_def_hash_version;
@@ -2566,12 +2571,12 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
2566 goto failed_mount; 2571 goto failed_mount;
2567 } 2572 }
2568 2573
2569 /* 2574 /*
2570 * It makes no sense for the first data block to be beyond the end 2575 * It makes no sense for the first data block to be beyond the end
2571 * of the filesystem. 2576 * of the filesystem.
2572 */ 2577 */
2573 if (le32_to_cpu(es->s_first_data_block) >= ext4_blocks_count(es)) { 2578 if (le32_to_cpu(es->s_first_data_block) >= ext4_blocks_count(es)) {
2574 printk(KERN_WARNING "EXT4-fs: bad geometry: first data" 2579 printk(KERN_WARNING "EXT4-fs: bad geometry: first data"
2575 "block %u is beyond end of filesystem (%llu)\n", 2580 "block %u is beyond end of filesystem (%llu)\n",
2576 le32_to_cpu(es->s_first_data_block), 2581 le32_to_cpu(es->s_first_data_block),
2577 ext4_blocks_count(es)); 2582 ext4_blocks_count(es));
@@ -3082,6 +3087,7 @@ static journal_t *ext4_get_dev_journal(struct super_block *sb,
3082 EXT4_SB(sb)->journal_bdev = bdev; 3087 EXT4_SB(sb)->journal_bdev = bdev;
3083 ext4_init_journal_params(sb, journal); 3088 ext4_init_journal_params(sb, journal);
3084 return journal; 3089 return journal;
3090
3085out_journal: 3091out_journal:
3086 jbd2_journal_destroy(journal); 3092 jbd2_journal_destroy(journal);
3087out_bdev: 3093out_bdev:
@@ -3116,7 +3122,6 @@ static int ext4_load_journal(struct super_block *sb,
3116 * crash? For recovery, we need to check in advance whether we 3122 * crash? For recovery, we need to check in advance whether we
3117 * can get read-write access to the device. 3123 * can get read-write access to the device.
3118 */ 3124 */
3119
3120 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER)) { 3125 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER)) {
3121 if (sb->s_flags & MS_RDONLY) { 3126 if (sb->s_flags & MS_RDONLY) {
3122 printk(KERN_INFO "EXT4-fs: INFO: recovery " 3127 printk(KERN_INFO "EXT4-fs: INFO: recovery "
@@ -3234,7 +3239,6 @@ static int ext4_commit_super(struct super_block *sb, int sync)
3234 return error; 3239 return error;
3235} 3240}
3236 3241
3237
3238/* 3242/*
3239 * Have we just finished recovery? If so, and if we are mounting (or 3243 * Have we just finished recovery? If so, and if we are mounting (or
3240 * remounting) the filesystem readonly, then we will end up with a 3244 * remounting) the filesystem readonly, then we will end up with a
@@ -3485,8 +3489,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
3485 3489
3486 /* 3490 /*
3487 * Make sure the group descriptor checksums 3491 * Make sure the group descriptor checksums
3488 * are sane. If they aren't, refuse to 3492 * are sane. If they aren't, refuse to remount r/w.
3489 * remount r/w.
3490 */ 3493 */
3491 for (g = 0; g < sbi->s_groups_count; g++) { 3494 for (g = 0; g < sbi->s_groups_count; g++) {
3492 struct ext4_group_desc *gdp = 3495 struct ext4_group_desc *gdp =
@@ -3545,6 +3548,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
3545 kfree(old_opts.s_qf_names[i]); 3548 kfree(old_opts.s_qf_names[i]);
3546#endif 3549#endif
3547 return 0; 3550 return 0;
3551
3548restore_opts: 3552restore_opts:
3549 sb->s_flags = old_sb_flags; 3553 sb->s_flags = old_sb_flags;
3550 sbi->s_mount_opt = old_opts.s_mount_opt; 3554 sbi->s_mount_opt = old_opts.s_mount_opt;
@@ -3628,11 +3632,12 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf)
3628 le64_to_cpup((void *)es->s_uuid + sizeof(u64)); 3632 le64_to_cpup((void *)es->s_uuid + sizeof(u64));
3629 buf->f_fsid.val[0] = fsid & 0xFFFFFFFFUL; 3633 buf->f_fsid.val[0] = fsid & 0xFFFFFFFFUL;
3630 buf->f_fsid.val[1] = (fsid >> 32) & 0xFFFFFFFFUL; 3634 buf->f_fsid.val[1] = (fsid >> 32) & 0xFFFFFFFFUL;
3635
3631 return 0; 3636 return 0;
3632} 3637}
3633 3638
3634/* Helper function for writing quotas on sync - we need to start transaction before quota file 3639/* Helper function for writing quotas on sync - we need to start transaction
3635 * is locked for write. Otherwise the are possible deadlocks: 3640 * before quota file is locked for write. Otherwise the are possible deadlocks:
3636 * Process 1 Process 2 3641 * Process 1 Process 2
3637 * ext4_create() quota_sync() 3642 * ext4_create() quota_sync()
3638 * jbd2_journal_start() write_dquot() 3643 * jbd2_journal_start() write_dquot()
@@ -3656,7 +3661,7 @@ static int ext4_write_dquot(struct dquot *dquot)
3656 3661
3657 inode = dquot_to_inode(dquot); 3662 inode = dquot_to_inode(dquot);
3658 handle = ext4_journal_start(inode, 3663 handle = ext4_journal_start(inode,
3659 EXT4_QUOTA_TRANS_BLOCKS(dquot->dq_sb)); 3664 EXT4_QUOTA_TRANS_BLOCKS(dquot->dq_sb));
3660 if (IS_ERR(handle)) 3665 if (IS_ERR(handle))
3661 return PTR_ERR(handle); 3666 return PTR_ERR(handle);
3662 ret = dquot_commit(dquot); 3667 ret = dquot_commit(dquot);
@@ -3672,7 +3677,7 @@ static int ext4_acquire_dquot(struct dquot *dquot)
3672 handle_t *handle; 3677 handle_t *handle;
3673 3678
3674 handle = ext4_journal_start(dquot_to_inode(dquot), 3679 handle = ext4_journal_start(dquot_to_inode(dquot),
3675 EXT4_QUOTA_INIT_BLOCKS(dquot->dq_sb)); 3680 EXT4_QUOTA_INIT_BLOCKS(dquot->dq_sb));
3676 if (IS_ERR(handle)) 3681 if (IS_ERR(handle))
3677 return PTR_ERR(handle); 3682 return PTR_ERR(handle);
3678 ret = dquot_acquire(dquot); 3683 ret = dquot_acquire(dquot);
@@ -3688,7 +3693,7 @@ static int ext4_release_dquot(struct dquot *dquot)
3688 handle_t *handle; 3693 handle_t *handle;
3689 3694
3690 handle = ext4_journal_start(dquot_to_inode(dquot), 3695 handle = ext4_journal_start(dquot_to_inode(dquot),
3691 EXT4_QUOTA_DEL_BLOCKS(dquot->dq_sb)); 3696 EXT4_QUOTA_DEL_BLOCKS(dquot->dq_sb));
3692 if (IS_ERR(handle)) { 3697 if (IS_ERR(handle)) {
3693 /* Release dquot anyway to avoid endless cycle in dqput() */ 3698 /* Release dquot anyway to avoid endless cycle in dqput() */
3694 dquot_release(dquot); 3699 dquot_release(dquot);
@@ -3736,7 +3741,7 @@ static int ext4_write_info(struct super_block *sb, int type)
3736static int ext4_quota_on_mount(struct super_block *sb, int type) 3741static int ext4_quota_on_mount(struct super_block *sb, int type)
3737{ 3742{
3738 return vfs_quota_on_mount(sb, EXT4_SB(sb)->s_qf_names[type], 3743 return vfs_quota_on_mount(sb, EXT4_SB(sb)->s_qf_names[type],
3739 EXT4_SB(sb)->s_jquota_fmt, type); 3744 EXT4_SB(sb)->s_jquota_fmt, type);
3740} 3745}
3741 3746
3742/* 3747/*
@@ -3907,10 +3912,10 @@ out:
3907 3912
3908#endif 3913#endif
3909 3914
3910static int ext4_get_sb(struct file_system_type *fs_type, 3915static int ext4_get_sb(struct file_system_type *fs_type, int flags,
3911 int flags, const char *dev_name, void *data, struct vfsmount *mnt) 3916 const char *dev_name, void *data, struct vfsmount *mnt)
3912{ 3917{
3913 return get_sb_bdev(fs_type, flags, dev_name, data, ext4_fill_super, mnt); 3918 return get_sb_bdev(fs_type, flags, dev_name, data, ext4_fill_super,mnt);
3914} 3919}
3915 3920
3916static struct file_system_type ext4_fs_type = { 3921static struct file_system_type ext4_fs_type = {
@@ -3922,14 +3927,14 @@ static struct file_system_type ext4_fs_type = {
3922}; 3927};
3923 3928
3924#ifdef CONFIG_EXT4DEV_COMPAT 3929#ifdef CONFIG_EXT4DEV_COMPAT
3925static int ext4dev_get_sb(struct file_system_type *fs_type, 3930static int ext4dev_get_sb(struct file_system_type *fs_type, int flags,
3926 int flags, const char *dev_name, void *data, struct vfsmount *mnt) 3931 const char *dev_name, void *data,struct vfsmount *mnt)
3927{ 3932{
3928 printk(KERN_WARNING "EXT4-fs: Update your userspace programs " 3933 printk(KERN_WARNING "EXT4-fs: Update your userspace programs "
3929 "to mount using ext4\n"); 3934 "to mount using ext4\n");
3930 printk(KERN_WARNING "EXT4-fs: ext4dev backwards compatibility " 3935 printk(KERN_WARNING "EXT4-fs: ext4dev backwards compatibility "
3931 "will go away by 2.6.31\n"); 3936 "will go away by 2.6.31\n");
3932 return get_sb_bdev(fs_type, flags, dev_name, data, ext4_fill_super, mnt); 3937 return get_sb_bdev(fs_type, flags, dev_name, data, ext4_fill_super,mnt);
3933} 3938}
3934 3939
3935static struct file_system_type ext4dev_fs_type = { 3940static struct file_system_type ext4dev_fs_type = {