Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp209922imm; Fri, 13 Jul 2018 22:00:54 -0700 (PDT) X-Google-Smtp-Source: AAOMgpepq0G0FQMfcwtjdz38KwyYtR3NoK2ThDmwie45e7+fo+zK73N4JxneCIHOBqiiZpf73C6n X-Received: by 2002:a17:902:9f81:: with SMTP id g1-v6mr8791440plq.304.1531544454576; Fri, 13 Jul 2018 22:00:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531544454; cv=none; d=google.com; s=arc-20160816; b=AEjrNV/6fVX+k0VHXDyIWC7uY2h/+I5LvfnOKCS2AWvWSlKQEKXaAg7CDbKn52h0/L sNr98FOU0YfvYuJ/paUinpPgdiCGvnvtbuOVVRQMrCn0DxmerlQt9DmK3+Ibs9yvMJVs 3zh5EY+b92oILHcXrYxyPwCpqJjQ6kitAmCKfAvImZvNrH/W9IdihOPUCuN9f1u2k31t LubBlLxpq0wXApw8Vg7e310PxSS69nFpD5otIlqtYZB6mS1hYi0qXcg6L8Ja/JEI8dlv 1qW0l5+L6vsOFRW/Sg/wmYz7xCmiCjXe4r7rb2ZZUqX/FZipHeDl6GkcG5p4W+4L9DCq 55lQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:arc-authentication-results; bh=3Sw3ZvNG2/XFDKmqrlyTWP/2KkdyPzd5HADCu5n8yc8=; b=s52oK/TX3WX7RWJhbNYcjPv3juCLGZCbMB86NNO7dmjwORyjbXkAIJ/Bo7yyfbvCDd 4ODogiO2YB8+Yy1Pab64yzhPCrQB8SJTmno7bcCI//6AWwTLynSPatxfI7OPzSMFSdPd WUUOGtR3PgTHNnpE/q6Ihmf+bwQSMCjExqVO8458AyFgxYa14W4VaJpkeZ4XHxraqE0Z MoOhL6rNjkdLcv8Zebo1/1nGb3mTdLMh1wsWaujZ9WOCAIRXZRhEXQmNw+KxS2miFuh7 FROfDVIIzx36KE2qbYL55PkAsZ5TANYos9SJxdgQNHmYJ7sx9D56W0Zff2rR3TUnWymo TUCg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v71-v6si27164503pfj.354.2018.07.13.22.00.39; Fri, 13 Jul 2018 22:00:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726979AbeGNFR2 (ORCPT + 99 others); Sat, 14 Jul 2018 01:17:28 -0400 Received: from mga01.intel.com ([192.55.52.88]:53599 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725880AbeGNFR1 (ORCPT ); Sat, 14 Jul 2018 01:17:27 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jul 2018 21:59:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,350,1526367600"; d="scan'208";a="71297877" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by fmsmga004.fm.intel.com with ESMTP; 13 Jul 2018 21:59:48 -0700 Subject: [PATCH v6 04/13] filesystem-dax: Set page->index From: Dan Williams To: linux-nvdimm@lists.01.org Cc: Christoph Hellwig , Matthew Wilcox , Ross Zwisler , Jan Kara , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Fri, 13 Jul 2018 21:49:50 -0700 Message-ID: <153154379074.34503.9610948190338126460.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <153154376846.34503.15480221419473501643.stgit@dwillia2-desk3.amr.corp.intel.com> References: <153154376846.34503.15480221419473501643.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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)) {