]> Git Repo - linux.git/commitdiff
ext4: fix invalid inode checksum
authorLuo Meng <[email protected]>
Tue, 20 Oct 2020 01:36:31 +0000 (09:36 +0800)
committerTheodore Ts'o <[email protected]>
Thu, 22 Oct 2020 03:22:38 +0000 (23:22 -0400)
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]>
fs/ext4/inode.c

index 43d6a07262d2a6585333877e677acd10476ed132..03c2253005f000722151a33c7324e8a83678b36b 100644 (file)
@@ -5030,6 +5030,12 @@ static int ext4_do_update_inode(handle_t *handle,
        if (ext4_test_inode_state(inode, EXT4_STATE_NEW))
                memset(raw_inode, 0, EXT4_SB(inode->i_sb)->s_inode_size);
 
+       err = ext4_inode_blocks_set(handle, raw_inode, ei);
+       if (err) {
+               spin_unlock(&ei->i_raw_lock);
+               goto out_brelse;
+       }
+
        raw_inode->i_mode = cpu_to_le16(inode->i_mode);
        i_uid = i_uid_read(inode);
        i_gid = i_gid_read(inode);
@@ -5063,11 +5069,6 @@ static int ext4_do_update_inode(handle_t *handle,
        EXT4_INODE_SET_XTIME(i_atime, inode, raw_inode);
        EXT4_EINODE_SET_XTIME(i_crtime, ei, raw_inode);
 
-       err = ext4_inode_blocks_set(handle, raw_inode, ei);
-       if (err) {
-               spin_unlock(&ei->i_raw_lock);
-               goto out_brelse;
-       }
        raw_inode->i_dtime = cpu_to_le32(ei->i_dtime);
        raw_inode->i_flags = cpu_to_le32(ei->i_flags & 0xFFFFFFFF);
        if (likely(!test_opt2(inode->i_sb, HURD_COMPAT)))
This page took 0.068125 seconds and 4 git commands to generate.