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 return xa_mk_value(flags | (pfn_t_to_pfn(pfn) << DAX_SHIFT)); 99 } 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 static bool dax_is_locked(void *entry) 108 { 109 return xa_to_value(entry) & DAX_LOCKED; ··· 110 return 0; 111 } 112 113 - static int dax_is_pmd_entry(void *entry) 114 { 115 return xa_to_value(entry) & DAX_PMD; 116 } 117 118 - static int dax_is_pte_entry(void *entry) 119 { 120 return !(xa_to_value(entry) & DAX_PMD); 121 } ··· 407 { 408 struct address_space *mapping = page->mapping; 409 XA_STATE(xas, &mapping->i_pages, page->index); 410 411 if (S_ISCHR(mapping->host->i_mode)) 412 return; 413 414 - dax_unlock_entry(&xas, dax_make_page_entry(page)); 415 } 416 417 /*
··· 98 return xa_mk_value(flags | (pfn_t_to_pfn(pfn) << DAX_SHIFT)); 99 } 100 101 static bool dax_is_locked(void *entry) 102 { 103 return xa_to_value(entry) & DAX_LOCKED; ··· 116 return 0; 117 } 118 119 + static unsigned long dax_is_pmd_entry(void *entry) 120 { 121 return xa_to_value(entry) & DAX_PMD; 122 } 123 124 + static bool dax_is_pte_entry(void *entry) 125 { 126 return !(xa_to_value(entry) & DAX_PMD); 127 } ··· 413 { 414 struct address_space *mapping = page->mapping; 415 XA_STATE(xas, &mapping->i_pages, page->index); 416 + void *entry; 417 418 if (S_ISCHR(mapping->host->i_mode)) 419 return; 420 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); 426 } 427 428 /*