device-dax: Set page->index
authorDan Williams <dan.j.williams@intel.com>
Sat, 14 Jul 2018 04:49:45 +0000 (21:49 -0700)
committerDave Jiang <dave.jiang@intel.com>
Fri, 20 Jul 2018 18:20:44 +0000 (11:20 -0700)
In support of enabling memory_failure() handling for device-dax
mappings, set ->index to the pgoff of the page. The rmap implementation
requires ->index to bound the search through the vma interval tree.

The ->index value is never cleared. There is no possibility for the
page to become associated with another pgoff while the device is
enabled. When the device is disabled the 'struct page' array for the
device is destroyed and ->index is reinitialized to zero.

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
drivers/dax/device.c

index 95cfcfd..361a110 100644 (file)
@@ -416,6 +416,7 @@ static vm_fault_t dev_dax_huge_fault(struct vm_fault *vmf,
 
        if (rc == VM_FAULT_NOPAGE) {
                unsigned long i;
+               pgoff_t pgoff;
 
                /*
                 * In the device-dax case the only possibility for a
@@ -423,6 +424,8 @@ static vm_fault_t dev_dax_huge_fault(struct vm_fault *vmf,
                 * mapped. No need to consider the zero page, or racing
                 * conflicting mappings.
                 */
+               pgoff = linear_page_index(vmf->vma, vmf->address
+                               & ~(fault_size - 1));
                for (i = 0; i < fault_size / PAGE_SIZE; i++) {
                        struct page *page;
 
@@ -430,6 +433,7 @@ static vm_fault_t dev_dax_huge_fault(struct vm_fault *vmf,
                        if (page->mapping)
                                continue;
                        page->mapping = filp->f_mapping;
+                       page->index = pgoff + i;
                }
        }
        dax_read_unlock(id);