diff options
author | Jan Kara <jack@suse.cz> | 2016-09-30 02:02:29 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-10-22 12:40:25 +0200 |
commit | fb13b62a14d586b9614ddaf23ea0fac364e317d3 (patch) | |
tree | 4f9dafac0659f9255f77842e20f676f30a957f2e /fs/ext4 | |
parent | ff50a7245ad01e5baf0b60fb30ebaf5e38bb83b6 (diff) | |
download | lwn-fb13b62a14d586b9614ddaf23ea0fac364e317d3.tar.gz lwn-fb13b62a14d586b9614ddaf23ea0fac364e317d3.zip |
ext4: unmap metadata when zeroing blocks
commit 9b623df614576680cadeaa4d7e0b5884de8f7c17 upstream.
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/inode.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index fd5b5e8ba9d4..f4cdc647ecfc 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -647,11 +647,19 @@ found: /* * We have to zeroout blocks before inserting them into extent * status tree. Otherwise someone could look them up there and - * use them before they are really zeroed. + * use them before they are really zeroed. We also have to + * unmap metadata before zeroing as otherwise writeback can + * overwrite zeros with stale data from block device. */ if (flags & EXT4_GET_BLOCKS_ZERO && map->m_flags & EXT4_MAP_MAPPED && map->m_flags & EXT4_MAP_NEW) { + ext4_lblk_t i; + + for (i = 0; i < map->m_len; i++) { + unmap_underlying_metadata(inode->i_sb->s_bdev, + map->m_pblk + i); + } ret = ext4_issue_zeroout(inode, map->m_lblk, map->m_pblk, map->m_len); if (ret) { |