aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext3/super.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext3/super.c')
-rw-r--r--fs/ext3/super.c79
1 files changed, 39 insertions, 40 deletions
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index f3675cc630e9..18769cc32377 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -575,16 +575,16 @@ static int ext3_show_options(struct seq_file *seq, struct vfsmount *vfs)
575 le16_to_cpu(es->s_def_resgid) != EXT3_DEF_RESGID) { 575 le16_to_cpu(es->s_def_resgid) != EXT3_DEF_RESGID) {
576 seq_printf(seq, ",resgid=%u", sbi->s_resgid); 576 seq_printf(seq, ",resgid=%u", sbi->s_resgid);
577 } 577 }
578 if (test_opt(sb, ERRORS_CONT)) { 578 if (test_opt(sb, ERRORS_RO)) {
579 int def_errors = le16_to_cpu(es->s_errors); 579 int def_errors = le16_to_cpu(es->s_errors);
580 580
581 if (def_errors == EXT3_ERRORS_PANIC || 581 if (def_errors == EXT3_ERRORS_PANIC ||
582 def_errors == EXT3_ERRORS_RO) { 582 def_errors == EXT3_ERRORS_CONTINUE) {
583 seq_puts(seq, ",errors=continue"); 583 seq_puts(seq, ",errors=remount-ro");
584 } 584 }
585 } 585 }
586 if (test_opt(sb, ERRORS_RO)) 586 if (test_opt(sb, ERRORS_CONT))
587 seq_puts(seq, ",errors=remount-ro"); 587 seq_puts(seq, ",errors=continue");
588 if (test_opt(sb, ERRORS_PANIC)) 588 if (test_opt(sb, ERRORS_PANIC))
589 seq_puts(seq, ",errors=panic"); 589 seq_puts(seq, ",errors=panic");
590 if (test_opt(sb, NO_UID32)) 590 if (test_opt(sb, NO_UID32))
@@ -649,11 +649,10 @@ static struct inode *ext3_nfs_get_inode(struct super_block *sb,
649 * Currently we don't know the generation for parent directory, so 649 * Currently we don't know the generation for parent directory, so
650 * a generation of 0 means "accept any" 650 * a generation of 0 means "accept any"
651 */ 651 */
652 inode = iget(sb, ino); 652 inode = ext3_iget(sb, ino);
653 if (inode == NULL) 653 if (IS_ERR(inode))
654 return ERR_PTR(-ENOMEM); 654 return ERR_CAST(inode);
655 if (is_bad_inode(inode) || 655 if (generation && inode->i_generation != generation) {
656 (generation && inode->i_generation != generation)) {
657 iput(inode); 656 iput(inode);
658 return ERR_PTR(-ESTALE); 657 return ERR_PTR(-ESTALE);
659 } 658 }
@@ -722,7 +721,6 @@ static struct quotactl_ops ext3_qctl_operations = {
722static const struct super_operations ext3_sops = { 721static const struct super_operations ext3_sops = {
723 .alloc_inode = ext3_alloc_inode, 722 .alloc_inode = ext3_alloc_inode,
724 .destroy_inode = ext3_destroy_inode, 723 .destroy_inode = ext3_destroy_inode,
725 .read_inode = ext3_read_inode,
726 .write_inode = ext3_write_inode, 724 .write_inode = ext3_write_inode,
727 .dirty_inode = ext3_dirty_inode, 725 .dirty_inode = ext3_dirty_inode,
728 .delete_inode = ext3_delete_inode, 726 .delete_inode = ext3_delete_inode,
@@ -1224,7 +1222,7 @@ static int ext3_setup_super(struct super_block *sb, struct ext3_super_block *es,
1224#endif 1222#endif
1225 if (!(__s16) le16_to_cpu(es->s_max_mnt_count)) 1223 if (!(__s16) le16_to_cpu(es->s_max_mnt_count))
1226 es->s_max_mnt_count = cpu_to_le16(EXT3_DFL_MAX_MNT_COUNT); 1224 es->s_max_mnt_count = cpu_to_le16(EXT3_DFL_MAX_MNT_COUNT);
1227 es->s_mnt_count=cpu_to_le16(le16_to_cpu(es->s_mnt_count) + 1); 1225 le16_add_cpu(&es->s_mnt_count, 1);
1228 es->s_mtime = cpu_to_le32(get_seconds()); 1226 es->s_mtime = cpu_to_le32(get_seconds());
1229 ext3_update_dynamic_rev(sb); 1227 ext3_update_dynamic_rev(sb);
1230 EXT3_SET_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER); 1228 EXT3_SET_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER);
@@ -1252,28 +1250,24 @@ static int ext3_setup_super(struct super_block *sb, struct ext3_super_block *es,
1252} 1250}
1253 1251
1254/* Called at mount-time, super-block is locked */ 1252/* Called at mount-time, super-block is locked */
1255static int ext3_check_descriptors (struct super_block * sb) 1253static int ext3_check_descriptors(struct super_block *sb)
1256{ 1254{
1257 struct ext3_sb_info *sbi = EXT3_SB(sb); 1255 struct ext3_sb_info *sbi = EXT3_SB(sb);
1258 ext3_fsblk_t first_block = le32_to_cpu(sbi->s_es->s_first_data_block); 1256 ext3_fsblk_t first_block = le32_to_cpu(sbi->s_es->s_first_data_block);
1259 ext3_fsblk_t last_block; 1257 ext3_fsblk_t last_block;
1260 struct ext3_group_desc * gdp = NULL;
1261 int desc_block = 0;
1262 int i; 1258 int i;
1263 1259
1264 ext3_debug ("Checking group descriptors"); 1260 ext3_debug ("Checking group descriptors");
1265 1261
1266 for (i = 0; i < sbi->s_groups_count; i++) 1262 for (i = 0; i < sbi->s_groups_count; i++) {
1267 { 1263 struct ext3_group_desc *gdp = ext3_get_group_desc(sb, i, NULL);
1264
1268 if (i == sbi->s_groups_count - 1) 1265 if (i == sbi->s_groups_count - 1)
1269 last_block = le32_to_cpu(sbi->s_es->s_blocks_count) - 1; 1266 last_block = le32_to_cpu(sbi->s_es->s_blocks_count) - 1;
1270 else 1267 else
1271 last_block = first_block + 1268 last_block = first_block +
1272 (EXT3_BLOCKS_PER_GROUP(sb) - 1); 1269 (EXT3_BLOCKS_PER_GROUP(sb) - 1);
1273 1270
1274 if ((i % EXT3_DESC_PER_BLOCK(sb)) == 0)
1275 gdp = (struct ext3_group_desc *)
1276 sbi->s_group_desc[desc_block++]->b_data;
1277 if (le32_to_cpu(gdp->bg_block_bitmap) < first_block || 1271 if (le32_to_cpu(gdp->bg_block_bitmap) < first_block ||
1278 le32_to_cpu(gdp->bg_block_bitmap) > last_block) 1272 le32_to_cpu(gdp->bg_block_bitmap) > last_block)
1279 { 1273 {
@@ -1306,7 +1300,6 @@ static int ext3_check_descriptors (struct super_block * sb)
1306 return 0; 1300 return 0;
1307 } 1301 }
1308 first_block += EXT3_BLOCKS_PER_GROUP(sb); 1302 first_block += EXT3_BLOCKS_PER_GROUP(sb);
1309 gdp++;
1310 } 1303 }
1311 1304
1312 sbi->s_es->s_free_blocks_count=cpu_to_le32(ext3_count_free_blocks(sb)); 1305 sbi->s_es->s_free_blocks_count=cpu_to_le32(ext3_count_free_blocks(sb));
@@ -1383,8 +1376,8 @@ static void ext3_orphan_cleanup (struct super_block * sb,
1383 while (es->s_last_orphan) { 1376 while (es->s_last_orphan) {
1384 struct inode *inode; 1377 struct inode *inode;
1385 1378
1386 if (!(inode = 1379 inode = ext3_orphan_get(sb, le32_to_cpu(es->s_last_orphan));
1387 ext3_orphan_get(sb, le32_to_cpu(es->s_last_orphan)))) { 1380 if (IS_ERR(inode)) {
1388 es->s_last_orphan = 0; 1381 es->s_last_orphan = 0;
1389 break; 1382 break;
1390 } 1383 }
@@ -1513,6 +1506,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1513 int db_count; 1506 int db_count;
1514 int i; 1507 int i;
1515 int needs_recovery; 1508 int needs_recovery;
1509 int ret = -EINVAL;
1516 __le32 features; 1510 __le32 features;
1517 int err; 1511 int err;
1518 1512
@@ -1583,10 +1577,10 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1583 1577
1584 if (le16_to_cpu(sbi->s_es->s_errors) == EXT3_ERRORS_PANIC) 1578 if (le16_to_cpu(sbi->s_es->s_errors) == EXT3_ERRORS_PANIC)
1585 set_opt(sbi->s_mount_opt, ERRORS_PANIC); 1579 set_opt(sbi->s_mount_opt, ERRORS_PANIC);
1586 else if (le16_to_cpu(sbi->s_es->s_errors) == EXT3_ERRORS_RO) 1580 else if (le16_to_cpu(sbi->s_es->s_errors) == EXT3_ERRORS_CONTINUE)
1587 set_opt(sbi->s_mount_opt, ERRORS_RO);
1588 else
1589 set_opt(sbi->s_mount_opt, ERRORS_CONT); 1581 set_opt(sbi->s_mount_opt, ERRORS_CONT);
1582 else
1583 set_opt(sbi->s_mount_opt, ERRORS_RO);
1590 1584
1591 sbi->s_resuid = le16_to_cpu(es->s_def_resuid); 1585 sbi->s_resuid = le16_to_cpu(es->s_def_resuid);
1592 sbi->s_resgid = le16_to_cpu(es->s_def_resgid); 1586 sbi->s_resgid = le16_to_cpu(es->s_def_resgid);
@@ -1882,19 +1876,24 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1882 * so we can safely mount the rest of the filesystem now. 1876 * so we can safely mount the rest of the filesystem now.
1883 */ 1877 */
1884 1878
1885 root = iget(sb, EXT3_ROOT_INO); 1879 root = ext3_iget(sb, EXT3_ROOT_INO);
1886 sb->s_root = d_alloc_root(root); 1880 if (IS_ERR(root)) {
1887 if (!sb->s_root) {
1888 printk(KERN_ERR "EXT3-fs: get root inode failed\n"); 1881 printk(KERN_ERR "EXT3-fs: get root inode failed\n");
1889 iput(root); 1882 ret = PTR_ERR(root);
1890 goto failed_mount4; 1883 goto failed_mount4;
1891 } 1884 }
1892 if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { 1885 if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) {
1893 dput(sb->s_root); 1886 iput(root);
1894 sb->s_root = NULL;
1895 printk(KERN_ERR "EXT3-fs: corrupt root inode, run e2fsck\n"); 1887 printk(KERN_ERR "EXT3-fs: corrupt root inode, run e2fsck\n");
1896 goto failed_mount4; 1888 goto failed_mount4;
1897 } 1889 }
1890 sb->s_root = d_alloc_root(root);
1891 if (!sb->s_root) {
1892 printk(KERN_ERR "EXT3-fs: get root dentry failed\n");
1893 iput(root);
1894 ret = -ENOMEM;
1895 goto failed_mount4;
1896 }
1898 1897
1899 ext3_setup_super (sb, es, sb->s_flags & MS_RDONLY); 1898 ext3_setup_super (sb, es, sb->s_flags & MS_RDONLY);
1900 /* 1899 /*
@@ -1946,7 +1945,7 @@ out_fail:
1946 sb->s_fs_info = NULL; 1945 sb->s_fs_info = NULL;
1947 kfree(sbi); 1946 kfree(sbi);
1948 lock_kernel(); 1947 lock_kernel();
1949 return -EINVAL; 1948 return ret;
1950} 1949}
1951 1950
1952/* 1951/*
@@ -1982,8 +1981,8 @@ static journal_t *ext3_get_journal(struct super_block *sb,
1982 * things happen if we iget() an unused inode, as the subsequent 1981 * things happen if we iget() an unused inode, as the subsequent
1983 * iput() will try to delete it. */ 1982 * iput() will try to delete it. */
1984 1983
1985 journal_inode = iget(sb, journal_inum); 1984 journal_inode = ext3_iget(sb, journal_inum);
1986 if (!journal_inode) { 1985 if (IS_ERR(journal_inode)) {
1987 printk(KERN_ERR "EXT3-fs: no journal found.\n"); 1986 printk(KERN_ERR "EXT3-fs: no journal found.\n");
1988 return NULL; 1987 return NULL;
1989 } 1988 }
@@ -1996,7 +1995,7 @@ static journal_t *ext3_get_journal(struct super_block *sb,
1996 1995
1997 jbd_debug(2, "Journal inode found at %p: %Ld bytes\n", 1996 jbd_debug(2, "Journal inode found at %p: %Ld bytes\n",
1998 journal_inode, journal_inode->i_size); 1997 journal_inode, journal_inode->i_size);
1999 if (is_bad_inode(journal_inode) || !S_ISREG(journal_inode->i_mode)) { 1998 if (!S_ISREG(journal_inode->i_mode)) {
2000 printk(KERN_ERR "EXT3-fs: invalid journal inode.\n"); 1999 printk(KERN_ERR "EXT3-fs: invalid journal inode.\n");
2001 iput(journal_inode); 2000 iput(journal_inode);
2002 return NULL; 2001 return NULL;
@@ -2759,16 +2758,16 @@ static int ext3_quota_on(struct super_block *sb, int type, int format_id,
2759 if (err) 2758 if (err)
2760 return err; 2759 return err;
2761 /* Quotafile not on the same filesystem? */ 2760 /* Quotafile not on the same filesystem? */
2762 if (nd.mnt->mnt_sb != sb) { 2761 if (nd.path.mnt->mnt_sb != sb) {
2763 path_release(&nd); 2762 path_put(&nd.path);
2764 return -EXDEV; 2763 return -EXDEV;
2765 } 2764 }
2766 /* Quotafile not of fs root? */ 2765 /* Quotafile not of fs root? */
2767 if (nd.dentry->d_parent->d_inode != sb->s_root->d_inode) 2766 if (nd.path.dentry->d_parent->d_inode != sb->s_root->d_inode)
2768 printk(KERN_WARNING 2767 printk(KERN_WARNING
2769 "EXT3-fs: Quota file not on filesystem root. " 2768 "EXT3-fs: Quota file not on filesystem root. "
2770 "Journalled quota will not work.\n"); 2769 "Journalled quota will not work.\n");
2771 path_release(&nd); 2770 path_put(&nd.path);
2772 return vfs_quota_on(sb, type, format_id, path); 2771 return vfs_quota_on(sb, type, format_id, path);
2773} 2772}
2774 2773