From patchwork Fri Oct 14 23:58:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 13007526 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 294C7C433FE for ; Fri, 14 Oct 2022 23:58:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B12066B0072; Fri, 14 Oct 2022 19:58:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A739B6B0075; Fri, 14 Oct 2022 19:58:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8EC3F6B007B; Fri, 14 Oct 2022 19:58:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 7CF566B0072 for ; Fri, 14 Oct 2022 19:58:11 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 534C21204EC for ; Fri, 14 Oct 2022 23:58:11 +0000 (UTC) X-FDA: 80021221182.12.D81A8C2 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by imf16.hostedemail.com (Postfix) with ESMTP id B4FAB18001E for ; Fri, 14 Oct 2022 23:58:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665791889; x=1697327889; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=b6C7Qe8Q1GJpUot5lHXs4yvkjjX4IgtewPJJUoytmac=; b=ZkpXAICss5hHzkbPvITbhzrZBDmhf1DmTWw/5kf6Sl3mKymXhDWiLAFr aIKPwOHk1LoePp6AW1D1QOihyEu4LsOZRUU0/udXhNLGCMReKANdWcF06 dCcWJ5N2aOST86I5Q3FR2z4tVwIZogIwlUerR7pFgEqWqd3F8Nh5NcJX3 hmbKsjDiGTFIkKZfp7B0+rp4Cwh4WFQw9+eq6ou0BjnmuoXikZak+ZlA3 kDwwVYtmQNVFitlZOAYqOdPHfJiw0KzkkmyHViRW3tKis7vTXrSzHNtNn VRS03lTKCoZU9/CPqKu9z6FH9yolH09O6nnWwAatLRds843Axc3bsdder Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10500"; a="292862047" X-IronPort-AV: E=Sophos;i="5.95,185,1661842800"; d="scan'208";a="292862047" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2022 16:58:09 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10500"; a="630113423" X-IronPort-AV: E=Sophos;i="5.95,185,1661842800"; d="scan'208";a="630113423" Received: from uyoon-mobl.amr.corp.intel.com (HELO dwillia2-xfh.jf.intel.com) ([10.209.90.112]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2022 16:58:08 -0700 Subject: [PATCH v3 12/25] fsdax: Cleanup dax_associate_entry() From: Dan Williams To: linux-mm@kvack.org Cc: Matthew Wilcox , Jan Kara , "Darrick J. Wong" , Jason Gunthorpe , Christoph Hellwig , John Hubbard , david@fromorbit.com, nvdimm@lists.linux.dev, akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org Date: Fri, 14 Oct 2022 16:58:07 -0700 Message-ID: <166579188791.2236710.2590200540568819339.stgit@dwillia2-xfh.jf.intel.com> In-Reply-To: <166579181584.2236710.17813547487183983273.stgit@dwillia2-xfh.jf.intel.com> References: <166579181584.2236710.17813547487183983273.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=1665791889; a=rsa-sha256; cv=none; b=p6WmIFa5w6eYxM/ImgIMWgbopYGKWnEQQ/xwgHi73kCafay8vIt7X+WCztdeUbZ1IiN4oC MnbX3SsK3I2KqIkYGM2S6byIr6zkuxSnRpnReCRYa5UrqhTT7dUt5mhiqHjzQ9mbOwJxqx DEMlz3TnJEBlRCt8pfSP6uki1fTbv5Q= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=ZkpXAICs; spf=pass (imf16.hostedemail.com: domain of dan.j.williams@intel.com designates 134.134.136.20 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=1665791889; 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=btXBtxcbjCcTlZk4yf7Gaea1dGkef3rJyQBZS8dmASA=; b=pTNZXw5CZxI+w5KYo/2x0E9OHjLuDzLAHCpCLJJGWuDgpmPGcQBekYFH+AKpPRtiwWVqTA MNaAb2WyPhMb3Ezv7u5wDph19JiNeu5nZMDpYqtawmjbFsLDAbNcd2W08VCi/7SjXnPv9c bmS7z1VEI0Kz0DYwpeG8x3rvzOYDC+o= X-Stat-Signature: xc6zote89h9u7mjhpxfpyhitbganei3s X-Rspamd-Queue-Id: B4FAB18001E X-Rspam-User: Authentication-Results: imf16.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=ZkpXAICs; spf=pass (imf16.hostedemail.com: domain of dan.j.williams@intel.com designates 134.134.136.20 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Rspamd-Server: rspam06 X-HE-Tag: 1665791889-292694 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 | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 73e510ca5a70..48bc43c0c03c 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -406,8 +406,7 @@ static struct dev_pagemap *folio_pgmap(struct folio *folio) */ static vm_fault_t 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), index; struct folio *folio; @@ -416,9 +415,9 @@ static vm_fault_t dax_associate_entry(void *entry, if (IS_ENABLED(CONFIG_FS_DAX_LIMITED)) return 0; - index = linear_page_index(vma, address & ~(size - 1)); + index = linear_page_index(vmf->vma, ALIGN(vmf->address, size)); dax_for_each_folio(entry, folio, i) - if (cow) { + if (flags & DAX_COW) { dax_mapping_set_cow(folio); } else { WARN_ON_ONCE(folio->mapping); @@ -992,8 +991,7 @@ static vm_fault_t dax_insert_entry(struct xa_state *xas, struct vm_fault *vmf, void *old; dax_disassociate_entry(entry, mapping, false); - ret = dax_associate_entry(new_entry, mapping, vmf->vma, vmf->address, - cow); + ret = dax_associate_entry(new_entry, mapping, vmf, flags); if (ret) goto out; /*