Skip to content

Commit 348e967

Browse files
jankaraRoss Zwisler
authored andcommitted
dax: Make huge page handling depend of CONFIG_BROKEN
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 <[email protected]> Signed-off-by: Ross Zwisler <[email protected]>
1 parent b995353 commit 348e967

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

fs/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ config FS_DAX_PMD
5252
depends on FS_DAX
5353
depends on ZONE_DEVICE
5454
depends on TRANSPARENT_HUGEPAGE
55+
depends on BROKEN
5556

5657
endif # BLOCK
5758

fs/dax.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ int dax_fault(struct vm_area_struct *vma, struct vm_fault *vmf,
675675
}
676676
EXPORT_SYMBOL_GPL(dax_fault);
677677

678-
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
678+
#if defined(CONFIG_TRANSPARENT_HUGEPAGE)
679679
/*
680680
* The 'colour' (ie low bits) within a PMD of a page offset. This comes up
681681
* more often than one might expect in the below function.

include/linux/dax.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static inline int __dax_zero_page_range(struct block_device *bdev,
2929
}
3030
#endif
3131

32-
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
32+
#if defined(CONFIG_TRANSPARENT_HUGEPAGE)
3333
int dax_pmd_fault(struct vm_area_struct *, unsigned long addr, pmd_t *,
3434
unsigned int flags, get_block_t);
3535
int __dax_pmd_fault(struct vm_area_struct *, unsigned long addr, pmd_t *,

0 commit comments

Comments
 (0)