DAX uses the DAX_ZERO_PAGE bit to represent holes in files. It could also use a single entry, such as XArray's XA_ZERO_ENTRY. This distinguishes zero pages and allows us to shift DAX_EMPTY down (see patch 2/3). Signed-off-by: Amy Parker <enbyamy@xxxxxxxxx> --- fs/dax.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 5b47834f2e1b..fa8ca1a71bbd 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -77,9 +77,14 @@ fs_initcall(init_dax_wait_table); #define DAX_SHIFT (4) #define DAX_LOCKED (1UL << 0) #define DAX_PMD (1UL << 1) -#define DAX_ZERO_PAGE (1UL << 2) #define DAX_EMPTY (1UL << 3) +/* + * A zero entry, XA_ZERO_ENTRY, is used to represent a zero page. This + * definition helps with checking if an entry is a PMD size. + */ +#define XA_ZERO_PMD_ENTRY DAX_PMD | (unsigned long)XA_ZERO_ENTRY + static unsigned long dax_to_pfn(void *entry) { return xa_to_value(entry) >> DAX_SHIFT; @@ -114,7 +119,7 @@ static bool dax_is_pte_entry(void *entry) static int dax_is_zero_entry(void *entry) { - return xa_to_value(entry) & DAX_ZERO_PAGE; + return xa_to_value(entry) & (unsigned long)XA_ZERO_ENTRY; } static int dax_is_empty_entry(void *entry) @@ -738,7 +743,7 @@ static void *dax_insert_entry(struct xa_state *xas, if (dirty) __mark_inode_dirty(mapping->host, I_DIRTY_PAGES); - if (dax_is_zero_entry(entry) && !(flags & DAX_ZERO_PAGE)) { + if (dax_is_zero_entry(entry) && !(flags & (unsigned long)XA_ZERO_ENTRY)) { unsigned long index = xas->xa_index; /* we are replacing a zero page with block mapping */ if (dax_is_pmd_entry(entry)) @@ -1047,7 +1052,7 @@ static vm_fault_t dax_load_hole(struct xa_state *xas, vm_fault_t ret; *entry = dax_insert_entry(xas, mapping, vmf, *entry, pfn, - DAX_ZERO_PAGE, false); + XA_ZERO_ENTRY, false); ret = vmf_insert_mixed(vmf->vma, vaddr, pfn); trace_dax_load_hole(inode, vmf, ret); @@ -1434,7 +1439,7 @@ static vm_fault_t dax_pmd_load_hole(struct xa_state *xas, struct vm_fault *vmf, pfn = page_to_pfn_t(zero_page); *entry = dax_insert_entry(xas, mapping, vmf, *entry, pfn, - DAX_PMD | DAX_ZERO_PAGE, false); + XA_ZERO_PMD_ENTRY, false); if (arch_needs_pgtable_deposit()) { pgtable = pte_alloc_one(vma->vm_mm); -- 2.29.2