]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
dax: Make huge page handling depend of CONFIG_BROKEN
authorJan Kara <jack@suse.cz>
Thu, 12 May 2016 16:29:15 +0000 (18:29 +0200)
committerRoss Zwisler <ross.zwisler@linux.intel.com>
Thu, 19 May 2016 21:13:17 +0000 (15:13 -0600)
Currently the handling of huge pages for DAX is racy. For example the
following can happen:

CPU0 (THP write fault) CPU1 (normal read fault)

__dax_pmd_fault() __dax_fault()
  get_block(inode, block, &bh, 0) -> not mapped
get_block(inode, block, &bh, 0)
  -> not mapped
  if (!buffer_mapped(&bh) && write)
    get_block(inode, block, &bh, 1) -> allocates blocks
  truncate_pagecache_range(inode, lstart, lend);
dax_load_hole();

This results in data corruption since process on CPU1 won't see changes
into the file done by CPU0.

The race can happen even if two normal faults race however with THP the
situation is even worse because the two faults don't operate on the same
entries in the radix tree and we want to use these entries for
serialization. So make THP support in DAX code depend on CONFIG_BROKEN
for now.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
fs/Kconfig
fs/dax.c
include/linux/dax.h

index 6725f59c18e6b5f6b2ddcabaf1c83bd3d7c48406..b8fcb416be72983e77a11d033f044d14685f8e07 100644 (file)
@@ -52,6 +52,7 @@ config FS_DAX_PMD
        depends on FS_DAX
        depends on ZONE_DEVICE
        depends on TRANSPARENT_HUGEPAGE
+       depends on BROKEN
 
 endif # BLOCK
 
index bdad05213e4b09249b6d64a63911182b608796fe..0433a2b5e484382caa0cb9f5570b825c28e9e6d0 100644 (file)
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -675,7 +675,7 @@ int dax_fault(struct vm_area_struct *vma, struct vm_fault *vmf,
 }
 EXPORT_SYMBOL_GPL(dax_fault);
 
-#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+#if defined(CONFIG_TRANSPARENT_HUGEPAGE)
 /*
  * The 'colour' (ie low bits) within a PMD of a page offset.  This comes up
  * more often than one might expect in the below function.
index 90fbc99e531341d39000badf201474284737aea1..72dc81de3ddbfa6d35838a3df3f8e2021d068bbf 100644 (file)
@@ -29,7 +29,7 @@ static inline int __dax_zero_page_range(struct block_device *bdev,
 }
 #endif
 
-#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+#if defined(CONFIG_TRANSPARENT_HUGEPAGE)
 int dax_pmd_fault(struct vm_area_struct *, unsigned long addr, pmd_t *,
                                unsigned int flags, get_block_t);
 int __dax_pmd_fault(struct vm_area_struct *, unsigned long addr, pmd_t *,