From patchwork Wed Jul 4 21:40:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10507629 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 91751603D7 for ; Wed, 4 Jul 2018 21:50:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 883AC28CD3 for ; Wed, 4 Jul 2018 21:50:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C5CF28DAA; Wed, 4 Jul 2018 21:50:45 +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 1C70028CD3 for ; Wed, 4 Jul 2018 21:50:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 380DE6B000C; Wed, 4 Jul 2018 17:50:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 32EE46B000E; Wed, 4 Jul 2018 17:50:44 -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 246B06B0010; Wed, 4 Jul 2018 17:50:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f70.google.com (mail-pl0-f70.google.com [209.85.160.70]) by kanga.kvack.org (Postfix) with ESMTP id DA64E6B000C for ; Wed, 4 Jul 2018 17:50:43 -0400 (EDT) Received: by mail-pl0-f70.google.com with SMTP id bf1-v6so462170plb.2 for ; Wed, 04 Jul 2018 14:50:43 -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=b4fIHaissXF3v0DmwaBTlmdBOzEHaoFe/qMfV94UsXg=; b=odd3bW2u7xaw09hU6tpM7slcLTMV5QC3qjr70ppdJqrCfQhCyKnKdaCQxqt0k5BxNq ypjn3OVikLMCGgvxr8LXKjrdu5tyI3B70KjsmgeIgBJlfdnTypiUS6f36fM4EJ+8X7vC FvA2K8cqxDoV8sL8mCD46GQiqIDPcm7/qzdtYkOd4aluh3DkIbxkoFiEzRmWNgh4ATem gDDQ9qUeuxogugWfyDrJbGacErz5McLBHImG/YhXZlaTTjMhEudwJvb1XB/RBzb7HB1Y pT6X0HS3s7G/O6amOWrUG2+FTY7AGyVhLU30ROgUUprKax/rKvVnywiq2wYGg8CxAY7L gMnA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.126 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: APt69E1X4q/IVofc2A44sx7CwO0JCrAvsOQ8tClcxVOAtc5MWrhE25vJ QNEvYLlbWZFXHPztu4kaVIadl8fqikr8KLNYS+J7X4IRhfzaIHOSHrIxUWHKJtC3/HIaYsniTsF jX6zzXYH8WajT3o+cf+xmyBRqDUskz94YG5uhliVjJuEH8vxR2sETIEJIwCXo4bZccA== X-Received: by 2002:a63:7a0a:: with SMTP id v10-v6mr3195458pgc.444.1530741043576; Wed, 04 Jul 2018 14:50:43 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfIwBIwoWUtiddsJTOQbfgGtjCN4UCOyi9bNJ9EDhq4qvNcDDHxSw+rn8dOBw2tiRy7g5Sg X-Received: by 2002:a63:7a0a:: with SMTP id v10-v6mr3195442pgc.444.1530741042725; Wed, 04 Jul 2018 14:50:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530741042; cv=none; d=google.com; s=arc-20160816; b=nMEvVHMdCDOOtJffLFNhKEkljWZvW5QibVM55sNbxdqKhgXo3i014R8YwuOGvK42RA 1mDKwD7/bb5LApFjes767qVYESuMwFv4gIXGmSOdK/U68L9f/HGHS+llo7MqhBuGCh63 M5fsQ65aG070NIaaNucW7mRKTCxTsg04iMNCcJFHuhSCiufLMUyvhfkbfOucSsgWku5q lpRmjf0cp0waZQ3iTdV4s3KqdYKVUPuV+v6tiSf6eb8sGK2umEAuDhwwEeNnAFF1OeG+ miXp9w0fhoB+1DpIUMCtgbdXlELaP8kmneRiTWsvhlnGoa51yDg+kfZSypxEGq3ynLtF h4bw== 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=b4fIHaissXF3v0DmwaBTlmdBOzEHaoFe/qMfV94UsXg=; b=imhkXyHP1VNgQDqPIhibYSblCWVxD0MqRWHA2RQR6PLCGtInLQ2YN7yRlHMy4KSz19 1YtNv2g3Z4oE/omhjpD+UzPtXTu6LAHH+Vd+RMST3oEgY77EDgvfe6WA6YSTz+ak6e3i uoL6z5eZiiJcRZLv5ociEimsXlCbQa3+cgsFRGCZfp3Zn5+//EuIVBYakJJKERTFem5V sFnchjufEsukQwepdpSh7F8ZBO8g5oDKC7oDypr3IZO7aDuGC/n9kjGddSjflLrjl/MF JkbUjKlJ9PawI+yusgLeJCuuLblYXy9j6L7R+qXJS/g0Ul6A63yBXBduwMg6OtahcFT4 c2KA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga18.intel.com (mga18.intel.com. [134.134.136.126]) by mx.google.com with ESMTPS id 59-v6si4391552plp.496.2018.07.04.14.50.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Jul 2018 14:50:42 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.126 as permitted sender) client-ip=134.134.136.126; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.126 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 fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jul 2018 14:50:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,309,1526367600"; d="scan'208";a="52665161" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by fmsmga008.fm.intel.com with ESMTP; 04 Jul 2018 14:50:41 -0700 Subject: [PATCH v5 04/11] filesystem-dax: Set page->index From: Dan Williams To: linux-nvdimm@lists.01.org Cc: Christoph Hellwig , Matthew Wilcox , Ross Zwisler , Jan Kara , hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, jack@suse.cz, ross.zwisler@linux.intel.com Date: Wed, 04 Jul 2018 14:40:44 -0700 Message-ID: <153074044454.27838.11584443742245442258.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <153074042316.27838.17319837331947007626.stgit@dwillia2-desk3.amr.corp.intel.com> References: <153074042316.27838.17319837331947007626.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: Christoph Hellwig Cc: Matthew Wilcox Cc: Ross Zwisler Reviewed-by: Jan Kara 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 641192808bb6..4de11ed463ce 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; } } @@ -701,7 +711,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)) {