Skip to content

Commit

Permalink
ext2: Unmap metadata when zeroing blocks
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jan Kara committed Sep 27, 2016
1 parent 5d3ddd8 commit 225c516
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions fs/ext2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,16 @@ static int ext2_get_blocks(struct inode *inode,
}

if (IS_DAX(inode)) {
int i;

/*
* We must unmap blocks before zeroing so that writeback cannot
* overwrite zeros with stale data from block device page cache.
*/
for (i = 0; i < count; i++) {
unmap_underlying_metadata(inode->i_sb->s_bdev,
le32_to_cpu(chain[depth-1].key) + i);
}
/*
* block must be initialised before we put it in the tree
* so that it's not found by another thread before it's
Expand Down

0 comments on commit 225c516

Please sign in to comment.