diff options
Diffstat (limited to 'fs/ext4/super.c')
-rw-r--r-- | fs/ext4/super.c | 132 |
1 files changed, 34 insertions, 98 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index dea8f13c2fd9..9b2b2bc4ec17 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -374,66 +374,6 @@ void ext4_update_dynamic_rev(struct super_block *sb) | |||
374 | */ | 374 | */ |
375 | } | 375 | } |
376 | 376 | ||
377 | int ext4_update_compat_feature(handle_t *handle, | ||
378 | struct super_block *sb, __u32 compat) | ||
379 | { | ||
380 | int err = 0; | ||
381 | if (!EXT4_HAS_COMPAT_FEATURE(sb, compat)) { | ||
382 | err = ext4_journal_get_write_access(handle, | ||
383 | EXT4_SB(sb)->s_sbh); | ||
384 | if (err) | ||
385 | return err; | ||
386 | EXT4_SET_COMPAT_FEATURE(sb, compat); | ||
387 | sb->s_dirt = 1; | ||
388 | handle->h_sync = 1; | ||
389 | BUFFER_TRACE(EXT4_SB(sb)->s_sbh, | ||
390 | "call ext4_journal_dirty_met adata"); | ||
391 | err = ext4_journal_dirty_metadata(handle, | ||
392 | EXT4_SB(sb)->s_sbh); | ||
393 | } | ||
394 | return err; | ||
395 | } | ||
396 | |||
397 | int ext4_update_rocompat_feature(handle_t *handle, | ||
398 | struct super_block *sb, __u32 rocompat) | ||
399 | { | ||
400 | int err = 0; | ||
401 | if (!EXT4_HAS_RO_COMPAT_FEATURE(sb, rocompat)) { | ||
402 | err = ext4_journal_get_write_access(handle, | ||
403 | EXT4_SB(sb)->s_sbh); | ||
404 | if (err) | ||
405 | return err; | ||
406 | EXT4_SET_RO_COMPAT_FEATURE(sb, rocompat); | ||
407 | sb->s_dirt = 1; | ||
408 | handle->h_sync = 1; | ||
409 | BUFFER_TRACE(EXT4_SB(sb)->s_sbh, | ||
410 | "call ext4_journal_dirty_met adata"); | ||
411 | err = ext4_journal_dirty_metadata(handle, | ||
412 | EXT4_SB(sb)->s_sbh); | ||
413 | } | ||
414 | return err; | ||
415 | } | ||
416 | |||
417 | int ext4_update_incompat_feature(handle_t *handle, | ||
418 | struct super_block *sb, __u32 incompat) | ||
419 | { | ||
420 | int err = 0; | ||
421 | if (!EXT4_HAS_INCOMPAT_FEATURE(sb, incompat)) { | ||
422 | err = ext4_journal_get_write_access(handle, | ||
423 | EXT4_SB(sb)->s_sbh); | ||
424 | if (err) | ||
425 | return err; | ||
426 | EXT4_SET_INCOMPAT_FEATURE(sb, incompat); | ||
427 | sb->s_dirt = 1; | ||
428 | handle->h_sync = 1; | ||
429 | BUFFER_TRACE(EXT4_SB(sb)->s_sbh, | ||
430 | "call ext4_journal_dirty_met adata"); | ||
431 | err = ext4_journal_dirty_metadata(handle, | ||
432 | EXT4_SB(sb)->s_sbh); | ||
433 | } | ||
434 | return err; | ||
435 | } | ||
436 | |||
437 | /* | 377 | /* |
438 | * Open the external journal device | 378 | * Open the external journal device |
439 | */ | 379 | */ |
@@ -904,7 +844,7 @@ static const struct export_operations ext4_export_ops = { | |||
904 | enum { | 844 | enum { |
905 | Opt_bsd_df, Opt_minix_df, Opt_grpid, Opt_nogrpid, | 845 | Opt_bsd_df, Opt_minix_df, Opt_grpid, Opt_nogrpid, |
906 | Opt_resgid, Opt_resuid, Opt_sb, Opt_err_cont, Opt_err_panic, Opt_err_ro, | 846 | Opt_resgid, Opt_resuid, Opt_sb, Opt_err_cont, Opt_err_panic, Opt_err_ro, |
907 | Opt_nouid32, Opt_nocheck, Opt_debug, Opt_oldalloc, Opt_orlov, | 847 | Opt_nouid32, Opt_debug, Opt_oldalloc, Opt_orlov, |
908 | Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl, | 848 | Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl, |
909 | Opt_reservation, Opt_noreservation, Opt_noload, Opt_nobh, Opt_bh, | 849 | Opt_reservation, Opt_noreservation, Opt_noload, Opt_nobh, Opt_bh, |
910 | Opt_commit, Opt_journal_update, Opt_journal_inum, Opt_journal_dev, | 850 | Opt_commit, Opt_journal_update, Opt_journal_inum, Opt_journal_dev, |
@@ -915,7 +855,7 @@ enum { | |||
915 | Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota, | 855 | Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota, |
916 | Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota, | 856 | Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota, |
917 | Opt_grpquota, Opt_extents, Opt_noextents, Opt_i_version, | 857 | Opt_grpquota, Opt_extents, Opt_noextents, Opt_i_version, |
918 | Opt_mballoc, Opt_nomballoc, Opt_stripe, Opt_delalloc, Opt_nodelalloc, | 858 | Opt_stripe, Opt_delalloc, Opt_nodelalloc, |
919 | Opt_inode_readahead_blks | 859 | Opt_inode_readahead_blks |
920 | }; | 860 | }; |
921 | 861 | ||
@@ -933,8 +873,6 @@ static const match_table_t tokens = { | |||
933 | {Opt_err_panic, "errors=panic"}, | 873 | {Opt_err_panic, "errors=panic"}, |
934 | {Opt_err_ro, "errors=remount-ro"}, | 874 | {Opt_err_ro, "errors=remount-ro"}, |
935 | {Opt_nouid32, "nouid32"}, | 875 | {Opt_nouid32, "nouid32"}, |
936 | {Opt_nocheck, "nocheck"}, | ||
937 | {Opt_nocheck, "check=none"}, | ||
938 | {Opt_debug, "debug"}, | 876 | {Opt_debug, "debug"}, |
939 | {Opt_oldalloc, "oldalloc"}, | 877 | {Opt_oldalloc, "oldalloc"}, |
940 | {Opt_orlov, "orlov"}, | 878 | {Opt_orlov, "orlov"}, |
@@ -973,8 +911,6 @@ static const match_table_t tokens = { | |||
973 | {Opt_extents, "extents"}, | 911 | {Opt_extents, "extents"}, |
974 | {Opt_noextents, "noextents"}, | 912 | {Opt_noextents, "noextents"}, |
975 | {Opt_i_version, "i_version"}, | 913 | {Opt_i_version, "i_version"}, |
976 | {Opt_mballoc, "mballoc"}, | ||
977 | {Opt_nomballoc, "nomballoc"}, | ||
978 | {Opt_stripe, "stripe=%u"}, | 914 | {Opt_stripe, "stripe=%u"}, |
979 | {Opt_resize, "resize"}, | 915 | {Opt_resize, "resize"}, |
980 | {Opt_delalloc, "delalloc"}, | 916 | {Opt_delalloc, "delalloc"}, |
@@ -1073,9 +1009,6 @@ static int parse_options(char *options, struct super_block *sb, | |||
1073 | case Opt_nouid32: | 1009 | case Opt_nouid32: |
1074 | set_opt(sbi->s_mount_opt, NO_UID32); | 1010 | set_opt(sbi->s_mount_opt, NO_UID32); |
1075 | break; | 1011 | break; |
1076 | case Opt_nocheck: | ||
1077 | clear_opt(sbi->s_mount_opt, CHECK); | ||
1078 | break; | ||
1079 | case Opt_debug: | 1012 | case Opt_debug: |
1080 | set_opt(sbi->s_mount_opt, DEBUG); | 1013 | set_opt(sbi->s_mount_opt, DEBUG); |
1081 | break; | 1014 | break; |
@@ -1618,14 +1551,14 @@ static int ext4_check_descriptors(struct super_block *sb) | |||
1618 | if (block_bitmap < first_block || block_bitmap > last_block) { | 1551 | if (block_bitmap < first_block || block_bitmap > last_block) { |
1619 | printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: " | 1552 | printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: " |
1620 | "Block bitmap for group %lu not in group " | 1553 | "Block bitmap for group %lu not in group " |
1621 | "(block %llu)!", i, block_bitmap); | 1554 | "(block %llu)!\n", i, block_bitmap); |
1622 | return 0; | 1555 | return 0; |
1623 | } | 1556 | } |
1624 | inode_bitmap = ext4_inode_bitmap(sb, gdp); | 1557 | inode_bitmap = ext4_inode_bitmap(sb, gdp); |
1625 | if (inode_bitmap < first_block || inode_bitmap > last_block) { | 1558 | if (inode_bitmap < first_block || inode_bitmap > last_block) { |
1626 | printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: " | 1559 | printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: " |
1627 | "Inode bitmap for group %lu not in group " | 1560 | "Inode bitmap for group %lu not in group " |
1628 | "(block %llu)!", i, inode_bitmap); | 1561 | "(block %llu)!\n", i, inode_bitmap); |
1629 | return 0; | 1562 | return 0; |
1630 | } | 1563 | } |
1631 | inode_table = ext4_inode_table(sb, gdp); | 1564 | inode_table = ext4_inode_table(sb, gdp); |
@@ -1633,7 +1566,7 @@ static int ext4_check_descriptors(struct super_block *sb) | |||
1633 | inode_table + sbi->s_itb_per_group - 1 > last_block) { | 1566 | inode_table + sbi->s_itb_per_group - 1 > last_block) { |
1634 | printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: " | 1567 | printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: " |
1635 | "Inode table for group %lu not in group " | 1568 | "Inode table for group %lu not in group " |
1636 | "(block %llu)!", i, inode_table); | 1569 | "(block %llu)!\n", i, inode_table); |
1637 | return 0; | 1570 | return 0; |
1638 | } | 1571 | } |
1639 | spin_lock(sb_bgl_lock(sbi, i)); | 1572 | spin_lock(sb_bgl_lock(sbi, i)); |
@@ -1778,13 +1711,13 @@ static void ext4_orphan_cleanup(struct super_block *sb, | |||
1778 | * | 1711 | * |
1779 | * Note, this does *not* consider any metadata overhead for vfs i_blocks. | 1712 | * Note, this does *not* consider any metadata overhead for vfs i_blocks. |
1780 | */ | 1713 | */ |
1781 | static loff_t ext4_max_size(int blkbits) | 1714 | static loff_t ext4_max_size(int blkbits, int has_huge_files) |
1782 | { | 1715 | { |
1783 | loff_t res; | 1716 | loff_t res; |
1784 | loff_t upper_limit = MAX_LFS_FILESIZE; | 1717 | loff_t upper_limit = MAX_LFS_FILESIZE; |
1785 | 1718 | ||
1786 | /* small i_blocks in vfs inode? */ | 1719 | /* small i_blocks in vfs inode? */ |
1787 | if (sizeof(blkcnt_t) < sizeof(u64)) { | 1720 | if (!has_huge_files || sizeof(blkcnt_t) < sizeof(u64)) { |
1788 | /* | 1721 | /* |
1789 | * CONFIG_LSF is not enabled implies the inode | 1722 | * CONFIG_LSF is not enabled implies the inode |
1790 | * i_block represent total blocks in 512 bytes | 1723 | * i_block represent total blocks in 512 bytes |
@@ -1814,7 +1747,7 @@ static loff_t ext4_max_size(int blkbits) | |||
1814 | * block limit, and also a limit of (2^48 - 1) 512-byte sectors in i_blocks. | 1747 | * block limit, and also a limit of (2^48 - 1) 512-byte sectors in i_blocks. |
1815 | * We need to be 1 filesystem block less than the 2^48 sector limit. | 1748 | * We need to be 1 filesystem block less than the 2^48 sector limit. |
1816 | */ | 1749 | */ |
1817 | static loff_t ext4_max_bitmap_size(int bits) | 1750 | static loff_t ext4_max_bitmap_size(int bits, int has_huge_files) |
1818 | { | 1751 | { |
1819 | loff_t res = EXT4_NDIR_BLOCKS; | 1752 | loff_t res = EXT4_NDIR_BLOCKS; |
1820 | int meta_blocks; | 1753 | int meta_blocks; |
@@ -1827,11 +1760,11 @@ static loff_t ext4_max_bitmap_size(int bits) | |||
1827 | * total number of 512 bytes blocks of the file | 1760 | * total number of 512 bytes blocks of the file |
1828 | */ | 1761 | */ |
1829 | 1762 | ||
1830 | if (sizeof(blkcnt_t) < sizeof(u64)) { | 1763 | if (!has_huge_files || sizeof(blkcnt_t) < sizeof(u64)) { |
1831 | /* | 1764 | /* |
1832 | * CONFIG_LSF is not enabled implies the inode | 1765 | * !has_huge_files or CONFIG_LSF is not enabled |
1833 | * i_block represent total blocks in 512 bytes | 1766 | * implies the inode i_block represent total blocks in |
1834 | * 32 == size of vfs inode i_blocks * 8 | 1767 | * 512 bytes 32 == size of vfs inode i_blocks * 8 |
1835 | */ | 1768 | */ |
1836 | upper_limit = (1LL << 32) - 1; | 1769 | upper_limit = (1LL << 32) - 1; |
1837 | 1770 | ||
@@ -1940,7 +1873,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
1940 | int blocksize; | 1873 | int blocksize; |
1941 | int db_count; | 1874 | int db_count; |
1942 | int i; | 1875 | int i; |
1943 | int needs_recovery; | 1876 | int needs_recovery, has_huge_files; |
1944 | __le32 features; | 1877 | __le32 features; |
1945 | __u64 blocks_count; | 1878 | __u64 blocks_count; |
1946 | int err; | 1879 | int err; |
@@ -2081,7 +2014,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2081 | sb->s_id, le32_to_cpu(features)); | 2014 | sb->s_id, le32_to_cpu(features)); |
2082 | goto failed_mount; | 2015 | goto failed_mount; |
2083 | } | 2016 | } |
2084 | if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_HUGE_FILE)) { | 2017 | has_huge_files = EXT4_HAS_RO_COMPAT_FEATURE(sb, |
2018 | EXT4_FEATURE_RO_COMPAT_HUGE_FILE); | ||
2019 | if (has_huge_files) { | ||
2085 | /* | 2020 | /* |
2086 | * Large file size enabled file system can only be | 2021 | * Large file size enabled file system can only be |
2087 | * mount if kernel is build with CONFIG_LSF | 2022 | * mount if kernel is build with CONFIG_LSF |
@@ -2131,8 +2066,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2131 | } | 2066 | } |
2132 | } | 2067 | } |
2133 | 2068 | ||
2134 | sbi->s_bitmap_maxbytes = ext4_max_bitmap_size(sb->s_blocksize_bits); | 2069 | sbi->s_bitmap_maxbytes = ext4_max_bitmap_size(sb->s_blocksize_bits, |
2135 | sb->s_maxbytes = ext4_max_size(sb->s_blocksize_bits); | 2070 | has_huge_files); |
2071 | sb->s_maxbytes = ext4_max_size(sb->s_blocksize_bits, has_huge_files); | ||
2136 | 2072 | ||
2137 | if (le32_to_cpu(es->s_rev_level) == EXT4_GOOD_OLD_REV) { | 2073 | if (le32_to_cpu(es->s_rev_level) == EXT4_GOOD_OLD_REV) { |
2138 | sbi->s_inode_size = EXT4_GOOD_OLD_INODE_SIZE; | 2074 | sbi->s_inode_size = EXT4_GOOD_OLD_INODE_SIZE; |
@@ -2456,6 +2392,21 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2456 | "available.\n"); | 2392 | "available.\n"); |
2457 | } | 2393 | } |
2458 | 2394 | ||
2395 | if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) { | ||
2396 | printk(KERN_WARNING "EXT4-fs: Ignoring delalloc option - " | ||
2397 | "requested data journaling mode\n"); | ||
2398 | clear_opt(sbi->s_mount_opt, DELALLOC); | ||
2399 | } else if (test_opt(sb, DELALLOC)) | ||
2400 | printk(KERN_INFO "EXT4-fs: delayed allocation enabled\n"); | ||
2401 | |||
2402 | ext4_ext_init(sb); | ||
2403 | err = ext4_mb_init(sb, needs_recovery); | ||
2404 | if (err) { | ||
2405 | printk(KERN_ERR "EXT4-fs: failed to initalize mballoc (%d)\n", | ||
2406 | err); | ||
2407 | goto failed_mount4; | ||
2408 | } | ||
2409 | |||
2459 | /* | 2410 | /* |
2460 | * akpm: core read_super() calls in here with the superblock locked. | 2411 | * akpm: core read_super() calls in here with the superblock locked. |
2461 | * That deadlocks, because orphan cleanup needs to lock the superblock | 2412 | * That deadlocks, because orphan cleanup needs to lock the superblock |
@@ -2475,21 +2426,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2475 | test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA ? "ordered": | 2426 | test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA ? "ordered": |
2476 | "writeback"); | 2427 | "writeback"); |
2477 | 2428 | ||
2478 | if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) { | ||
2479 | printk(KERN_WARNING "EXT4-fs: Ignoring delalloc option - " | ||
2480 | "requested data journaling mode\n"); | ||
2481 | clear_opt(sbi->s_mount_opt, DELALLOC); | ||
2482 | } else if (test_opt(sb, DELALLOC)) | ||
2483 | printk(KERN_INFO "EXT4-fs: delayed allocation enabled\n"); | ||
2484 | |||
2485 | ext4_ext_init(sb); | ||
2486 | err = ext4_mb_init(sb, needs_recovery); | ||
2487 | if (err) { | ||
2488 | printk(KERN_ERR "EXT4-fs: failed to initalize mballoc (%d)\n", | ||
2489 | err); | ||
2490 | goto failed_mount4; | ||
2491 | } | ||
2492 | |||
2493 | lock_kernel(); | 2429 | lock_kernel(); |
2494 | return 0; | 2430 | return 0; |
2495 | 2431 | ||