]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ext2: Unmap metadata when zeroing blocks
authorJan Kara <jack@suse.cz>
Tue, 27 Sep 2016 14:35:45 +0000 (16:35 +0200)
committerJan Kara <jack@suse.cz>
Tue, 27 Sep 2016 16:16:55 +0000 (18:16 +0200)
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>
fs/ext2/inode.c

index d5c7d09919f318066c1be57cf446624875ba229a..303ae2bb269a269b1968ad9a1b354e02c475536d 100644 (file)
@@ -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