ext4: call journal revoke when freeing ea_inode blocks
authorTahsin Erdogan <tahsin@google.com>
Thu, 22 Jun 2017 01:36:51 +0000 (21:36 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 22 Jun 2017 01:36:51 +0000 (21:36 -0400)
ea_inode contents are treated as metadata, that's why it is journaled
during initial writes. Failing to call revoke during freeing could cause
user data to be overwritten with original ea_inode contents during journal
replay.

Signed-off-by: Tahsin Erdogan <tahsin@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/extents.c
fs/ext4/indirect.c

index 3e36508610b796b6612cc1e670a0fc2c8c3c282a..e0a8425ff74da9e60427f09f5525e1bc85952d51 100644 (file)
@@ -2488,7 +2488,8 @@ int ext4_ext_index_trans_blocks(struct inode *inode, int extents)
 
 static inline int get_default_free_blocks_flags(struct inode *inode)
 {
-       if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))
+       if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode) ||
+           ext4_test_inode_flag(inode, EXT4_INODE_EA_INODE))
                return EXT4_FREE_BLOCKS_METADATA | EXT4_FREE_BLOCKS_FORGET;
        else if (ext4_should_journal_data(inode))
                return EXT4_FREE_BLOCKS_FORGET;
index bc15c2c17633079a54de855baf1272b0124f19eb..7ffa290cbb8e7d2fe9cf6ac605833f0b827318f8 100644 (file)
@@ -829,7 +829,8 @@ static int ext4_clear_blocks(handle_t *handle, struct inode *inode,
        int     flags = EXT4_FREE_BLOCKS_VALIDATED;
        int     err;
 
-       if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))
+       if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode) ||
+           ext4_test_inode_flag(inode, EXT4_INODE_EA_INODE))
                flags |= EXT4_FREE_BLOCKS_FORGET | EXT4_FREE_BLOCKS_METADATA;
        else if (ext4_should_journal_data(inode))
                flags |= EXT4_FREE_BLOCKS_FORGET;