Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1039665pxf; Thu, 18 Mar 2021 19:00:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEN+l7hQPjc7GBfTivmxtML8fV9TFYkXeh1YDA5yiMBBKYI+akFnT1M8kgd3uv2bwNbIPv X-Received: by 2002:a17:907:7745:: with SMTP id kx5mr1695102ejc.3.1616119220592; Thu, 18 Mar 2021 19:00:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616119220; cv=none; d=google.com; s=arc-20160816; b=JtrzHw5RW2DhaS7yycUGJ0TE25ggtT6QMspwsb2eA17SipeZeZRfLbVlnvPIwh+hi2 nPPentapNPuS+snA5XJCnOUZ27KzjYJapo00Ft9IsTfB1mkHsGdq+gufd66xaIgFhsbA 0vXeHZxJGdvKvaoeQ6R7xH5snSCcXs+SCbz8QHcZMlPvCiU0GLVuS+JWKNhKvZxXOBN9 X+MOxmVRUs1mYwvdsoUvn8IJQN0Eq9D2ghww4x3KeSMGnwmRf+tJJz0LK3kG/ochzs28 2xUjP3hVq7cO+RkO2q1AxObN5cZb4hxw5TejCuiGVs5HIFQbLh3abf28jrVsCEFPjLri Ft8w== 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; bh=TauXqyuj4s+CzCR0hYZNNd26CX+fILsICVpCX+wjbmo=; b=yyI974K/Oh1IOlChOUvY5kKhxmxebr5l2uo9/Z+cozs62u9yDNiW9dJR1R/G7E8W5H Gylvo3koDuD1XByKMF5oYGAfsGEaVnCcSa6vfyeqW4Vbm5nPz9nlG/wU96DGqYz7jvHB GBO4zHYrnFvxkoy2UMAlnySaqbvGF9w/Nm/KwRLkN5nfqbUJw4Pduhgel/qmQ72G7Ic4 m4tedUSqS2glv7TYtDZT+TWfx5UaxdzHvC0PKtqE+Gii8hffDQ6LG67+lj4P6/bWQe7Y awEK2TdZNVogPrKti6q9AvlQEPNdkmBftPydE0lVNvj8hUm6aQ6DrH38R424fwow4x7J ljvQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t6si2954086edw.202.2021.03.18.18.59.57; Thu, 18 Mar 2021 19:00:20 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231854AbhCSBxb (ORCPT + 99 others); Thu, 18 Mar 2021 21:53:31 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:41437 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231266AbhCSBxA (ORCPT ); Thu, 18 Mar 2021 21:53:00 -0400 IronPort-HdrOrdr: =?us-ascii?q?A9a23=3Ao5oiRq/wxH1iNJ1zKhZuk+A4I+orLtY04lQ7?= =?us-ascii?q?vn1ZYxpTb8CeioSSjO0WvCWE7Ao5dVMBvZS7OKeGSW7B7pId2+QsFJqrQQWOgg?= =?us-ascii?q?WVBa5v4YboyzfjXw3Sn9Q26Y5OaK57YeeQMXFfreLXpDa1CMwhxt7vytHMuc77?= =?us-ascii?q?w212RQ9nL4FMhj0JaTqzKUF9SAlYCZdRLvP1ifZvnSaqengcc62Adxs4dtXEzu?= =?us-ascii?q?eqqLvWJTYCBzMCrDKFlC6U7tfBeCSw71MzVCxuzN4ZnVT4rw=3D=3D?= X-IronPort-AV: E=Sophos;i="5.81,259,1610380800"; d="scan'208";a="105876660" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 19 Mar 2021 09:52:58 +0800 Received: from G08CNEXMBPEKD06.g08.fujitsu.local (unknown [10.167.33.206]) by cn.fujitsu.com (Postfix) with ESMTP id 9859A4CEB2A0; Fri, 19 Mar 2021 09:52:55 +0800 (CST) Received: from G08CNEXJMPEKD02.g08.fujitsu.local (10.167.33.202) by G08CNEXMBPEKD06.g08.fujitsu.local (10.167.33.206) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 19 Mar 2021 09:52:55 +0800 Received: from G08CNEXCHPEKD04.g08.fujitsu.local (10.167.33.200) by G08CNEXJMPEKD02.g08.fujitsu.local (10.167.33.202) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 19 Mar 2021 09:52:55 +0800 Received: from irides.mr.mr.mr (10.167.225.141) by G08CNEXCHPEKD04.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 19 Mar 2021 09:52:54 +0800 From: Shiyang Ruan To: , , , CC: , , , , , , , , , Subject: [PATCH v3 03/10] fsdax: Output address in dax_iomap_pfn() and rename it Date: Fri, 19 Mar 2021 09:52:30 +0800 Message-ID: <20210319015237.993880-4-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210319015237.993880-1-ruansy.fnst@fujitsu.com> References: <20210319015237.993880-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-yoursite-MailScanner-ID: 9859A4CEB2A0.A2C4D 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 --- fs/dax.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 33ddad0f3091..a70e6aa285bb 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -997,8 +997,8 @@ static sector_t dax_iomap_sector(struct iomap *iomap, loff_t pos) return (iomap->addr + (pos & PAGE_MASK) - iomap->offset) >> 9; } -static int dax_iomap_pfn(struct iomap *iomap, loff_t pos, size_t size, - pfn_t *pfnp) +static int dax_iomap_direct_access(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; @@ -1010,11 +1010,13 @@ static int dax_iomap_pfn(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; @@ -1024,6 +1026,12 @@ static int dax_iomap_pfn(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; @@ -1386,7 +1394,7 @@ static vm_fault_t dax_fault_actor(struct vm_fault *vmf, pfn_t *pfnp, return VM_FAULT_SIGBUS; } - err = dax_iomap_pfn(iomap, pos, size, &pfn); + err = dax_iomap_direct_access(iomap, pos, size, NULL, &pfn); if (err) return dax_fault_return(err); -- 2.30.1