Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1892296pxm; Sun, 27 Feb 2022 05:53:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJzhJoiEwKKkINcqnJ4BdTwRHPFCfYrG4TtSC0RuowWVfV04bkJSFfWJlBeBEywvlDyEcqoP X-Received: by 2002:a17:906:9f06:b0:6ce:36da:8247 with SMTP id fy6-20020a1709069f0600b006ce36da8247mr12127144ejc.651.1645969998982; Sun, 27 Feb 2022 05:53:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645969998; cv=none; d=google.com; s=arc-20160816; b=Q6EcWOBplSw650kmmo8CDhFMl5kVUFa5jQKf6Vd9I5TXHNdjavrfGK/DkdPa4Goq0l NDGtRamfE//LyizZchGuMXOOFkgS4dzrhU/6wjiZE7OUIWt6rCFtXsCE/2VTvTvE9Qm0 l1gfEA+oF3HPLLpzQvMQACWgclgGGjDxURe54wL7AIMs9lIDVcsQUnTSu0znsLbUQr4M IsZfKMzUZ3ydN0D6vQZylOiu55CafF5Y1zbNNAkpU3TGL6Qeyk8wWoTtpIBT+XQym911 eR3yOb4SbLbC9XGQFBrevNUU7B+5tfZpnhTzmo0O3B9C/ke8wsA2ZQm9BS1QsVkMKc/O lyMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-hdrordr:ironport-data; bh=VvLC/F+p3/w7xxw9wmCIO2l9EjzGCTLswbfedi3fzkw=; b=e7O7cR7b+qO0oRTzSVATGCIB7a1K3qucVPuMLbSZiYLRtjAvlptSZLwZ3f0ht+6aiW qMxDYHsVUtW3SFTYXEwwXuc2rFoUkBzALBOeqiOagBwSkZH3UDWhMK3QFqjfW7COnuCh pfG4r+cio94OnIJtbIFIm0stefcH9BD/Ti1mo94D16uEgqK2AmTUeugmmd+V6aVxKOO+ Hbhvuoq4sIrI4c1BLRp8qn7iUeN4eBQt/DG8zJLkc60LYXM0NO0pc4vpjLDeqXIs05bR T/aZrL1+/4I44w1BLZoniTXOUPniK2NsAAMqyPk1+rI8eTV/40R3StATFA4o346th8ud DuwA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fujitsu.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w10-20020a1709060a0a00b006cfec41b8e4si4531492ejf.951.2022.02.27.05.52.56; Sun, 27 Feb 2022 05:53:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fujitsu.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230420AbiB0MIx (ORCPT + 99 others); Sun, 27 Feb 2022 07:08:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230388AbiB0MIg (ORCPT ); Sun, 27 Feb 2022 07:08:36 -0500 Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8C33D25EA7; Sun, 27 Feb 2022 04:07:58 -0800 (PST) IronPort-Data: =?us-ascii?q?A9a23=3A3rwCZKnGrMC6ssI3R9fZqmPo5gz+J0RdPkR7XQ2?= =?us-ascii?q?eYbTBsI5bp2QHyWNKXT3XOq7ZZmanLt4lPt7ip09U75S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ZLz9P+qjlzEj+7t2u?= =?us-ascii?q?qEuFADsaG51I3kNcMEK2A0d2TA5JCd4QE4ed3NNOo36FdW4MZsq2K3EZV6ybzu?= =?us-ascii?q?e75q7OUFojPVoK+QOOhTSn5PrTFAWZ5A4XV3dqza05+WbIvgTl7uGIsu29yDXb?= =?us-ascii?q?y2jPhq4m6+fJ+59mPoihm8IVIjLjhkKDf4J6QYCPuzgzvaWG9EsquMOkmWZXA+?= =?us-ascii?q?1Dr1fqOk2lqxrk3AftlBw07WX59FOeiXz/5eTkWTMBDdZbj44xSGqv16MZhqA1?= =?us-ascii?q?7Et35RPTi3IOZimw1hgVpuK4Iy2Cr3DE6EbLyoUo/jFiuYh3Us4vkWVQxjIYLH?= =?us-ascii?q?46JlOB1GkWKpgUMCji3ocqTbq7VQGmgoA9+q3cYpwMdi32PnTq/PblpgRroA?= =?us-ascii?q?=3D=3D?= X-IronPort-AV: E=Sophos;i="5.88,333,1635177600"; d="scan'208";a="122037689" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 27 Feb 2022 20:07:58 +0800 Received: from G08CNEXMBPEKD06.g08.fujitsu.local (unknown [10.167.33.206]) by cn.fujitsu.com (Postfix) with ESMTP id 137084D15A5F; Sun, 27 Feb 2022 20:07:52 +0800 (CST) Received: from G08CNEXCHPEKD09.g08.fujitsu.local (10.167.33.85) by G08CNEXMBPEKD06.g08.fujitsu.local (10.167.33.206) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Sun, 27 Feb 2022 20:07:51 +0800 Received: from irides.mr.mr (10.167.225.141) by G08CNEXCHPEKD09.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.23 via Frontend Transport; Sun, 27 Feb 2022 20:07:51 +0800 From: Shiyang Ruan To: , , , , CC: , , , , , Christoph Hellwig Subject: [PATCH v11 5/8] mm: move pgoff_address() to vma_pgoff_address() Date: Sun, 27 Feb 2022 20:07:44 +0800 Message-ID: <20220227120747.711169-6-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220227120747.711169-1-ruansy.fnst@fujitsu.com> References: <20220227120747.711169-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-yoursite-MailScanner-ID: 137084D15A5F.A523F X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: ruansy.fnst@fujitsu.com X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since it is not a DAX-specific function, move it into mm and rename it to be a generic helper. Signed-off-by: Shiyang Ruan Reviewed-by: Christoph Hellwig Reviewed-by: Dan Williams --- fs/dax.c | 12 +----------- include/linux/mm.h | 13 +++++++++++++ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 653a2f390b72..f164cf64c611 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -853,16 +853,6 @@ static void *dax_insert_entry(struct xa_state *xas, return entry; } -static inline -unsigned long pgoff_address(pgoff_t pgoff, struct vm_area_struct *vma) -{ - unsigned long address; - - address = vma->vm_start + ((pgoff - vma->vm_pgoff) << PAGE_SHIFT); - VM_BUG_ON_VMA(address < vma->vm_start || address >= vma->vm_end, vma); - return address; -} - /* Walk all mappings of a given index of a file and writeprotect them */ static void dax_entry_mkclean(struct address_space *mapping, pgoff_t index, unsigned long pfn) @@ -882,7 +872,7 @@ static void dax_entry_mkclean(struct address_space *mapping, pgoff_t index, if (!(vma->vm_flags & VM_SHARED)) continue; - address = pgoff_address(index, vma); + address = vma_pgoff_address(vma, index); /* * follow_invalidate_pte() will use the range to call diff --git a/include/linux/mm.h b/include/linux/mm.h index e1a84b1e6787..9b1d56c5c224 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2816,6 +2816,19 @@ static inline unsigned long vma_pages(struct vm_area_struct *vma) return (vma->vm_end - vma->vm_start) >> PAGE_SHIFT; } +/* + * Get user virtual address at the specific offset within a vma. + */ +static inline unsigned long vma_pgoff_address(struct vm_area_struct *vma, + pgoff_t pgoff) +{ + unsigned long address; + + address = vma->vm_start + ((pgoff - vma->vm_pgoff) << PAGE_SHIFT); + VM_BUG_ON_VMA(address < vma->vm_start || address >= vma->vm_end, vma); + return address; +} + /* Look up the first VMA which exactly match the interval vm_start ... vm_end */ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm, unsigned long vm_start, unsigned long vm_end) -- 2.35.1