dax: Fix dax_unlock_mapping_entry for PMD pages

Device DAX PMD pages do not set the PageHead bit for compound pages.
Fix for now by retrieving the PMD bit from the entry, but eventually we
will be passed the page size by the caller.

Reported-by: Dan Williams <dan.j.williams@intel.com>
Fixes: 9f32d221301c ("dax: Convert dax_lock_mapping_entry to XArray")
Signed-off-by: Matthew Wilcox <willy@infradead.org>

+8 -9
+8 -9
fs/dax.c
··· 98 98 return xa_mk_value(flags | (pfn_t_to_pfn(pfn) << DAX_SHIFT)); 99 99 } 100 100 101 - static void *dax_make_page_entry(struct page *page) 102 - { 103 - pfn_t pfn = page_to_pfn_t(page); 104 - return dax_make_entry(pfn, PageHead(page) ? DAX_PMD : 0); 105 - } 106 - 107 101 static bool dax_is_locked(void *entry) 108 102 { 109 103 return xa_to_value(entry) & DAX_LOCKED; ··· 110 116 return 0; 111 117 } 112 118 113 - static int dax_is_pmd_entry(void *entry) 119 + static unsigned long dax_is_pmd_entry(void *entry) 114 120 { 115 121 return xa_to_value(entry) & DAX_PMD; 116 122 } 117 123 118 - static int dax_is_pte_entry(void *entry) 124 + static bool dax_is_pte_entry(void *entry) 119 125 { 120 126 return !(xa_to_value(entry) & DAX_PMD); 121 127 } ··· 407 413 { 408 414 struct address_space *mapping = page->mapping; 409 415 XA_STATE(xas, &mapping->i_pages, page->index); 416 + void *entry; 410 417 411 418 if (S_ISCHR(mapping->host->i_mode)) 412 419 return; 413 420 414 - dax_unlock_entry(&xas, dax_make_page_entry(page)); 421 + rcu_read_lock(); 422 + entry = xas_load(&xas); 423 + rcu_read_unlock(); 424 + entry = dax_make_entry(page_to_pfn_t(page), dax_is_pmd_entry(entry)); 425 + dax_unlock_entry(&xas, entry); 415 426 } 416 427 417 428 /*