diff options
Diffstat (limited to 'fs/ext4/super.c')
-rw-r--r-- | fs/ext4/super.c | 69 |
1 files changed, 39 insertions, 30 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 055a0cd0168e..13383ba18f1d 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -777,11 +777,10 @@ static struct inode *ext4_nfs_get_inode(struct super_block *sb, | |||
777 | * Currently we don't know the generation for parent directory, so | 777 | * Currently we don't know the generation for parent directory, so |
778 | * a generation of 0 means "accept any" | 778 | * a generation of 0 means "accept any" |
779 | */ | 779 | */ |
780 | inode = iget(sb, ino); | 780 | inode = ext4_iget(sb, ino); |
781 | if (inode == NULL) | 781 | if (IS_ERR(inode)) |
782 | return ERR_PTR(-ENOMEM); | 782 | return ERR_CAST(inode); |
783 | if (is_bad_inode(inode) || | 783 | if (generation && inode->i_generation != generation) { |
784 | (generation && inode->i_generation != generation)) { | ||
785 | iput(inode); | 784 | iput(inode); |
786 | return ERR_PTR(-ESTALE); | 785 | return ERR_PTR(-ESTALE); |
787 | } | 786 | } |
@@ -850,7 +849,6 @@ static struct quotactl_ops ext4_qctl_operations = { | |||
850 | static const struct super_operations ext4_sops = { | 849 | static const struct super_operations ext4_sops = { |
851 | .alloc_inode = ext4_alloc_inode, | 850 | .alloc_inode = ext4_alloc_inode, |
852 | .destroy_inode = ext4_destroy_inode, | 851 | .destroy_inode = ext4_destroy_inode, |
853 | .read_inode = ext4_read_inode, | ||
854 | .write_inode = ext4_write_inode, | 852 | .write_inode = ext4_write_inode, |
855 | .dirty_inode = ext4_dirty_inode, | 853 | .dirty_inode = ext4_dirty_inode, |
856 | .delete_inode = ext4_delete_inode, | 854 | .delete_inode = ext4_delete_inode, |
@@ -1458,7 +1456,7 @@ int ext4_group_desc_csum_verify(struct ext4_sb_info *sbi, __u32 block_group, | |||
1458 | } | 1456 | } |
1459 | 1457 | ||
1460 | /* Called at mount-time, super-block is locked */ | 1458 | /* Called at mount-time, super-block is locked */ |
1461 | static int ext4_check_descriptors (struct super_block * sb) | 1459 | static int ext4_check_descriptors(struct super_block *sb) |
1462 | { | 1460 | { |
1463 | struct ext4_sb_info *sbi = EXT4_SB(sb); | 1461 | struct ext4_sb_info *sbi = EXT4_SB(sb); |
1464 | ext4_fsblk_t first_block = le32_to_cpu(sbi->s_es->s_first_data_block); | 1462 | ext4_fsblk_t first_block = le32_to_cpu(sbi->s_es->s_first_data_block); |
@@ -1466,8 +1464,6 @@ static int ext4_check_descriptors (struct super_block * sb) | |||
1466 | ext4_fsblk_t block_bitmap; | 1464 | ext4_fsblk_t block_bitmap; |
1467 | ext4_fsblk_t inode_bitmap; | 1465 | ext4_fsblk_t inode_bitmap; |
1468 | ext4_fsblk_t inode_table; | 1466 | ext4_fsblk_t inode_table; |
1469 | struct ext4_group_desc * gdp = NULL; | ||
1470 | int desc_block = 0; | ||
1471 | int flexbg_flag = 0; | 1467 | int flexbg_flag = 0; |
1472 | ext4_group_t i; | 1468 | ext4_group_t i; |
1473 | 1469 | ||
@@ -1476,17 +1472,15 @@ static int ext4_check_descriptors (struct super_block * sb) | |||
1476 | 1472 | ||
1477 | ext4_debug ("Checking group descriptors"); | 1473 | ext4_debug ("Checking group descriptors"); |
1478 | 1474 | ||
1479 | for (i = 0; i < sbi->s_groups_count; i++) | 1475 | for (i = 0; i < sbi->s_groups_count; i++) { |
1480 | { | 1476 | struct ext4_group_desc *gdp = ext4_get_group_desc(sb, i, NULL); |
1477 | |||
1481 | if (i == sbi->s_groups_count - 1 || flexbg_flag) | 1478 | if (i == sbi->s_groups_count - 1 || flexbg_flag) |
1482 | last_block = ext4_blocks_count(sbi->s_es) - 1; | 1479 | last_block = ext4_blocks_count(sbi->s_es) - 1; |
1483 | else | 1480 | else |
1484 | last_block = first_block + | 1481 | last_block = first_block + |
1485 | (EXT4_BLOCKS_PER_GROUP(sb) - 1); | 1482 | (EXT4_BLOCKS_PER_GROUP(sb) - 1); |
1486 | 1483 | ||
1487 | if ((i % EXT4_DESC_PER_BLOCK(sb)) == 0) | ||
1488 | gdp = (struct ext4_group_desc *) | ||
1489 | sbi->s_group_desc[desc_block++]->b_data; | ||
1490 | block_bitmap = ext4_block_bitmap(sb, gdp); | 1484 | block_bitmap = ext4_block_bitmap(sb, gdp); |
1491 | if (block_bitmap < first_block || block_bitmap > last_block) | 1485 | if (block_bitmap < first_block || block_bitmap > last_block) |
1492 | { | 1486 | { |
@@ -1524,8 +1518,6 @@ static int ext4_check_descriptors (struct super_block * sb) | |||
1524 | } | 1518 | } |
1525 | if (!flexbg_flag) | 1519 | if (!flexbg_flag) |
1526 | first_block += EXT4_BLOCKS_PER_GROUP(sb); | 1520 | first_block += EXT4_BLOCKS_PER_GROUP(sb); |
1527 | gdp = (struct ext4_group_desc *) | ||
1528 | ((__u8 *)gdp + EXT4_DESC_SIZE(sb)); | ||
1529 | } | 1521 | } |
1530 | 1522 | ||
1531 | ext4_free_blocks_count_set(sbi->s_es, ext4_count_free_blocks(sb)); | 1523 | ext4_free_blocks_count_set(sbi->s_es, ext4_count_free_blocks(sb)); |
@@ -1811,6 +1803,7 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent) | |||
1811 | unsigned long journal_devnum = 0; | 1803 | unsigned long journal_devnum = 0; |
1812 | unsigned long def_mount_opts; | 1804 | unsigned long def_mount_opts; |
1813 | struct inode *root; | 1805 | struct inode *root; |
1806 | int ret = -EINVAL; | ||
1814 | int blocksize; | 1807 | int blocksize; |
1815 | int db_count; | 1808 | int db_count; |
1816 | int i; | 1809 | int i; |
@@ -1926,6 +1919,17 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent) | |||
1926 | printk(KERN_WARNING | 1919 | printk(KERN_WARNING |
1927 | "EXT4-fs warning: feature flags set on rev 0 fs, " | 1920 | "EXT4-fs warning: feature flags set on rev 0 fs, " |
1928 | "running e2fsck is recommended\n"); | 1921 | "running e2fsck is recommended\n"); |
1922 | |||
1923 | /* | ||
1924 | * Since ext4 is still considered development code, we require | ||
1925 | * that the TEST_FILESYS flag in s->flags be set. | ||
1926 | */ | ||
1927 | if (!(le32_to_cpu(es->s_flags) & EXT2_FLAGS_TEST_FILESYS)) { | ||
1928 | printk(KERN_WARNING "EXT4-fs: %s: not marked " | ||
1929 | "OK to use with test code.\n", sb->s_id); | ||
1930 | goto failed_mount; | ||
1931 | } | ||
1932 | |||
1929 | /* | 1933 | /* |
1930 | * Check feature flags regardless of the revision level, since we | 1934 | * Check feature flags regardless of the revision level, since we |
1931 | * previously didn't change the revision level when setting the flags, | 1935 | * previously didn't change the revision level when setting the flags, |
@@ -2243,19 +2247,24 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent) | |||
2243 | * so we can safely mount the rest of the filesystem now. | 2247 | * so we can safely mount the rest of the filesystem now. |
2244 | */ | 2248 | */ |
2245 | 2249 | ||
2246 | root = iget(sb, EXT4_ROOT_INO); | 2250 | root = ext4_iget(sb, EXT4_ROOT_INO); |
2247 | sb->s_root = d_alloc_root(root); | 2251 | if (IS_ERR(root)) { |
2248 | if (!sb->s_root) { | ||
2249 | printk(KERN_ERR "EXT4-fs: get root inode failed\n"); | 2252 | printk(KERN_ERR "EXT4-fs: get root inode failed\n"); |
2250 | iput(root); | 2253 | ret = PTR_ERR(root); |
2251 | goto failed_mount4; | 2254 | goto failed_mount4; |
2252 | } | 2255 | } |
2253 | if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { | 2256 | if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { |
2254 | dput(sb->s_root); | 2257 | iput(root); |
2255 | sb->s_root = NULL; | ||
2256 | printk(KERN_ERR "EXT4-fs: corrupt root inode, run e2fsck\n"); | 2258 | printk(KERN_ERR "EXT4-fs: corrupt root inode, run e2fsck\n"); |
2257 | goto failed_mount4; | 2259 | goto failed_mount4; |
2258 | } | 2260 | } |
2261 | sb->s_root = d_alloc_root(root); | ||
2262 | if (!sb->s_root) { | ||
2263 | printk(KERN_ERR "EXT4-fs: get root dentry failed\n"); | ||
2264 | iput(root); | ||
2265 | ret = -ENOMEM; | ||
2266 | goto failed_mount4; | ||
2267 | } | ||
2259 | 2268 | ||
2260 | ext4_setup_super (sb, es, sb->s_flags & MS_RDONLY); | 2269 | ext4_setup_super (sb, es, sb->s_flags & MS_RDONLY); |
2261 | 2270 | ||
@@ -2336,7 +2345,7 @@ out_fail: | |||
2336 | sb->s_fs_info = NULL; | 2345 | sb->s_fs_info = NULL; |
2337 | kfree(sbi); | 2346 | kfree(sbi); |
2338 | lock_kernel(); | 2347 | lock_kernel(); |
2339 | return -EINVAL; | 2348 | return ret; |
2340 | } | 2349 | } |
2341 | 2350 | ||
2342 | /* | 2351 | /* |
@@ -2372,8 +2381,8 @@ static journal_t *ext4_get_journal(struct super_block *sb, | |||
2372 | * things happen if we iget() an unused inode, as the subsequent | 2381 | * things happen if we iget() an unused inode, as the subsequent |
2373 | * iput() will try to delete it. */ | 2382 | * iput() will try to delete it. */ |
2374 | 2383 | ||
2375 | journal_inode = iget(sb, journal_inum); | 2384 | journal_inode = ext4_iget(sb, journal_inum); |
2376 | if (!journal_inode) { | 2385 | if (IS_ERR(journal_inode)) { |
2377 | printk(KERN_ERR "EXT4-fs: no journal found.\n"); | 2386 | printk(KERN_ERR "EXT4-fs: no journal found.\n"); |
2378 | return NULL; | 2387 | return NULL; |
2379 | } | 2388 | } |
@@ -2386,7 +2395,7 @@ static journal_t *ext4_get_journal(struct super_block *sb, | |||
2386 | 2395 | ||
2387 | jbd_debug(2, "Journal inode found at %p: %Ld bytes\n", | 2396 | jbd_debug(2, "Journal inode found at %p: %Ld bytes\n", |
2388 | journal_inode, journal_inode->i_size); | 2397 | journal_inode, journal_inode->i_size); |
2389 | if (is_bad_inode(journal_inode) || !S_ISREG(journal_inode->i_mode)) { | 2398 | if (!S_ISREG(journal_inode->i_mode)) { |
2390 | printk(KERN_ERR "EXT4-fs: invalid journal inode.\n"); | 2399 | printk(KERN_ERR "EXT4-fs: invalid journal inode.\n"); |
2391 | iput(journal_inode); | 2400 | iput(journal_inode); |
2392 | return NULL; | 2401 | return NULL; |
@@ -3149,16 +3158,16 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id, | |||
3149 | if (err) | 3158 | if (err) |
3150 | return err; | 3159 | return err; |
3151 | /* Quotafile not on the same filesystem? */ | 3160 | /* Quotafile not on the same filesystem? */ |
3152 | if (nd.mnt->mnt_sb != sb) { | 3161 | if (nd.path.mnt->mnt_sb != sb) { |
3153 | path_release(&nd); | 3162 | path_put(&nd.path); |
3154 | return -EXDEV; | 3163 | return -EXDEV; |
3155 | } | 3164 | } |
3156 | /* Quotafile not of fs root? */ | 3165 | /* Quotafile not of fs root? */ |
3157 | if (nd.dentry->d_parent->d_inode != sb->s_root->d_inode) | 3166 | if (nd.path.dentry->d_parent->d_inode != sb->s_root->d_inode) |
3158 | printk(KERN_WARNING | 3167 | printk(KERN_WARNING |
3159 | "EXT4-fs: Quota file not on filesystem root. " | 3168 | "EXT4-fs: Quota file not on filesystem root. " |
3160 | "Journalled quota will not work.\n"); | 3169 | "Journalled quota will not work.\n"); |
3161 | path_release(&nd); | 3170 | path_put(&nd.path); |
3162 | return vfs_quota_on(sb, type, format_id, path); | 3171 | return vfs_quota_on(sb, type, format_id, path); |
3163 | } | 3172 | } |
3164 | 3173 | ||