Skip to content

Commit 357cc4c

Browse files
Luo Menggregkh
authored andcommitted
ext4: fix invalid inode checksum
commit 1322181 upstream. During the stability test, there are some errors: ext4_lookup:1590: inode #6967: comm fsstress: iget: checksum invalid. If the inode->i_iblocks too big and doesn't set huge file flag, checksum will not be recalculated when update the inode information to it's buffer. If other inode marks the buffer dirty, then the inconsistent inode will be flushed to disk. Fix this problem by checking i_blocks in advance. Cc: [email protected] Signed-off-by: Luo Meng <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 5676680 commit 357cc4c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

fs/ext4/inode.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4982,6 +4982,12 @@ static int ext4_do_update_inode(handle_t *handle,
49824982
if (ext4_test_inode_state(inode, EXT4_STATE_NEW))
49834983
memset(raw_inode, 0, EXT4_SB(inode->i_sb)->s_inode_size);
49844984

4985+
err = ext4_inode_blocks_set(handle, raw_inode, ei);
4986+
if (err) {
4987+
spin_unlock(&ei->i_raw_lock);
4988+
goto out_brelse;
4989+
}
4990+
49854991
raw_inode->i_mode = cpu_to_le16(inode->i_mode);
49864992
i_uid = i_uid_read(inode);
49874993
i_gid = i_gid_read(inode);
@@ -5015,11 +5021,6 @@ static int ext4_do_update_inode(handle_t *handle,
50155021
EXT4_INODE_SET_XTIME(i_atime, inode, raw_inode);
50165022
EXT4_EINODE_SET_XTIME(i_crtime, ei, raw_inode);
50175023

5018-
err = ext4_inode_blocks_set(handle, raw_inode, ei);
5019-
if (err) {
5020-
spin_unlock(&ei->i_raw_lock);
5021-
goto out_brelse;
5022-
}
50235024
raw_inode->i_dtime = cpu_to_le32(ei->i_dtime);
50245025
raw_inode->i_flags = cpu_to_le32(ei->i_flags & 0xFFFFFFFF);
50255026
if (likely(!test_opt2(inode->i_sb, HURD_COMPAT)))

0 commit comments

Comments
 (0)