From patchwork Tue May 22 14:39:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10418773 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 5889A6032A for ; Tue, 22 May 2018 14:49:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 46EE628D05 for ; Tue, 22 May 2018 14:49:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B40B28D2A; Tue, 22 May 2018 14:49:59 +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 DB37D28D05 for ; Tue, 22 May 2018 14:49:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2BAC56B000A; Tue, 22 May 2018 10:49:57 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 28FCC6B000C; Tue, 22 May 2018 10:49:57 -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 1A7F76B000D; Tue, 22 May 2018 10:49:57 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f198.google.com (mail-pf0-f198.google.com [209.85.192.198]) by kanga.kvack.org (Postfix) with ESMTP id CF5176B000A for ; Tue, 22 May 2018 10:49:56 -0400 (EDT) Received: by mail-pf0-f198.google.com with SMTP id x21-v6so11175500pfn.23 for ; Tue, 22 May 2018 07:49:56 -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=ndauXD7et+cJqdraP9jC9wDobj+pwPuDU+w3H5PIBxs=; b=s5yas7MvLX1PZjIOrPII6h+1SSncqky+8nkAfAQkQZeKiSrr9AIqnBrts4bzg2fSki S2ps+cUaVC4eNPIIi0myRraAkgNWll4SqGyObrriFUH1VJt2PZsMhcEfTaAXSN0fVxXF BU8EAnhEIHhiFLcv3KecMqZ2jkMFDnyzb9GTQIn1gVPrUvmXFE53j/MpBMKcGCGG6IOc zjMlaA+ioBAdhgFb5D4A9g+S/UCAEZ+JQGTSaI3hE8CFRxs0fvcpPGTDupceP22TpS0T GstLOukv6Q3U0WyMewYf157RGEVh1j+jgGaTfB3aNh9WGvrmf6rhBP+6IO7fVa8RzmV8 8gSw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.100 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: ALKqPwdUdgroQHfVgl6zf/LVe2QeS/No7Da5EoFwcZDhB57R6qm6GO1k ccz0X9ZF+IMsuMYGq08VJDVTfkUvUtARlGZSdOIGEF2493D4bVkihY1+RJxtW5JuM8pVjYtuWAC Hz7soXb2oxp2WJUKMK6u3S2wfV/V/eunzE9mr5WXnpSvhd98Sp6KyH4c+XbjJPaywGQ== X-Received: by 2002:a17:902:a582:: with SMTP id az2-v6mr24570808plb.98.1527000596547; Tue, 22 May 2018 07:49:56 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpyCjDFPy2NM/6wSe61rxuWwvzfnkrPCQbNeFYFFyw8xlfApTZYW+iJYt3kDeMmuJZJ4mhX X-Received: by 2002:a17:902:a582:: with SMTP id az2-v6mr24570769plb.98.1527000595925; Tue, 22 May 2018 07:49:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527000595; cv=none; d=google.com; s=arc-20160816; b=Acvr9ckVOXyYEoXZmL+jDBFYmyYrRl8fJkdGcgg5L/1orl8l7bpCaW/6mH1MQu8D7q TDA0ROfYhqz4EW8O880Czjq5nsfFIlUGZvXo/bpffymIIpywol1zBCYU96RIb46LVsuh Lp9dF4l7dkajXk8DObFZGUiIyulHsvbZsjvWvuquHAxTPheR7xGd50GPfNAGRf/eM4IR iT5cGD0MPb7KEex4Ug8UQZrVWJxPcZe9kf3y8muXQ3YCKFUUZQRwpyz3vyiJoc+d192f B+A+UkiIhGGZGlthuK+qYq+gSFsZXaNdtO7FFKcAtCike//nm2yUzR60eHkmn94Mi9QJ gOuQ== 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=ndauXD7et+cJqdraP9jC9wDobj+pwPuDU+w3H5PIBxs=; b=TRo1BByTxHh0dQtw//FOfjt2PxJxElC3UWJ7WAitZaQbiYYb8uZE1HqOmCw8zREyQs 5RDCf8TUMO/eUTwDOaRmN1sX4CZ7xKN91M9PInizjh1nLztLs8kTLhaz7pb4RUAFDm7g /1VHnWuYeY5lo9eKuMVoxIRz4hMLjJT8ZIvugOLY8h3r66IVcsMBvizjpOw9mHcg2SKR zPhyIuQ3myOWnRt+aO2r4r6eGqs1uGro4GG/KzU2BNDyRTRRbPyxFDpX3tpL0ApuD1+u KqJu4E+DpOYnYBDovSWSducmDcOYSsLnatVnjlw9oiiJbjIn0XFkfIOuHtwvnOJHxnz6 A4ZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga07.intel.com (mga07.intel.com. [134.134.136.100]) by mx.google.com with ESMTPS id e2-v6si17871248pls.579.2018.05.22.07.49.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 07:49:55 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.100 as permitted sender) client-ip=134.134.136.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.100 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 fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 May 2018 07:49:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,430,1520924400"; d="scan'208";a="230810217" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by fmsmga006.fm.intel.com with ESMTP; 22 May 2018 07:49:54 -0700 Subject: [PATCH 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, tony.luck@intel.com Date: Tue, 22 May 2018 07:39:57 -0700 Message-ID: <152699999778.24093.18007971664703285330.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> 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 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index aaec72ded1b6..2e4682cd7c69 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -319,18 +319,22 @@ 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) +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 +352,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 +609,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)) {