From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl0-f72.google.com (mail-pl0-f72.google.com [209.85.160.72]) by kanga.kvack.org (Postfix) with ESMTP id 8331E6B0008 for ; Tue, 22 May 2018 10:49:50 -0400 (EDT) Received: by mail-pl0-f72.google.com with SMTP id u7-v6so12350250plq.3 for ; Tue, 22 May 2018 07:49:50 -0700 (PDT) Received: from mga02.intel.com (mga02.intel.com. [134.134.136.20]) by mx.google.com with ESMTPS id bc11-v6si16081889plb.544.2018.05.22.07.49.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 07:49:49 -0700 (PDT) Subject: [PATCH 04/11] device-dax: set page->index From: Dan Williams Date: Tue, 22 May 2018 07:39:52 -0700 Message-ID: <152699999266.24093.18001031234939470569.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <152699997165.24093.12194490924829406111.stgit@dwillia2-desk3.amr.corp.intel.com> References: <152699997165.24093.12194490924829406111.stgit@dwillia2-desk3.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: linux-nvdimm@lists.01.org Cc: hch@lst.de, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, tony.luck@intel.com 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. Signed-off-by: Dan Williams --- drivers/dax/device.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/dax/device.c b/drivers/dax/device.c index 8e986478d48d..b33e45ee4f70 100644 --- a/drivers/dax/device.c +++ b/drivers/dax/device.c @@ -418,7 +418,10 @@ static vm_fault_t dev_dax_huge_fault(struct vm_fault *vmf, if (rc == VM_FAULT_NOPAGE) { unsigned long i; + pgoff_t pgoff; + pgoff = linear_page_index(vma, vmf->address + & ~(fault_size - 1)); for (i = 0; i < fault_size / PAGE_SIZE; i++) { struct page *page; @@ -426,6 +429,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);