dax: Fix huge page faults
authorMatthew Wilcox <willy@infradead.org>
Fri, 16 Nov 2018 20:19:13 +0000 (15:19 -0500)
committerMatthew Wilcox <willy@infradead.org>
Sat, 17 Nov 2018 17:07:53 +0000 (12:07 -0500)
commit0e40de0338d005f73d46898a21544cd26f01b4ce
tree219460210db66a66308167398ddc320252e30047
parentfda490d39fc0668d92e170d95c11e35a010019aa
dax: Fix huge page faults

Using xas_load() with a PMD-sized xa_state would work if either a
PMD-sized entry was present or a PTE sized entry was present in the
first 64 entries (of the 512 PTEs in a PMD on x86).  If there was no
PTE in the first 64 entries, grab_mapping_entry() would believe there
were no entries present, allocate a PMD-sized entry and overwrite the
PTE in the page cache.

Use xas_find_conflict() instead which turns out to simplify
both get_unlocked_entry() and grab_mapping_entry().  Also remove a
WARN_ON_ONCE from grab_mapping_entry() as it will have already triggered
in get_unlocked_entry().

Fixes: cfc93c6c6c96 ("dax: Convert dax_insert_pfn_mkwrite to XArray")
Signed-off-by: Matthew Wilcox <willy@infradead.org>
fs/dax.c