From patchwork Fri Sep 16 03:35:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 12978060 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 222DDECAAD3 for ; Fri, 16 Sep 2022 03:35:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8EC478D0001; Thu, 15 Sep 2022 23:35:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 89B8280008; Thu, 15 Sep 2022 23:35:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7166E8D0001; Thu, 15 Sep 2022 23:35:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 5E66B80008 for ; Thu, 15 Sep 2022 23:35:58 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 4042AAB791 for ; Fri, 16 Sep 2022 03:35:58 +0000 (UTC) X-FDA: 79916534796.08.F7F1111 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by imf17.hostedemail.com (Postfix) with ESMTP id BE1EF4009F for ; Fri, 16 Sep 2022 03:35:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663299357; x=1694835357; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=j5tRXbceFLZcGlHWWzLaIriWLFbXvQfVW7h15WIRvnM=; b=UL2QWDO2OrOLviyzqmyxn6CUPUzYJot0RcrZm3TKK6dWevqx6XjZQNLG zD/k58eRw8F9083R4cd0K8e8NPKKGmVcWyI/TqIBfP7z89HpzRcPV+cIL 5EmsdGTR5eU8lhPNPT6eo4mxcHM0qj5KjO55WBRR+aYZ/7e9O6ftlFSJP eLkeT4uhhXHJBAKpbAfIlHve3xIAmY6QPmoANXun1CRjzFB5YgBaFAqyn 6S9Cr0nglpiqmKEM8dVe71HAfrmjSm0lWmO+3VYC+FfqFYAr9HLojg+rS 2s2tvHZJjSg2HnVl7jaZCryit6JV7bK+knz7BXbNTMp+rleHYLe2Xgsmp Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10471"; a="281930499" X-IronPort-AV: E=Sophos;i="5.93,319,1654585200"; d="scan'208";a="281930499" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2022 20:35:56 -0700 X-IronPort-AV: E=Sophos;i="5.93,319,1654585200"; d="scan'208";a="648099914" Received: from colinlix-mobl.amr.corp.intel.com (HELO dwillia2-xfh.jf.intel.com) ([10.209.29.52]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2022 20:35:56 -0700 Subject: [PATCH v2 08/18] fsdax: Cleanup dax_associate_entry() From: Dan Williams To: akpm@linux-foundation.org Cc: Matthew Wilcox , Jan Kara , "Darrick J. Wong" , Jason Gunthorpe , Christoph Hellwig , John Hubbard , linux-fsdevel@vger.kernel.org, nvdimm@lists.linux.dev, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-ext4@vger.kernel.org Date: Thu, 15 Sep 2022 20:35:56 -0700 Message-ID: <166329935598.2786261.15591591637555586864.stgit@dwillia2-xfh.jf.intel.com> In-Reply-To: <166329930818.2786261.6086109734008025807.stgit@dwillia2-xfh.jf.intel.com> References: <166329930818.2786261.6086109734008025807.stgit@dwillia2-xfh.jf.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663299357; a=rsa-sha256; cv=none; b=BzdXPmvsCh1wmYpMVlL/E4gSpYrJqf1turknlvxY6ns2/Oqv0u+BSyoUSYtehTNQ47YBAm Rd+Rqyk+jMFWftb4NqNcrhWCGnB9WdaGdqvMlVOojVKb4LYl+wH+WgkatN9iO+KZuyNa43 XRjqF8cCyhPZq3lWNQK9A2EXCYlD4Ac= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=UL2QWDO2; spf=pass (imf17.hostedemail.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 (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663299357; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=1MpRCRDLHif5gtcTvfZSuqk9tx0XT6kDDZSl0SePm9c=; b=nI9uHird2I/nZC6QzZCJEOmDg0phtQUWbALH362jAzZTQepg98J+hH6+cjyad3SE2D2/Gc TcKU0Me9h+d0e9OO/+0Aa+UTkjDW8N/4sx5Lt7sfqYeKyl7Dp2cmcnr8hswt2FUD/9xF8w h2NOXAKZ5RDDczUtY8wtH9MKngR/sBk= X-Rspam-User: Authentication-Results: imf17.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=UL2QWDO2; spf=pass (imf17.hostedemail.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 (policy=none) header.from=intel.com X-Rspamd-Server: rspam03 X-Stat-Signature: m41fec7qowct998s6teebcrkodn38xr9 X-Rspamd-Queue-Id: BE1EF4009F X-HE-Tag: 1663299357-354975 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: Pass @vmf to drop the separate @vma and @address arguments to dax_associate_entry(), use the existing DAX flags to convey the @cow argument, and replace the open-coded ALIGN(). Cc: Matthew Wilcox Cc: Jan Kara Cc: "Darrick J. Wong" Cc: Jason Gunthorpe Cc: Christoph Hellwig Cc: John Hubbard Signed-off-by: Dan Williams --- fs/dax.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 8382aab0d2f7..bd5c6b6e371e 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -368,7 +368,7 @@ static inline void dax_mapping_set_cow(struct page *page) * FS_DAX_MAPPING_COW, and use page->index as refcount. */ static void dax_associate_entry(void *entry, struct address_space *mapping, - struct vm_area_struct *vma, unsigned long address, bool cow) + struct vm_fault *vmf, unsigned long flags) { unsigned long size = dax_entry_size(entry), pfn, index; int i = 0; @@ -376,11 +376,11 @@ static void dax_associate_entry(void *entry, struct address_space *mapping, if (IS_ENABLED(CONFIG_FS_DAX_LIMITED)) return; - index = linear_page_index(vma, address & ~(size - 1)); + index = linear_page_index(vmf->vma, ALIGN(vmf->address, size)); for_each_mapped_pfn(entry, pfn) { struct page *page = pfn_to_page(pfn); - if (cow) { + if (flags & DAX_COW) { dax_mapping_set_cow(page); } else { WARN_ON_ONCE(page->mapping); @@ -916,8 +916,7 @@ static vm_fault_t dax_insert_entry(struct xa_state *xas, struct vm_fault *vmf, void *old; dax_disassociate_entry(entry, mapping, false); - dax_associate_entry(new_entry, mapping, vmf->vma, vmf->address, - cow); + dax_associate_entry(new_entry, mapping, vmf, flags); /* * Only swap our new entry into the page cache if the current * entry is a zero page or an empty entry. If a normal PTE or