aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2016-09-30 02:02:29 -0400
committerTheodore Ts'o <tytso@mit.edu>2016-09-30 02:02:29 -0400
commit9b623df614576680cadeaa4d7e0b5884de8f7c17 (patch)
tree06860f5d4dac697ceb441b2ad0305610470d387a /fs/ext4
parent51e8137b82622d8ea22e993d613db568f11c1523 (diff)
ext4: unmap metadata when zeroing blocks
When zeroing blocks for DAX allocations, we also have to unmap aliases in the block device mappings. Otherwise writeback can overwrite zeros with stale data from block device page cache. Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: stable@kernel.org
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/inode.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index d8a4afc5eedb..cd918823b352 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -647,11 +647,19 @@ found:
647 /* 647 /*
648 * We have to zeroout blocks before inserting them into extent 648 * We have to zeroout blocks before inserting them into extent
649 * status tree. Otherwise someone could look them up there and 649 * status tree. Otherwise someone could look them up there and
650 * use them before they are really zeroed. 650 * use them before they are really zeroed. We also have to
651 * unmap metadata before zeroing as otherwise writeback can
652 * overwrite zeros with stale data from block device.
651 */ 653 */
652 if (flags & EXT4_GET_BLOCKS_ZERO && 654 if (flags & EXT4_GET_BLOCKS_ZERO &&
653 map->m_flags & EXT4_MAP_MAPPED && 655 map->m_flags & EXT4_MAP_MAPPED &&
654 map->m_flags & EXT4_MAP_NEW) { 656 map->m_flags & EXT4_MAP_NEW) {
657 ext4_lblk_t i;
658
659 for (i = 0; i < map->m_len; i++) {
660 unmap_underlying_metadata(inode->i_sb->s_bdev,
661 map->m_pblk + i);
662 }
655 ret = ext4_issue_zeroout(inode, map->m_lblk, 663 ret = ext4_issue_zeroout(inode, map->m_lblk,
656 map->m_pblk, map->m_len); 664 map->m_pblk, map->m_len);
657 if (ret) { 665 if (ret) {