From patchwork Sun Sep 4 02:16:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 12965097 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 AAB40ECAAD5 for ; Sun, 4 Sep 2022 02:16:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4B52A80173; Sat, 3 Sep 2022 22:16:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4632C8015A; Sat, 3 Sep 2022 22:16:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 32B3780173; Sat, 3 Sep 2022 22:16:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 236B88015A for ; Sat, 3 Sep 2022 22:16:32 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id EE01A1C5B78 for ; Sun, 4 Sep 2022 02:16:31 +0000 (UTC) X-FDA: 79872788982.15.8816D6E Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by imf15.hostedemail.com (Postfix) with ESMTP id 46DB2A005A for ; Sun, 4 Sep 2022 02:16:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662257791; x=1693793791; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9CRqNyu89p0LQkhJhRVAoDT4rdt25lVWtdCoNTZjeqE=; b=JixZohKSwiPCT4CbVBFI6u4E5OXDCBu59Rq1wEW8eA4+h9m9Q6fzX4mM CrPm28WQ68MiDvQNbQgkDT4uoFSnzRbYrtBF/Zmm1S8TGpyKIyUTloAQA fliaDFKA9z68qVP2k9eCUrJ/vkpLkZ0GzANZNX1gRuzTs/5QyynrxbRZ8 VgJkOzgRg4Q+B+l/Hxmm5Bx0ZWdtC1qreh59KCrSxpDGe7cZohLI7u/bb K57rj9JhaNkwQrAKPkidIRJ2uwc4nbKK+yv35ZFuSMPP4kUKDglMgnbTr e8cJ0A1kHeB68EW3Z02YCTJhYqCE5J+sKP9ismX4IhDVbCRCZN117uwMV Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10459"; a="294943506" X-IronPort-AV: E=Sophos;i="5.93,288,1654585200"; d="scan'208";a="294943506" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2022 19:16:29 -0700 X-IronPort-AV: E=Sophos;i="5.93,288,1654585200"; d="scan'208";a="789035742" Received: from pg4-mobl3.amr.corp.intel.com (HELO dwillia2-xfh.jf.intel.com) ([10.212.132.198]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2022 19:16:29 -0700 Subject: [PATCH 05/13] 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-mm@kvack.org, nvdimm@lists.linux.dev, linux-fsdevel@vger.kernel.org Date: Sat, 03 Sep 2022 19:16:29 -0700 Message-ID: <166225778919.2351842.8691837577077340308.stgit@dwillia2-xfh.jf.intel.com> In-Reply-To: <166225775968.2351842.11156458342486082012.stgit@dwillia2-xfh.jf.intel.com> References: <166225775968.2351842.11156458342486082012.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=1662257791; a=rsa-sha256; cv=none; b=QuFkJyZfCiD/V0lmVKdOccbI3bFMN65FFhUSupr/JJNtxD0HclwI6qYcY3XcnGajdK/cj4 D8x2zyThfNXcGuUTsZ74KLnsXERKnV/Kh05pkTUbagGYaqeSEv/4dC/fkmmxXjKITuAUbN D8hcWQf/JzYwRUkOiF648npqlxD5dq8= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=JixZohKS; spf=softfail (imf15.hostedemail.com: 192.55.52.120 is neither permitted nor denied by domain of dan.j.williams@intel.com) smtp.mailfrom=dan.j.williams@intel.com; dmarc=fail reason="No valid SPF" header.from=intel.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662257791; 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=YhRwZPLof/amNyk6fvhqQd7+PUGMUtyo9MGRir8zxLc=; b=UYxsqL/+UtNDM3EAYPlHUd0YbalzfM/oNFfM3u/xb4eSW0IFi4KIphUtSbAEYktnNU+a65 d5eL/gCsHPygHS8GJqQBUWq98P/Js3cZrwN9GntcLWG3Zeh+xAwEE86B0uGDX0IwaSU6SM qGP/xaEa09Ui53Ua8iuQHK2QHASrVD8= X-Rspam-User: X-Stat-Signature: dmoxxndy8owcdpxwrqqymt5dorbtjy7m X-Rspamd-Queue-Id: 46DB2A005A X-Rspamd-Server: rspam10 Authentication-Results: imf15.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=JixZohKS; spf=softfail (imf15.hostedemail.com: 192.55.52.120 is neither permitted nor denied by domain of dan.j.williams@intel.com) smtp.mailfrom=dan.j.williams@intel.com; dmarc=fail reason="No valid SPF" header.from=intel.com (policy=none) X-HE-Tag: 1662257791-49360 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 d2fb58a7449b..fad1c8a1d913 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -362,7 +362,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; @@ -370,11 +370,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); @@ -882,8 +882,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