Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4620270pxb; Mon, 27 Sep 2021 23:24:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweomxiSKrTK8fXTNNpQrSu7rUVwTmThrGZdOOj/zoo9w29zhOy87nbr8hTSbyqq7PzaJBB X-Received: by 2002:a62:75cd:0:b0:43e:79c:72e with SMTP id q196-20020a6275cd000000b0043e079c072emr3913752pfc.53.1632810272352; Mon, 27 Sep 2021 23:24:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632810272; cv=none; d=google.com; s=arc-20160816; b=r0HGiLBsUZ2M+PMuAIc6a9sQEh1d35VJXI3pd517riERHd5Ym+gNvPocbzbctX2sks 20B/xI28APpFmC8Kk6gZotzErteO4UwiBwUAqZlzb2b7DXlyuJwEX0yid+s3pe09Et7+ PD4RQ4ZUodZPHgvUUAB6Zt1+YtwjcvJ5DkmNsrwc2+nTnNVt2AQ8vuZmsFvWmmwbi2U6 fwG7uvmnvZOkKMwQuYf34toOpxUiGd9eMdYoHvkUhI15BXrTJFCG5tBkohCJ2nJxBH8x zw3eLOWemjrZr6lgImVGbvX2otanD2NE46FEe+1UGmwv7N+7IZHnpbuX/lIiSo4NAhaL nNwQ== 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=uHyfM3oSLj83uouzDnvANNJioZjFvWcOFoKw8Dg/6uA=; b=kNqIiRXeF29uj7TEAkbGABRN2SBKE23V0JZCHGc7efc2yFIFkFRiqAzogrTMNKX7Jd OkuqR4/jbPW02JIrKr1S1BvINyZPavt7Zi3E8SpL9jaHMTFByj01HnpSUkYlyWBT4N4X FnGL51qLZyLhZrmea4lMiphLW4+VZ2cItLpESxSxPJcvloRu3S/LXjpwFul/+asKggQ0 r3u7/IbaNmksQkfBMsMIWE9h+WvCcCKcmAOS1E1FEDUx5EWLt8GMSbJOA82dAWhNCfQk QDRXJKwmYYSBM6s0Ovpd7PfEwEa6mOu6rZZzQOnfjTGJ1hFBlX5U5phlNmJJTk697Y5A Jmkw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s11si25741773pgp.222.2021.09.27.23.24.20; Mon, 27 Sep 2021 23:24:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S234207AbhI1GZI (ORCPT + 99 others); Tue, 28 Sep 2021 02:25:08 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:6245 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238982AbhI1GZH (ORCPT ); Tue, 28 Sep 2021 02:25:07 -0400 IronPort-Data: =?us-ascii?q?A9a23=3AGRWP7azeUug2UwtVswB6t+cnxyrEfRIJ4+MujC/?= =?us-ascii?q?XYbTApDJwhDIBxmBKC2uPbKqKYGPwe492a4qzp00Pu5aBz4A3HQtv/xmBbVoQ9?= =?us-ascii?q?5OdWo7xwmQcns+qBpSaChohtq3yU/GYRCwPZiKa9krF3oTJ9yEmjPnZHOqkUYY?= =?us-ascii?q?oBwgqLeNaYHZ44f5cs75h6mJYqYDR7zKl4bsekeWGULOW82Ic3lYv1k62gEgHU?= =?us-ascii?q?MIeF98vlgdWifhj5DcynpSOZX4VDfnZw3DQGuG4EgMmLtsvwo1V/kuBl/ssIti?= =?us-ascii?q?j1LjmcEwWWaOUNg+L4pZUc/H6xEEc+WppieBmXBYfQR4/ZzGhhc14zs5c85K2U?= =?us-ascii?q?hsBMLDOmfgGTl9TFCQW0ahuoeaaeSnh4JHNp6HBWz62qxl0N2k6NJMZ9s55G2Z?= =?us-ascii?q?L8uYSKSxLZReG78qpwba/W8FtgMo5JcXmNY9ZvWtvpRnVBPBgQ9bcQqHO5NZdx?= =?us-ascii?q?x8xgNxDGbDVYM9xQTZtcxPGbDVMN00RBZZ4m/2n7lHlciFVs1KVja425XXDig1?= =?us-ascii?q?71f7mN9+9UtqUScRQm26cp3na5CL9AxcHJJqTxCTt2nKnhsfLhj+9VI96PKe38?= =?us-ascii?q?fpmn0yV7ncOExBQWVbTif24jFOuHtxEJ0EK9y4Gs6c/7gqoQ8P7Uhn+p2SL1jY?= =?us-ascii?q?YWtxNA6g55RuLx678/QmUHC4HQyRHZdhgs9U5LRQu11mUj5b5CydHrrKYUzSe+?= =?us-ascii?q?62SoDf0PjIaRUccZDUDZRkI5dj95oUyiA/fCNF5H+iojbXI9ZvYq9yRhHFmwex?= =?us-ascii?q?N0ohQjOPmlW0rSgmE/vDhJjPZLC2ONo590j5EWQ=3D=3D?= IronPort-HdrOrdr: =?us-ascii?q?A9a23=3Ab+kR1qMzyEAD/MBcTv2jsMiBIKoaSvp037BL?= =?us-ascii?q?7TEUdfUxSKGlfq+V8sjzqiWftN98YhAdcLO7Scy9qBHnhP1ICOAqVN/MYOCMgh?= =?us-ascii?q?rLEGgN1+vf6gylMyj/28oY7q14bpV5YeeaMXFKyer8/ym0euxN/OW6?= X-IronPort-AV: E=Sophos;i="5.85,328,1624291200"; d="scan'208";a="115096956" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 28 Sep 2021 14:23:26 +0800 Received: from G08CNEXMBPEKD04.g08.fujitsu.local (unknown [10.167.33.201]) by cn.fujitsu.com (Postfix) with ESMTP id 75C8B4D0DC7A; Tue, 28 Sep 2021 14:23:24 +0800 (CST) Received: from G08CNEXCHPEKD09.g08.fujitsu.local (10.167.33.85) by G08CNEXMBPEKD04.g08.fujitsu.local (10.167.33.201) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Tue, 28 Sep 2021 14:23:13 +0800 Received: from irides.mr.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; Tue, 28 Sep 2021 14:23:12 +0800 From: Shiyang Ruan To: , , , CC: , , , , , , , , Ritesh Harjani Subject: [PATCH v10 1/8] fsdax: Output address in dax_iomap_pfn() and rename it Date: Tue, 28 Sep 2021 14:23:04 +0800 Message-ID: <20210928062311.4012070-2-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210928062311.4012070-1-ruansy.fnst@fujitsu.com> References: <20210928062311.4012070-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-yoursite-MailScanner-ID: 75C8B4D0DC7A.A1011 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: ruansy.fnst@fujitsu.com X-Spam-Status: No Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add address output in dax_iomap_pfn() in order to perform a memcpy() in CoW case. Since this function both output address and pfn, rename it to dax_iomap_direct_access(). Signed-off-by: Shiyang Ruan Reviewed-by: Christoph Hellwig Reviewed-by: Ritesh Harjani Reviewed-by: Dan Williams Reviewed-by: Darrick J. Wong --- fs/dax.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 4e3e5a283a91..8b482a58acae 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -1010,8 +1010,8 @@ static sector_t dax_iomap_sector(const struct iomap *iomap, loff_t pos) return (iomap->addr + (pos & PAGE_MASK) - iomap->offset) >> 9; } -static int dax_iomap_pfn(const struct iomap *iomap, loff_t pos, size_t size, - pfn_t *pfnp) +static int dax_iomap_direct_access(const struct iomap *iomap, loff_t pos, + size_t size, void **kaddr, pfn_t *pfnp) { const sector_t sector = dax_iomap_sector(iomap, pos); pgoff_t pgoff; @@ -1023,11 +1023,13 @@ static int dax_iomap_pfn(const struct iomap *iomap, loff_t pos, size_t size, return rc; id = dax_read_lock(); length = dax_direct_access(iomap->dax_dev, pgoff, PHYS_PFN(size), - NULL, pfnp); + kaddr, pfnp); if (length < 0) { rc = length; goto out; } + if (!pfnp) + goto out_check_addr; rc = -EINVAL; if (PFN_PHYS(length) < size) goto out; @@ -1037,6 +1039,12 @@ static int dax_iomap_pfn(const struct iomap *iomap, loff_t pos, size_t size, if (length > 1 && !pfn_t_devmap(*pfnp)) goto out; rc = 0; + +out_check_addr: + if (!kaddr) + goto out; + if (!*kaddr) + rc = -EFAULT; out: dax_read_unlock(id); return rc; @@ -1401,7 +1409,7 @@ static vm_fault_t dax_fault_iter(struct vm_fault *vmf, return pmd ? VM_FAULT_FALLBACK : VM_FAULT_SIGBUS; } - err = dax_iomap_pfn(&iter->iomap, pos, size, &pfn); + err = dax_iomap_direct_access(&iter->iomap, pos, size, NULL, &pfn); if (err) return pmd ? VM_FAULT_FALLBACK : dax_fault_return(err); -- 2.33.0