Skip to content

Commit 8c673cb

Browse files
committed
Merge tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4
Pull ext4 bugfix from Ted Ts'o: "This fixes the root cause of the ext4 data corruption bug which raised a ruckus on LWN, Phoronix, and Slashdot. This bug only showed up when non-standard mount options (journal_async_commit and/or journal_checksum) were enabled, and when the file system was not cleanly unmounted, but the root cause was the inode bitmap modifications was not being properly journaled. This could potentially lead to minor file system corruptions (pass 5 complaints with the inode allocation bitmap) after an unclean shutdown under the wrong/unlucky workloads, but it turned into major failure if the journal_checksum and/or jouaral_async_commit was enabled." * tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: ext4: fix unjournaled inode bitmap modification
2 parents 4476c0e + ffb5387 commit 8c673cb

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

fs/ext4/ialloc.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,10 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, umode_t mode,
725725
"inode=%lu", ino + 1);
726726
continue;
727727
}
728+
BUFFER_TRACE(inode_bitmap_bh, "get_write_access");
729+
err = ext4_journal_get_write_access(handle, inode_bitmap_bh);
730+
if (err)
731+
goto fail;
728732
ext4_lock_group(sb, group);
729733
ret2 = ext4_test_and_set_bit(ino, inode_bitmap_bh->b_data);
730734
ext4_unlock_group(sb, group);
@@ -738,6 +742,11 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, umode_t mode,
738742
goto out;
739743

740744
got:
745+
BUFFER_TRACE(inode_bitmap_bh, "call ext4_handle_dirty_metadata");
746+
err = ext4_handle_dirty_metadata(handle, NULL, inode_bitmap_bh);
747+
if (err)
748+
goto fail;
749+
741750
/* We may have to initialize the block bitmap if it isn't already */
742751
if (ext4_has_group_desc_csum(sb) &&
743752
gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
@@ -771,11 +780,6 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, umode_t mode,
771780
goto fail;
772781
}
773782

774-
BUFFER_TRACE(inode_bitmap_bh, "get_write_access");
775-
err = ext4_journal_get_write_access(handle, inode_bitmap_bh);
776-
if (err)
777-
goto fail;
778-
779783
BUFFER_TRACE(group_desc_bh, "get_write_access");
780784
err = ext4_journal_get_write_access(handle, group_desc_bh);
781785
if (err)
@@ -823,11 +827,6 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, umode_t mode,
823827
}
824828
ext4_unlock_group(sb, group);
825829

826-
BUFFER_TRACE(inode_bitmap_bh, "call ext4_handle_dirty_metadata");
827-
err = ext4_handle_dirty_metadata(handle, NULL, inode_bitmap_bh);
828-
if (err)
829-
goto fail;
830-
831830
BUFFER_TRACE(group_desc_bh, "call ext4_handle_dirty_metadata");
832831
err = ext4_handle_dirty_metadata(handle, NULL, group_desc_bh);
833832
if (err)

0 commit comments

Comments
 (0)