ext2: Avoid DAX zeroing to corrupt data
authorJan Kara <jack@suse.cz>
Wed, 11 May 2016 09:58:49 +0000 (11:58 +0200)
committerVishal Verma <vishal.l.verma@intel.com>
Tue, 17 May 2016 06:44:07 +0000 (00:44 -0600)
Currently ext2 zeroes any data blocks allocated for DAX inode however it
still returns them as BH_New. Thus DAX code zeroes them again in
dax_insert_mapping() which can possibly overwrite the data that has been
already stored to those blocks by a racing dax_io(). Avoid marking
pre-zeroed buffers as new.

Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
fs/ext2/inode.c

index 038d0ed5f5656e70875d8584cbe174aeddb34ba0..9a14af3b1a69c142e194d6ebc4800b3dc2bf488e 100644 (file)
@@ -745,11 +745,11 @@ static int ext2_get_blocks(struct inode *inode,
                        mutex_unlock(&ei->truncate_mutex);
                        goto cleanup;
                }
-       }
+       } else
+               set_buffer_new(bh_result);
 
        ext2_splice_branch(inode, iblock, partial, indirect_blks, count);
        mutex_unlock(&ei->truncate_mutex);
-       set_buffer_new(bh_result);
 got_it:
        map_bh(bh_result, inode->i_sb, le32_to_cpu(chain[depth-1].key));
        if (count > blocks_to_boundary)