From patchwork Fri Jun 8 23:50:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10455361 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 80DBC60234 for ; Sat, 9 Jun 2018 00:01:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BC3F2956D for ; Sat, 9 Jun 2018 00:01:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 79DD42955B; Sat, 9 Jun 2018 00:01:00 +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 9AF972955B for ; Sat, 9 Jun 2018 00:00:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0A9476B026B; Fri, 8 Jun 2018 20:00:56 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 02FE36B026C; Fri, 8 Jun 2018 20:00:55 -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 E16216B026D; Fri, 8 Jun 2018 20:00:55 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f197.google.com (mail-pf0-f197.google.com [209.85.192.197]) by kanga.kvack.org (Postfix) with ESMTP id 9AAD56B026B for ; Fri, 8 Jun 2018 20:00:55 -0400 (EDT) Received: by mail-pf0-f197.google.com with SMTP id z5-v6so6957934pfz.6 for ; Fri, 08 Jun 2018 17:00:55 -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=BX0IBoGH6gYrLlttvN5m/GWuACSczqcj9vcYjXDtgqI=; b=m6BJpamPSOsBWR4waTpJ+PsIj4uEGZAk6fe7DpS+A2Dsq+akwPfXRZIyiMc19+2z5I OWIZFwQdjSjUqaEaIydes5Oux1v/bD6HDU5O9rvR+umGgwdGkmR2Zf+qSFIYfuQusMKW LfB4Vj4AGiboUgSjq1yNHE4N+W1OQHe5L+53+idsxcDEJx8IKsS0jRGIuF7EEMSnJNUO EiOYaNJYUDvwXQoNAhfnUmv7hR6k9d5of5f4aBGHS3UIToV5hKNYIL8rwg3sDBLgUVq0 SMspnt+EIp9hkmoe1oRFtMKWjdfjlu1l//eE5AaFEPERt9LPT3n+CcgRbqKLlslYNbEA feTA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.136 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: APt69E186y3odLNIHpdafKIDrOd4r0useWcu4txmvZnYgRmkbqI3uYOB yDGcV64tYnTnMO/QjU4IpI7coQpCZDK5P/tv36umPC9aONh4VIdJf4s4xz87vlyAxlD6NBUn9XD 6u96E3WC7j2j9Mov4Y1/kWBkouik7fwuYo5U8m3d9/8EECCBbeIQOvI221ZNxTh6DkQ== X-Received: by 2002:a62:4653:: with SMTP id t80-v6mr7886456pfa.58.1528502455309; Fri, 08 Jun 2018 17:00:55 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLTlKkCgVWj91ALmOMRaTd/kFmuGJj9xrThUhPxKs+tZ0XYoA7KC0WEuaPcqiT/RTKwGLix X-Received: by 2002:a62:4653:: with SMTP id t80-v6mr7886420pfa.58.1528502454563; Fri, 08 Jun 2018 17:00:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528502454; cv=none; d=google.com; s=arc-20160816; b=n17jcIovses2EUZxARyOgr5KbXHUEJCSRhO8HQ44kwTefGStUNQL8JGS3LAjDnRsYU CQbEtico1PZ7TXITRv2kywTGqRc03aJ0QopLcFoQtRCbl+130VJRYdPKAfZndIXHTXAO SS4rBowOL60pWysFgC6+WUoOL5Q/nrMOxE0ag1DeB8dr4yiX3WTkeU7ARRM09XzOQAd8 Ox2l/Hv8S5O9koItGqD6JnxzLrXipn/kl1B7kuElEkHLEmRem2zs/SnAVVdxDnvxp8Uv FDIu8zzSb+a+szWnIpZ9POUtaHIqOsLxXB5ikei2eCFl5f2kx9BxBhEzifJL9veJl8EY kA/g== 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=BX0IBoGH6gYrLlttvN5m/GWuACSczqcj9vcYjXDtgqI=; b=TeMlz6mqPsQYozQWyS0xLLwoc6zNh2vCR3kSftEC8PkCCEu3rhu5zexoPD20nKJtRg GajD4y2hfjiuiHVq6tFng8HkaMhw8GFYyKt+FjH0bH7NHHg1L3so2BOFYUNDv9FU0R77 /O757odkasyMmhhN6+BF7+t8x7e8nHVClTk8hQn5u5gdW+WkwNSpNqCTWxuVLZFlO7Nu sCXYMK8TYEjLo8hzfBPdQHVcvPqWs6dMPFzFDlR0EkvnBNGuGNJzGFPLiPE1qGTw6gn0 d2UIBgeMD7gA1KZJLxXQ5bXMKg4qXsjv2v63ySrI0qkXd6adWJqrqhmDB7z3IyphdZ2d OHSg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.136 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga12.intel.com (mga12.intel.com. [192.55.52.136]) by mx.google.com with ESMTPS id a6-v6si5483741plz.351.2018.06.08.17.00.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Jun 2018 17:00:54 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.136 as permitted sender) client-ip=192.55.52.136; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.136 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 orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jun 2018 17:00:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,492,1520924400"; d="scan'208";a="206545847" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga004.jf.intel.com with ESMTP; 08 Jun 2018 17:00:44 -0700 Subject: [PATCH v4 05/12] filesystem-dax: Set page->index From: Dan Williams To: linux-nvdimm@lists.01.org Cc: Christoph Hellwig , Matthew Wilcox , Ross Zwisler , Jan Kara , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, jack@suse.cz Date: Fri, 08 Jun 2018 16:50:47 -0700 Message-ID: <152850184756.38390.8348959280033335538.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <152850182079.38390.8280340535691965744.stgit@dwillia2-desk3.amr.corp.intel.com> References: <152850182079.38390.8280340535691965744.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 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)) {