Skip to content

Commit

Permalink
device-dax: Set page->index
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dan Williams authored and Dave Jiang committed Jul 20, 2018
1 parent 2232c63 commit 35de299
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/dax/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,20 +416,24 @@ 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
* VM_FAULT_NOPAGE result is when device-dax capacity is
* 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;

page = pfn_to_page(pfn_t_to_pfn(pfn) + i);
if (page->mapping)
continue;
page->mapping = filp->f_mapping;
page->index = pgoff + i;
}
}
dax_read_unlock(id);
Expand Down

0 comments on commit 35de299

Please sign in to comment.