From patchwork Sun Jun 3 05:23:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10445177 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4984F60234 for ; Sun, 3 Jun 2018 05:33:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3BFCC289D6 for ; Sun, 3 Jun 2018 05:33:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 28DCA28AFB; Sun, 3 Jun 2018 05:33:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5B5A289D6 for ; Sun, 3 Jun 2018 05:33:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4689B6B0266; Sun, 3 Jun 2018 01:33:09 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3EDC06B0269; Sun, 3 Jun 2018 01:33:09 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2915F6B026A; Sun, 3 Jun 2018 01:33:09 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg0-f69.google.com (mail-pg0-f69.google.com [74.125.83.69]) by kanga.kvack.org (Postfix) with ESMTP id DAE7F6B0266 for ; Sun, 3 Jun 2018 01:33:08 -0400 (EDT) Received: by mail-pg0-f69.google.com with SMTP id z20-v6so3864395pgv.17 for ; Sat, 02 Jun 2018 22:33:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:cc:date:message-id:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=eXX7XE3VE0Xp38gj3E9CvV4rXUeDyJ4U1qUIx23011w=; b=ADoPw/ivcxo52JgQx/NnFFxsdoanouPL5nTc2gsf99yTXN7Y2F+45LtA7I4AB5DwUT huEv+q4N9FnFhZIyq/EwBY81kuV+c1myw9Xb//Fckl+tnKODsZHbcS32wI+87UHgHJ2V 3znZslAv83cZT4SGh2x5HeHDLeLFLOvTv4KU/kXJ2LqcBsk3Gc5w+HmfdGo5UIuw4642 JnUqntqNdqIZ8+rSMT91le6vuq3C7rYUH/S+25/jS2fe0JS8MdmxHvwYrdeZ1iENJdUG sqEHA8NW0pRz28i/Bnnl1YvNp3WV/3mctufs+AEsCT9FFwHPCoqOv4VUkwVea8hjUmC7 MGEg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.93 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: ALKqPwd9lG0glXAU3zvxG27rouvn9Vn9ke63qS5NehdcS6Pq2etM+FwL mNd/a6NlyosN2q8O5SDrm8nks05sIoL8gPP105tT1KYg6U/FSY/67/FgBLCW77sRp4qzMy/P4kG CxABFtcx8wC4zj0AoJn2qfEqiR9cgthNi2EzXJj/hSiKiCuEWLY30e1BRtFcL+GXD/w== X-Received: by 2002:a65:608d:: with SMTP id t13-v6mr13316731pgu.266.1528003988548; Sat, 02 Jun 2018 22:33:08 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLJ5j/NbUBllxyrEMKMYV9mrRTdA6slsUFBIVflPXDUdZ2dNCWv+xQbku9K0UUS2Ah/gDYg X-Received: by 2002:a65:608d:: with SMTP id t13-v6mr13316714pgu.266.1528003987825; Sat, 02 Jun 2018 22:33:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528003987; cv=none; d=google.com; s=arc-20160816; b=wuGLAHjVaHj/a51xxs0s2DwZYHP3hVsbmoeAzuFex7/TmHsHyQgitVG2KMkjup8AqQ Al9UNPLkk2+05kcge1SPg7IPYw9t2l7gMa4JiH+MdK9CDvp1SCVwmm5oy/nlir9TIE8+ LRwbLksiNE+AWV+0YO23OuERZ//UkHXPdFMn1vxEVMdqhCM9AO7wHdVQShJzqTESn49W 1ti/Aa5PymQRpgA3Wf1wC1P2bPd4K/iw1epqxZW4WROCLSk0tz+vk09eM7kbMX7gTJKY fnvMB01LyrnzqFW8jlaC4u38uByGn6wi7OLEvVAbJbKXS+n7ZMaYwxvxB0xBvL81966P 9xDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject :arc-authentication-results; bh=eXX7XE3VE0Xp38gj3E9CvV4rXUeDyJ4U1qUIx23011w=; b=Y8f4Fc0Hx+sNfn4sy/pIgz3tCDyb9TSiroh953wEwlObY06FxUQU1WnrwqSnvBFpEw eawWGE8y8FkmcsHZQ8J7jkFFa3t6V37/n5gElBLIo5Pccr0nKMrAFGKkeD4Zd4oTRjf7 ZikNnDJVXqusOwPKkj5zsFnleve04wmqj9NbQ6qiDhi7yJY/F3kw1WGNRBYRo+7xQlGW 5E3LatN8mhC27CJMU0zdFPgaUI8u+wDxY2cn6yDZOVX0EbL0B23EiOmC9pCaxNc7qOYg 5c1hHWB8foYobSPnU04tzMd1L2MpC+vJwjdsgW6ydo07fRv7Gnk5jZ7lADhVkeGOybcE W2mg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.93 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga11.intel.com (mga11.intel.com. [192.55.52.93]) by mx.google.com with ESMTPS id c10-v6si24182843plz.190.2018.06.02.22.33.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Jun 2018 22:33:07 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.93 as permitted sender) client-ip=192.55.52.93; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.93 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Jun 2018 22:33:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,472,1520924400"; d="scan'208";a="233936495" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by fmsmga005.fm.intel.com with ESMTP; 02 Jun 2018 22:33:07 -0700 Subject: [PATCH v2 05/11] filesystem-dax: Set page->index From: Dan Williams To: linux-nvdimm@lists.01.org Cc: Jan Kara , Christoph Hellwig , Matthew Wilcox , Ross Zwisler , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, jack@suse.cz Date: Sat, 02 Jun 2018 22:23:10 -0700 Message-ID: <152800339039.17112.4951970414861706948.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <152800336321.17112.3300876636370683279.stgit@dwillia2-desk3.amr.corp.intel.com> References: <152800336321.17112.3300876636370683279.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP In support of enabling memory_failure() handling for filesystem-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 is set and cleared at dax_associate_entry() and dax_disassociate_entry() time respectively. Cc: Jan Kara Cc: Christoph Hellwig Cc: Matthew Wilcox Cc: Ross Zwisler Signed-off-by: Dan Williams --- fs/dax.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index aaec72ded1b6..cccf6cad1a7a 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -319,18 +319,27 @@ static unsigned long dax_radix_end_pfn(void *entry) for (pfn = dax_radix_pfn(entry); \ pfn < dax_radix_end_pfn(entry); pfn++) -static void dax_associate_entry(void *entry, struct address_space *mapping) +/* + * TODO: for reflink+dax we need a way to associate a single page with + * multiple address_space instances at different linear_page_index() + * offsets. + */ +static void dax_associate_entry(void *entry, struct address_space *mapping, + struct vm_area_struct *vma, unsigned long address) { - unsigned long pfn; + unsigned long size = dax_entry_size(entry), pfn, index; + int i = 0; if (IS_ENABLED(CONFIG_FS_DAX_LIMITED)) return; + index = linear_page_index(vma, address & ~(size - 1)); for_each_mapped_pfn(entry, pfn) { struct page *page = pfn_to_page(pfn); WARN_ON_ONCE(page->mapping); page->mapping = mapping; + page->index = index + i++; } } @@ -348,6 +357,7 @@ static void dax_disassociate_entry(void *entry, struct address_space *mapping, WARN_ON_ONCE(trunc && page_ref_count(page) > 1); WARN_ON_ONCE(page->mapping && page->mapping != mapping); page->mapping = NULL; + page->index = 0; } } @@ -604,7 +614,7 @@ static void *dax_insert_mapping_entry(struct address_space *mapping, new_entry = dax_radix_locked_entry(pfn, flags); if (dax_entry_size(entry) != dax_entry_size(new_entry)) { dax_disassociate_entry(entry, mapping, false); - dax_associate_entry(new_entry, mapping); + dax_associate_entry(new_entry, mapping, vmf->vma, vmf->address); } if (dax_is_zero_entry(entry) || dax_is_empty_entry(entry)) {