diff options
Diffstat (limited to 'fs/ext4/super.c')
-rw-r--r-- | fs/ext4/super.c | 57 |
1 files changed, 31 insertions, 26 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 80928f716850..3cdb0a2fc648 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -45,7 +45,7 @@ | |||
45 | #include <linux/freezer.h> | 45 | #include <linux/freezer.h> |
46 | 46 | ||
47 | #include "ext4.h" | 47 | #include "ext4.h" |
48 | #include "ext4_extents.h" | 48 | #include "ext4_extents.h" /* Needed for trace points definition */ |
49 | #include "ext4_jbd2.h" | 49 | #include "ext4_jbd2.h" |
50 | #include "xattr.h" | 50 | #include "xattr.h" |
51 | #include "acl.h" | 51 | #include "acl.h" |
@@ -939,10 +939,11 @@ static struct inode *ext4_alloc_inode(struct super_block *sb) | |||
939 | return NULL; | 939 | return NULL; |
940 | 940 | ||
941 | ei->vfs_inode.i_version = 1; | 941 | ei->vfs_inode.i_version = 1; |
942 | ei->vfs_inode.i_data.writeback_index = 0; | ||
943 | memset(&ei->i_cached_extent, 0, sizeof(struct ext4_ext_cache)); | 942 | memset(&ei->i_cached_extent, 0, sizeof(struct ext4_ext_cache)); |
944 | INIT_LIST_HEAD(&ei->i_prealloc_list); | 943 | INIT_LIST_HEAD(&ei->i_prealloc_list); |
945 | spin_lock_init(&ei->i_prealloc_lock); | 944 | spin_lock_init(&ei->i_prealloc_lock); |
945 | ext4_es_init_tree(&ei->i_es_tree); | ||
946 | rwlock_init(&ei->i_es_lock); | ||
946 | ei->i_reserved_data_blocks = 0; | 947 | ei->i_reserved_data_blocks = 0; |
947 | ei->i_reserved_meta_blocks = 0; | 948 | ei->i_reserved_meta_blocks = 0; |
948 | ei->i_allocated_meta_blocks = 0; | 949 | ei->i_allocated_meta_blocks = 0; |
@@ -996,9 +997,7 @@ static void init_once(void *foo) | |||
996 | struct ext4_inode_info *ei = (struct ext4_inode_info *) foo; | 997 | struct ext4_inode_info *ei = (struct ext4_inode_info *) foo; |
997 | 998 | ||
998 | INIT_LIST_HEAD(&ei->i_orphan); | 999 | INIT_LIST_HEAD(&ei->i_orphan); |
999 | #ifdef CONFIG_EXT4_FS_XATTR | ||
1000 | init_rwsem(&ei->xattr_sem); | 1000 | init_rwsem(&ei->xattr_sem); |
1001 | #endif | ||
1002 | init_rwsem(&ei->i_data_sem); | 1001 | init_rwsem(&ei->i_data_sem); |
1003 | inode_init_once(&ei->vfs_inode); | 1002 | inode_init_once(&ei->vfs_inode); |
1004 | } | 1003 | } |
@@ -1031,6 +1030,7 @@ void ext4_clear_inode(struct inode *inode) | |||
1031 | clear_inode(inode); | 1030 | clear_inode(inode); |
1032 | dquot_drop(inode); | 1031 | dquot_drop(inode); |
1033 | ext4_discard_preallocations(inode); | 1032 | ext4_discard_preallocations(inode); |
1033 | ext4_es_remove_extent(inode, 0, EXT_MAX_BLOCKS); | ||
1034 | if (EXT4_I(inode)->jinode) { | 1034 | if (EXT4_I(inode)->jinode) { |
1035 | jbd2_journal_release_jbd_inode(EXT4_JOURNAL(inode), | 1035 | jbd2_journal_release_jbd_inode(EXT4_JOURNAL(inode), |
1036 | EXT4_I(inode)->jinode); | 1036 | EXT4_I(inode)->jinode); |
@@ -1447,13 +1447,8 @@ static const struct mount_opts { | |||
1447 | {Opt_data_journal, EXT4_MOUNT_JOURNAL_DATA, MOPT_DATAJ}, | 1447 | {Opt_data_journal, EXT4_MOUNT_JOURNAL_DATA, MOPT_DATAJ}, |
1448 | {Opt_data_ordered, EXT4_MOUNT_ORDERED_DATA, MOPT_DATAJ}, | 1448 | {Opt_data_ordered, EXT4_MOUNT_ORDERED_DATA, MOPT_DATAJ}, |
1449 | {Opt_data_writeback, EXT4_MOUNT_WRITEBACK_DATA, MOPT_DATAJ}, | 1449 | {Opt_data_writeback, EXT4_MOUNT_WRITEBACK_DATA, MOPT_DATAJ}, |
1450 | #ifdef CONFIG_EXT4_FS_XATTR | ||
1451 | {Opt_user_xattr, EXT4_MOUNT_XATTR_USER, MOPT_SET}, | 1450 | {Opt_user_xattr, EXT4_MOUNT_XATTR_USER, MOPT_SET}, |
1452 | {Opt_nouser_xattr, EXT4_MOUNT_XATTR_USER, MOPT_CLEAR}, | 1451 | {Opt_nouser_xattr, EXT4_MOUNT_XATTR_USER, MOPT_CLEAR}, |
1453 | #else | ||
1454 | {Opt_user_xattr, 0, MOPT_NOSUPPORT}, | ||
1455 | {Opt_nouser_xattr, 0, MOPT_NOSUPPORT}, | ||
1456 | #endif | ||
1457 | #ifdef CONFIG_EXT4_FS_POSIX_ACL | 1452 | #ifdef CONFIG_EXT4_FS_POSIX_ACL |
1458 | {Opt_acl, EXT4_MOUNT_POSIX_ACL, MOPT_SET}, | 1453 | {Opt_acl, EXT4_MOUNT_POSIX_ACL, MOPT_SET}, |
1459 | {Opt_noacl, EXT4_MOUNT_POSIX_ACL, MOPT_CLEAR}, | 1454 | {Opt_noacl, EXT4_MOUNT_POSIX_ACL, MOPT_CLEAR}, |
@@ -3202,7 +3197,6 @@ int ext4_calculate_overhead(struct super_block *sb) | |||
3202 | ext4_fsblk_t overhead = 0; | 3197 | ext4_fsblk_t overhead = 0; |
3203 | char *buf = (char *) get_zeroed_page(GFP_KERNEL); | 3198 | char *buf = (char *) get_zeroed_page(GFP_KERNEL); |
3204 | 3199 | ||
3205 | memset(buf, 0, PAGE_SIZE); | ||
3206 | if (!buf) | 3200 | if (!buf) |
3207 | return -ENOMEM; | 3201 | return -ENOMEM; |
3208 | 3202 | ||
@@ -3256,7 +3250,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
3256 | unsigned int i; | 3250 | unsigned int i; |
3257 | int needs_recovery, has_huge_files, has_bigalloc; | 3251 | int needs_recovery, has_huge_files, has_bigalloc; |
3258 | __u64 blocks_count; | 3252 | __u64 blocks_count; |
3259 | int err; | 3253 | int err = 0; |
3260 | unsigned int journal_ioprio = DEFAULT_JOURNAL_IOPRIO; | 3254 | unsigned int journal_ioprio = DEFAULT_JOURNAL_IOPRIO; |
3261 | ext4_group_t first_not_zeroed; | 3255 | ext4_group_t first_not_zeroed; |
3262 | 3256 | ||
@@ -3272,9 +3266,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
3272 | } | 3266 | } |
3273 | sb->s_fs_info = sbi; | 3267 | sb->s_fs_info = sbi; |
3274 | sbi->s_sb = sb; | 3268 | sbi->s_sb = sb; |
3275 | sbi->s_mount_opt = 0; | ||
3276 | sbi->s_resuid = make_kuid(&init_user_ns, EXT4_DEF_RESUID); | ||
3277 | sbi->s_resgid = make_kgid(&init_user_ns, EXT4_DEF_RESGID); | ||
3278 | sbi->s_inode_readahead_blks = EXT4_DEF_INODE_READAHEAD_BLKS; | 3269 | sbi->s_inode_readahead_blks = EXT4_DEF_INODE_READAHEAD_BLKS; |
3279 | sbi->s_sb_block = sb_block; | 3270 | sbi->s_sb_block = sb_block; |
3280 | if (sb->s_bdev->bd_part) | 3271 | if (sb->s_bdev->bd_part) |
@@ -3285,6 +3276,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
3285 | for (cp = sb->s_id; (cp = strchr(cp, '/'));) | 3276 | for (cp = sb->s_id; (cp = strchr(cp, '/'));) |
3286 | *cp = '!'; | 3277 | *cp = '!'; |
3287 | 3278 | ||
3279 | /* -EINVAL is default */ | ||
3288 | ret = -EINVAL; | 3280 | ret = -EINVAL; |
3289 | blocksize = sb_min_blocksize(sb, EXT4_MIN_BLOCK_SIZE); | 3281 | blocksize = sb_min_blocksize(sb, EXT4_MIN_BLOCK_SIZE); |
3290 | if (!blocksize) { | 3282 | if (!blocksize) { |
@@ -3369,9 +3361,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
3369 | if (def_mount_opts & EXT4_DEFM_UID16) | 3361 | if (def_mount_opts & EXT4_DEFM_UID16) |
3370 | set_opt(sb, NO_UID32); | 3362 | set_opt(sb, NO_UID32); |
3371 | /* xattr user namespace & acls are now defaulted on */ | 3363 | /* xattr user namespace & acls are now defaulted on */ |
3372 | #ifdef CONFIG_EXT4_FS_XATTR | ||
3373 | set_opt(sb, XATTR_USER); | 3364 | set_opt(sb, XATTR_USER); |
3374 | #endif | ||
3375 | #ifdef CONFIG_EXT4_FS_POSIX_ACL | 3365 | #ifdef CONFIG_EXT4_FS_POSIX_ACL |
3376 | set_opt(sb, POSIX_ACL); | 3366 | set_opt(sb, POSIX_ACL); |
3377 | #endif | 3367 | #endif |
@@ -3662,7 +3652,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
3662 | " too large to mount safely on this system"); | 3652 | " too large to mount safely on this system"); |
3663 | if (sizeof(sector_t) < 8) | 3653 | if (sizeof(sector_t) < 8) |
3664 | ext4_msg(sb, KERN_WARNING, "CONFIG_LBDAF not enabled"); | 3654 | ext4_msg(sb, KERN_WARNING, "CONFIG_LBDAF not enabled"); |
3665 | ret = err; | ||
3666 | goto failed_mount; | 3655 | goto failed_mount; |
3667 | } | 3656 | } |
3668 | 3657 | ||
@@ -3770,7 +3759,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
3770 | } | 3759 | } |
3771 | if (err) { | 3760 | if (err) { |
3772 | ext4_msg(sb, KERN_ERR, "insufficient memory"); | 3761 | ext4_msg(sb, KERN_ERR, "insufficient memory"); |
3773 | ret = err; | ||
3774 | goto failed_mount3; | 3762 | goto failed_mount3; |
3775 | } | 3763 | } |
3776 | 3764 | ||
@@ -3801,7 +3789,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
3801 | 3789 | ||
3802 | INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */ | 3790 | INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */ |
3803 | mutex_init(&sbi->s_orphan_lock); | 3791 | mutex_init(&sbi->s_orphan_lock); |
3804 | sbi->s_resize_flags = 0; | ||
3805 | 3792 | ||
3806 | sb->s_root = NULL; | 3793 | sb->s_root = NULL; |
3807 | 3794 | ||
@@ -3897,8 +3884,8 @@ no_journal: | |||
3897 | if (es->s_overhead_clusters) | 3884 | if (es->s_overhead_clusters) |
3898 | sbi->s_overhead = le32_to_cpu(es->s_overhead_clusters); | 3885 | sbi->s_overhead = le32_to_cpu(es->s_overhead_clusters); |
3899 | else { | 3886 | else { |
3900 | ret = ext4_calculate_overhead(sb); | 3887 | err = ext4_calculate_overhead(sb); |
3901 | if (ret) | 3888 | if (err) |
3902 | goto failed_mount_wq; | 3889 | goto failed_mount_wq; |
3903 | } | 3890 | } |
3904 | 3891 | ||
@@ -3910,6 +3897,7 @@ no_journal: | |||
3910 | alloc_workqueue("ext4-dio-unwritten", WQ_MEM_RECLAIM | WQ_UNBOUND, 1); | 3897 | alloc_workqueue("ext4-dio-unwritten", WQ_MEM_RECLAIM | WQ_UNBOUND, 1); |
3911 | if (!EXT4_SB(sb)->dio_unwritten_wq) { | 3898 | if (!EXT4_SB(sb)->dio_unwritten_wq) { |
3912 | printk(KERN_ERR "EXT4-fs: failed to create DIO workqueue\n"); | 3899 | printk(KERN_ERR "EXT4-fs: failed to create DIO workqueue\n"); |
3900 | ret = -ENOMEM; | ||
3913 | goto failed_mount_wq; | 3901 | goto failed_mount_wq; |
3914 | } | 3902 | } |
3915 | 3903 | ||
@@ -4012,12 +4000,20 @@ no_journal: | |||
4012 | /* Enable quota usage during mount. */ | 4000 | /* Enable quota usage during mount. */ |
4013 | if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA) && | 4001 | if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA) && |
4014 | !(sb->s_flags & MS_RDONLY)) { | 4002 | !(sb->s_flags & MS_RDONLY)) { |
4015 | ret = ext4_enable_quotas(sb); | 4003 | err = ext4_enable_quotas(sb); |
4016 | if (ret) | 4004 | if (err) |
4017 | goto failed_mount7; | 4005 | goto failed_mount7; |
4018 | } | 4006 | } |
4019 | #endif /* CONFIG_QUOTA */ | 4007 | #endif /* CONFIG_QUOTA */ |
4020 | 4008 | ||
4009 | if (test_opt(sb, DISCARD)) { | ||
4010 | struct request_queue *q = bdev_get_queue(sb->s_bdev); | ||
4011 | if (!blk_queue_discard(q)) | ||
4012 | ext4_msg(sb, KERN_WARNING, | ||
4013 | "mounting with \"discard\" option, but " | ||
4014 | "the device does not support discard"); | ||
4015 | } | ||
4016 | |||
4021 | ext4_msg(sb, KERN_INFO, "mounted filesystem with%s. " | 4017 | ext4_msg(sb, KERN_INFO, "mounted filesystem with%s. " |
4022 | "Opts: %s%s%s", descr, sbi->s_es->s_mount_opts, | 4018 | "Opts: %s%s%s", descr, sbi->s_es->s_mount_opts, |
4023 | *sbi->s_es->s_mount_opts ? "; " : "", orig_data); | 4019 | *sbi->s_es->s_mount_opts ? "; " : "", orig_data); |
@@ -4084,7 +4080,7 @@ out_fail: | |||
4084 | kfree(sbi); | 4080 | kfree(sbi); |
4085 | out_free_orig: | 4081 | out_free_orig: |
4086 | kfree(orig_data); | 4082 | kfree(orig_data); |
4087 | return ret; | 4083 | return err ? err : ret; |
4088 | } | 4084 | } |
4089 | 4085 | ||
4090 | /* | 4086 | /* |
@@ -4790,7 +4786,7 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
4790 | 4786 | ||
4791 | buf->f_type = EXT4_SUPER_MAGIC; | 4787 | buf->f_type = EXT4_SUPER_MAGIC; |
4792 | buf->f_bsize = sb->s_blocksize; | 4788 | buf->f_bsize = sb->s_blocksize; |
4793 | buf->f_blocks = ext4_blocks_count(es) - EXT4_C2B(sbi, sbi->s_overhead); | 4789 | buf->f_blocks = ext4_blocks_count(es) - EXT4_C2B(sbi, overhead); |
4794 | bfree = percpu_counter_sum_positive(&sbi->s_freeclusters_counter) - | 4790 | bfree = percpu_counter_sum_positive(&sbi->s_freeclusters_counter) - |
4795 | percpu_counter_sum_positive(&sbi->s_dirtyclusters_counter); | 4791 | percpu_counter_sum_positive(&sbi->s_dirtyclusters_counter); |
4796 | /* prevent underflow in case that few free space is available */ | 4792 | /* prevent underflow in case that few free space is available */ |
@@ -5282,6 +5278,7 @@ static int __init ext4_init_fs(void) | |||
5282 | ext4_li_info = NULL; | 5278 | ext4_li_info = NULL; |
5283 | mutex_init(&ext4_li_mtx); | 5279 | mutex_init(&ext4_li_mtx); |
5284 | 5280 | ||
5281 | /* Build-time check for flags consistency */ | ||
5285 | ext4_check_flag_values(); | 5282 | ext4_check_flag_values(); |
5286 | 5283 | ||
5287 | for (i = 0; i < EXT4_WQ_HASH_SZ; i++) { | 5284 | for (i = 0; i < EXT4_WQ_HASH_SZ; i++) { |
@@ -5289,9 +5286,14 @@ static int __init ext4_init_fs(void) | |||
5289 | init_waitqueue_head(&ext4__ioend_wq[i]); | 5286 | init_waitqueue_head(&ext4__ioend_wq[i]); |
5290 | } | 5287 | } |
5291 | 5288 | ||
5292 | err = ext4_init_pageio(); | 5289 | err = ext4_init_es(); |
5293 | if (err) | 5290 | if (err) |
5294 | return err; | 5291 | return err; |
5292 | |||
5293 | err = ext4_init_pageio(); | ||
5294 | if (err) | ||
5295 | goto out7; | ||
5296 | |||
5295 | err = ext4_init_system_zone(); | 5297 | err = ext4_init_system_zone(); |
5296 | if (err) | 5298 | if (err) |
5297 | goto out6; | 5299 | goto out6; |
@@ -5341,6 +5343,9 @@ out5: | |||
5341 | ext4_exit_system_zone(); | 5343 | ext4_exit_system_zone(); |
5342 | out6: | 5344 | out6: |
5343 | ext4_exit_pageio(); | 5345 | ext4_exit_pageio(); |
5346 | out7: | ||
5347 | ext4_exit_es(); | ||
5348 | |||
5344 | return err; | 5349 | return err; |
5345 | } | 5350 | } |
5346 | 5351 | ||