aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-07-13 16:14:55 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-07-13 16:14:55 -0400
commit18b34d9a7a085ba8f9cafa6a0d002e2cbac87c1f (patch)
tree939755a58a68aae5e1241b2a905ea612aeb2e589 /fs
parent502fde1a0a2990ec54eab5241d3135c545da7372 (diff)
parentbf40c92635d63fcc574c52649f7cda13e0418ac1 (diff)
Merge tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4
Pull ext4 bugfixes from Ted Ts'o: "More bug fixes for ext4 -- most importantly, a fix for a bug introduced in 3.15 that can end up triggering a file system corruption error after a journal replay. It shouldn't lead to any actual data corruption, but it is scary and can force file systems to be remounted read-only, etc" * tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: ext4: fix potential null pointer dereference in ext4_free_inode ext4: fix a potential deadlock in __ext4_es_shrink() ext4: revert commit which was causing fs corruption after journal replays ext4: disable synchronous transaction batching if max_batch_time==0 ext4: clarify ext4_error message in ext4_mb_generate_buddy_error() ext4: clarify error count warning messages ext4: fix unjournalled bg descriptor while initializing inode bitmap
Diffstat (limited to 'fs')
-rw-r--r--fs/ext4/extents_status.c4
-rw-r--r--fs/ext4/ialloc.c16
-rw-r--r--fs/ext4/mballoc.c4
-rw-r--r--fs/ext4/super.c60
-rw-r--r--fs/jbd2/transaction.c5
5 files changed, 44 insertions, 45 deletions
diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
index 3f5c188953a4..0b7e28e7eaa4 100644
--- a/fs/ext4/extents_status.c
+++ b/fs/ext4/extents_status.c
@@ -966,10 +966,10 @@ retry:
966 continue; 966 continue;
967 } 967 }
968 968
969 if (ei->i_es_lru_nr == 0 || ei == locked_ei) 969 if (ei->i_es_lru_nr == 0 || ei == locked_ei ||
970 !write_trylock(&ei->i_es_lock))
970 continue; 971 continue;
971 972
972 write_lock(&ei->i_es_lock);
973 shrunk = __es_try_to_reclaim_extents(ei, nr_to_scan); 973 shrunk = __es_try_to_reclaim_extents(ei, nr_to_scan);
974 if (ei->i_es_lru_nr == 0) 974 if (ei->i_es_lru_nr == 0)
975 list_del_init(&ei->i_es_lru); 975 list_del_init(&ei->i_es_lru);
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index a87455df38bc..5b87fc36aab8 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -338,7 +338,7 @@ out:
338 fatal = err; 338 fatal = err;
339 } else { 339 } else {
340 ext4_error(sb, "bit already cleared for inode %lu", ino); 340 ext4_error(sb, "bit already cleared for inode %lu", ino);
341 if (!EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) { 341 if (gdp && !EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) {
342 int count; 342 int count;
343 count = ext4_free_inodes_count(sb, gdp); 343 count = ext4_free_inodes_count(sb, gdp);
344 percpu_counter_sub(&sbi->s_freeinodes_counter, 344 percpu_counter_sub(&sbi->s_freeinodes_counter,
@@ -874,6 +874,13 @@ got:
874 goto out; 874 goto out;
875 } 875 }
876 876
877 BUFFER_TRACE(group_desc_bh, "get_write_access");
878 err = ext4_journal_get_write_access(handle, group_desc_bh);
879 if (err) {
880 ext4_std_error(sb, err);
881 goto out;
882 }
883
877 /* We may have to initialize the block bitmap if it isn't already */ 884 /* We may have to initialize the block bitmap if it isn't already */
878 if (ext4_has_group_desc_csum(sb) && 885 if (ext4_has_group_desc_csum(sb) &&
879 gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) { 886 gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
@@ -910,13 +917,6 @@ got:
910 } 917 }
911 } 918 }
912 919
913 BUFFER_TRACE(group_desc_bh, "get_write_access");
914 err = ext4_journal_get_write_access(handle, group_desc_bh);
915 if (err) {
916 ext4_std_error(sb, err);
917 goto out;
918 }
919
920 /* Update the relevant bg descriptor fields */ 920 /* Update the relevant bg descriptor fields */
921 if (ext4_has_group_desc_csum(sb)) { 921 if (ext4_has_group_desc_csum(sb)) {
922 int free; 922 int free;
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 7f72f50a8fa7..2dcb936be90e 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -752,8 +752,8 @@ void ext4_mb_generate_buddy(struct super_block *sb,
752 752
753 if (free != grp->bb_free) { 753 if (free != grp->bb_free) {
754 ext4_grp_locked_error(sb, group, 0, 0, 754 ext4_grp_locked_error(sb, group, 0, 0,
755 "%u clusters in bitmap, %u in gd; " 755 "block bitmap and bg descriptor "
756 "block bitmap corrupt.", 756 "inconsistent: %u vs %u free clusters",
757 free, grp->bb_free); 757 free, grp->bb_free);
758 /* 758 /*
759 * If we intend to continue, we consider group descriptor 759 * If we intend to continue, we consider group descriptor
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index b9b9aabfb4d2..6df7bc611dbd 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1525,8 +1525,6 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
1525 arg = JBD2_DEFAULT_MAX_COMMIT_AGE; 1525 arg = JBD2_DEFAULT_MAX_COMMIT_AGE;
1526 sbi->s_commit_interval = HZ * arg; 1526 sbi->s_commit_interval = HZ * arg;
1527 } else if (token == Opt_max_batch_time) { 1527 } else if (token == Opt_max_batch_time) {
1528 if (arg == 0)
1529 arg = EXT4_DEF_MAX_BATCH_TIME;
1530 sbi->s_max_batch_time = arg; 1528 sbi->s_max_batch_time = arg;
1531 } else if (token == Opt_min_batch_time) { 1529 } else if (token == Opt_min_batch_time) {
1532 sbi->s_min_batch_time = arg; 1530 sbi->s_min_batch_time = arg;
@@ -2809,10 +2807,11 @@ static void print_daily_error_info(unsigned long arg)
2809 es = sbi->s_es; 2807 es = sbi->s_es;
2810 2808
2811 if (es->s_error_count) 2809 if (es->s_error_count)
2812 ext4_msg(sb, KERN_NOTICE, "error count: %u", 2810 /* fsck newer than v1.41.13 is needed to clean this condition. */
2811 ext4_msg(sb, KERN_NOTICE, "error count since last fsck: %u",
2813 le32_to_cpu(es->s_error_count)); 2812 le32_to_cpu(es->s_error_count));
2814 if (es->s_first_error_time) { 2813 if (es->s_first_error_time) {
2815 printk(KERN_NOTICE "EXT4-fs (%s): initial error at %u: %.*s:%d", 2814 printk(KERN_NOTICE "EXT4-fs (%s): initial error at time %u: %.*s:%d",
2816 sb->s_id, le32_to_cpu(es->s_first_error_time), 2815 sb->s_id, le32_to_cpu(es->s_first_error_time),
2817 (int) sizeof(es->s_first_error_func), 2816 (int) sizeof(es->s_first_error_func),
2818 es->s_first_error_func, 2817 es->s_first_error_func,
@@ -2826,7 +2825,7 @@ static void print_daily_error_info(unsigned long arg)
2826 printk("\n"); 2825 printk("\n");
2827 } 2826 }
2828 if (es->s_last_error_time) { 2827 if (es->s_last_error_time) {
2829 printk(KERN_NOTICE "EXT4-fs (%s): last error at %u: %.*s:%d", 2828 printk(KERN_NOTICE "EXT4-fs (%s): last error at time %u: %.*s:%d",
2830 sb->s_id, le32_to_cpu(es->s_last_error_time), 2829 sb->s_id, le32_to_cpu(es->s_last_error_time),
2831 (int) sizeof(es->s_last_error_func), 2830 (int) sizeof(es->s_last_error_func),
2832 es->s_last_error_func, 2831 es->s_last_error_func,
@@ -3880,38 +3879,19 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3880 goto failed_mount2; 3879 goto failed_mount2;
3881 } 3880 }
3882 } 3881 }
3883
3884 /*
3885 * set up enough so that it can read an inode,
3886 * and create new inode for buddy allocator
3887 */
3888 sbi->s_gdb_count = db_count;
3889 if (!test_opt(sb, NOLOAD) &&
3890 EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL))
3891 sb->s_op = &ext4_sops;
3892 else
3893 sb->s_op = &ext4_nojournal_sops;
3894
3895 ext4_ext_init(sb);
3896 err = ext4_mb_init(sb);
3897 if (err) {
3898 ext4_msg(sb, KERN_ERR, "failed to initialize mballoc (%d)",
3899 err);
3900 goto failed_mount2;
3901 }
3902
3903 if (!ext4_check_descriptors(sb, &first_not_zeroed)) { 3882 if (!ext4_check_descriptors(sb, &first_not_zeroed)) {
3904 ext4_msg(sb, KERN_ERR, "group descriptors corrupted!"); 3883 ext4_msg(sb, KERN_ERR, "group descriptors corrupted!");
3905 goto failed_mount2a; 3884 goto failed_mount2;
3906 } 3885 }
3907 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG)) 3886 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG))
3908 if (!ext4_fill_flex_info(sb)) { 3887 if (!ext4_fill_flex_info(sb)) {
3909 ext4_msg(sb, KERN_ERR, 3888 ext4_msg(sb, KERN_ERR,
3910 "unable to initialize " 3889 "unable to initialize "
3911 "flex_bg meta info!"); 3890 "flex_bg meta info!");
3912 goto failed_mount2a; 3891 goto failed_mount2;
3913 } 3892 }
3914 3893
3894 sbi->s_gdb_count = db_count;
3915 get_random_bytes(&sbi->s_next_generation, sizeof(u32)); 3895 get_random_bytes(&sbi->s_next_generation, sizeof(u32));
3916 spin_lock_init(&sbi->s_next_gen_lock); 3896 spin_lock_init(&sbi->s_next_gen_lock);
3917 3897
@@ -3946,6 +3926,14 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3946 sbi->s_stripe = ext4_get_stripe_size(sbi); 3926 sbi->s_stripe = ext4_get_stripe_size(sbi);
3947 sbi->s_extent_max_zeroout_kb = 32; 3927 sbi->s_extent_max_zeroout_kb = 32;
3948 3928
3929 /*
3930 * set up enough so that it can read an inode
3931 */
3932 if (!test_opt(sb, NOLOAD) &&
3933 EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL))
3934 sb->s_op = &ext4_sops;
3935 else
3936 sb->s_op = &ext4_nojournal_sops;
3949 sb->s_export_op = &ext4_export_ops; 3937 sb->s_export_op = &ext4_export_ops;
3950 sb->s_xattr = ext4_xattr_handlers; 3938 sb->s_xattr = ext4_xattr_handlers;
3951#ifdef CONFIG_QUOTA 3939#ifdef CONFIG_QUOTA
@@ -4135,13 +4123,21 @@ no_journal:
4135 if (err) { 4123 if (err) {
4136 ext4_msg(sb, KERN_ERR, "failed to reserve %llu clusters for " 4124 ext4_msg(sb, KERN_ERR, "failed to reserve %llu clusters for "
4137 "reserved pool", ext4_calculate_resv_clusters(sb)); 4125 "reserved pool", ext4_calculate_resv_clusters(sb));
4138 goto failed_mount5; 4126 goto failed_mount4a;
4139 } 4127 }
4140 4128
4141 err = ext4_setup_system_zone(sb); 4129 err = ext4_setup_system_zone(sb);
4142 if (err) { 4130 if (err) {
4143 ext4_msg(sb, KERN_ERR, "failed to initialize system " 4131 ext4_msg(sb, KERN_ERR, "failed to initialize system "
4144 "zone (%d)", err); 4132 "zone (%d)", err);
4133 goto failed_mount4a;
4134 }
4135
4136 ext4_ext_init(sb);
4137 err = ext4_mb_init(sb);
4138 if (err) {
4139 ext4_msg(sb, KERN_ERR, "failed to initialize mballoc (%d)",
4140 err);
4145 goto failed_mount5; 4141 goto failed_mount5;
4146 } 4142 }
4147 4143
@@ -4218,8 +4214,11 @@ failed_mount8:
4218failed_mount7: 4214failed_mount7:
4219 ext4_unregister_li_request(sb); 4215 ext4_unregister_li_request(sb);
4220failed_mount6: 4216failed_mount6:
4221 ext4_release_system_zone(sb); 4217 ext4_mb_release(sb);
4222failed_mount5: 4218failed_mount5:
4219 ext4_ext_release(sb);
4220 ext4_release_system_zone(sb);
4221failed_mount4a:
4223 dput(sb->s_root); 4222 dput(sb->s_root);
4224 sb->s_root = NULL; 4223 sb->s_root = NULL;
4225failed_mount4: 4224failed_mount4:
@@ -4243,14 +4242,11 @@ failed_mount3:
4243 percpu_counter_destroy(&sbi->s_extent_cache_cnt); 4242 percpu_counter_destroy(&sbi->s_extent_cache_cnt);
4244 if (sbi->s_mmp_tsk) 4243 if (sbi->s_mmp_tsk)
4245 kthread_stop(sbi->s_mmp_tsk); 4244 kthread_stop(sbi->s_mmp_tsk);
4246failed_mount2a:
4247 ext4_mb_release(sb);
4248failed_mount2: 4245failed_mount2:
4249 for (i = 0; i < db_count; i++) 4246 for (i = 0; i < db_count; i++)
4250 brelse(sbi->s_group_desc[i]); 4247 brelse(sbi->s_group_desc[i]);
4251 ext4_kvfree(sbi->s_group_desc); 4248 ext4_kvfree(sbi->s_group_desc);
4252failed_mount: 4249failed_mount:
4253 ext4_ext_release(sb);
4254 if (sbi->s_chksum_driver) 4250 if (sbi->s_chksum_driver)
4255 crypto_free_shash(sbi->s_chksum_driver); 4251 crypto_free_shash(sbi->s_chksum_driver);
4256 if (sbi->s_proc) { 4252 if (sbi->s_proc) {
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index 38cfcf5f6fce..6f0f590cc5a3 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -1588,9 +1588,12 @@ int jbd2_journal_stop(handle_t *handle)
1588 * to perform a synchronous write. We do this to detect the 1588 * to perform a synchronous write. We do this to detect the
1589 * case where a single process is doing a stream of sync 1589 * case where a single process is doing a stream of sync
1590 * writes. No point in waiting for joiners in that case. 1590 * writes. No point in waiting for joiners in that case.
1591 *
1592 * Setting max_batch_time to 0 disables this completely.
1591 */ 1593 */
1592 pid = current->pid; 1594 pid = current->pid;
1593 if (handle->h_sync && journal->j_last_sync_writer != pid) { 1595 if (handle->h_sync && journal->j_last_sync_writer != pid &&
1596 journal->j_max_batch_time) {
1594 u64 commit_time, trans_time; 1597 u64 commit_time, trans_time;
1595 1598
1596 journal->j_last_sync_writer = pid; 1599 journal->j_last_sync_writer = pid;