Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
fork

Configure Feed

Select the types of activity you want to include in your feed.

ext4: revert commit which was causing fs corruption after journal replays

Commit 007649375f6af2 ("ext4: initialize multi-block allocator before
checking block descriptors") causes the block group descriptor's count
of the number of free blocks to become inconsistent with the number of
free blocks in the allocation bitmap. This is a harmless form of fs
corruption, but it causes the kernel to potentially remount the file
system read-only, or to panic, depending on the file systems's error
behavior.

Thanks to Eric Whitney for his tireless work to reproduce and to find
the guilty commit.

Fixes: 007649375f6af2 ("ext4: initialize multi-block allocator before checking block descriptors"

Cc: stable@vger.kernel.org # 3.15
Reported-by: David Jander <david@protonic.nl>
Reported-by: Matteo Croce <technoboy85@gmail.com>
Tested-by: Eric Whitney <enwlinux@gmail.com>
Suggested-by: Eric Whitney <enwlinux@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>

+24 -27
+24 -27
fs/ext4/super.c
··· 3879 3879 goto failed_mount2; 3880 3880 } 3881 3881 } 3882 - 3883 - /* 3884 - * set up enough so that it can read an inode, 3885 - * and create new inode for buddy allocator 3886 - */ 3887 - sbi->s_gdb_count = db_count; 3888 - if (!test_opt(sb, NOLOAD) && 3889 - EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) 3890 - sb->s_op = &ext4_sops; 3891 - else 3892 - sb->s_op = &ext4_nojournal_sops; 3893 - 3894 - ext4_ext_init(sb); 3895 - err = ext4_mb_init(sb); 3896 - if (err) { 3897 - ext4_msg(sb, KERN_ERR, "failed to initialize mballoc (%d)", 3898 - err); 3899 - goto failed_mount2; 3900 - } 3901 - 3902 3882 if (!ext4_check_descriptors(sb, &first_not_zeroed)) { 3903 3883 ext4_msg(sb, KERN_ERR, "group descriptors corrupted!"); 3904 - goto failed_mount2a; 3884 + goto failed_mount2; 3905 3885 } 3906 3886 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG)) 3907 3887 if (!ext4_fill_flex_info(sb)) { 3908 3888 ext4_msg(sb, KERN_ERR, 3909 3889 "unable to initialize " 3910 3890 "flex_bg meta info!"); 3911 - goto failed_mount2a; 3891 + goto failed_mount2; 3912 3892 } 3913 3893 3894 + sbi->s_gdb_count = db_count; 3914 3895 get_random_bytes(&sbi->s_next_generation, sizeof(u32)); 3915 3896 spin_lock_init(&sbi->s_next_gen_lock); 3916 3897 ··· 3926 3945 sbi->s_stripe = ext4_get_stripe_size(sbi); 3927 3946 sbi->s_extent_max_zeroout_kb = 32; 3928 3947 3948 + /* 3949 + * set up enough so that it can read an inode 3950 + */ 3951 + if (!test_opt(sb, NOLOAD) && 3952 + EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) 3953 + sb->s_op = &ext4_sops; 3954 + else 3955 + sb->s_op = &ext4_nojournal_sops; 3929 3956 sb->s_export_op = &ext4_export_ops; 3930 3957 sb->s_xattr = ext4_xattr_handlers; 3931 3958 #ifdef CONFIG_QUOTA ··· 4123 4134 if (err) { 4124 4135 ext4_msg(sb, KERN_ERR, "failed to reserve %llu clusters for " 4125 4136 "reserved pool", ext4_calculate_resv_clusters(sb)); 4126 - goto failed_mount5; 4137 + goto failed_mount4a; 4127 4138 } 4128 4139 4129 4140 err = ext4_setup_system_zone(sb); 4130 4141 if (err) { 4131 4142 ext4_msg(sb, KERN_ERR, "failed to initialize system " 4132 4143 "zone (%d)", err); 4144 + goto failed_mount4a; 4145 + } 4146 + 4147 + ext4_ext_init(sb); 4148 + err = ext4_mb_init(sb); 4149 + if (err) { 4150 + ext4_msg(sb, KERN_ERR, "failed to initialize mballoc (%d)", 4151 + err); 4133 4152 goto failed_mount5; 4134 4153 } 4135 4154 ··· 4214 4217 failed_mount7: 4215 4218 ext4_unregister_li_request(sb); 4216 4219 failed_mount6: 4217 - ext4_release_system_zone(sb); 4220 + ext4_mb_release(sb); 4218 4221 failed_mount5: 4222 + ext4_ext_release(sb); 4223 + ext4_release_system_zone(sb); 4224 + failed_mount4a: 4219 4225 dput(sb->s_root); 4220 4226 sb->s_root = NULL; 4221 4227 failed_mount4: ··· 4242 4242 percpu_counter_destroy(&sbi->s_extent_cache_cnt); 4243 4243 if (sbi->s_mmp_tsk) 4244 4244 kthread_stop(sbi->s_mmp_tsk); 4245 - failed_mount2a: 4246 - ext4_mb_release(sb); 4247 4245 failed_mount2: 4248 4246 for (i = 0; i < db_count; i++) 4249 4247 brelse(sbi->s_group_desc[i]); 4250 4248 ext4_kvfree(sbi->s_group_desc); 4251 4249 failed_mount: 4252 - ext4_ext_release(sb); 4253 4250 if (sbi->s_chksum_driver) 4254 4251 crypto_free_shash(sbi->s_chksum_driver); 4255 4252 if (sbi->s_proc) {