Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp818329pxb; Thu, 25 Feb 2021 16:26:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJyZ4yCwEOvjuGSLPBVOsdk3L/enlyCHtXugKV1CMqtlP9iAMH8k7HPdCp1JkMq1IG/R8sxW X-Received: by 2002:a17:907:1629:: with SMTP id hb41mr260789ejc.197.1614299196072; Thu, 25 Feb 2021 16:26:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614299196; cv=none; d=google.com; s=arc-20160816; b=l6FobYq1MLrbqhGfWgWXnVAgdgj150LCC5UZVmIpNzYKtHDZlra846CY63XEliDmMT MHfFCL/5X3jVbBoQOj+Qzsg0sYU7VEzHDXMS8wo/JV72qhXKroVDGfw5aKzggs5cXHUY fR49F8gxIpZgzgpsVOpjebm/ktOt3PvheEO7cEZ/Jd9Zko3sRmPfJnbq6jZl5U5e5QNx WjRheHPuQAUfahcwilAe7d9OmPdzCC4xDSdnjVgZootPPY0YWNkgYMte5hcVVFD+m8WR yBRVj7PGY2roMi3ffXrXWu2vDY/TDKtWyn9X2Ehy4X9ApMLCu5RGp1LSy1QqqIIyA4w2 XLUA== 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; bh=3kyYOFDWyZQEUNUdDawWVlqDIy6WyktbhTyQ/fDk5WA=; b=fw/wiRpK9FLSu2E2xLby4RHd449GpafQBXbuZTY7EGc2qFER++qBMdN9FjUVEQYE8m 8PrHH/3ZljpvvJUnkP6G3d4ezvV7vWNjoKL6Pf8n0csWkLXMnVzmRmzbVWjEiilpOypl RIFDt0LO7ZSvdI5RE7VaODMScNa5/D13fP6LpFUM/m1/LKD8cN49t91yiDZPPQlYJ0zZ 8UxLdRFON5qnaf+jrbsLMP6MPbux0mK8HUTIphj+gJ6Ok+Pl6uJrjuF0seSXy9lOnA5Z in++/DOTsYMyd1lpzE93rvW21SFqlkgyL1QzKE/wnXNy9LKAYYHL53vfSn05JMKmn/Ae vNQA== 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 hs9si4910068ejc.78.2021.02.25.16.26.13; Thu, 25 Feb 2021 16:26:36 -0800 (PST) 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 S232791AbhBZAYo (ORCPT + 99 others); Thu, 25 Feb 2021 19:24:44 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:12518 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229824AbhBZAYh (ORCPT ); Thu, 25 Feb 2021 19:24:37 -0500 X-IronPort-AV: E=Sophos;i="5.81,207,1610380800"; d="scan'208";a="104882817" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 26 Feb 2021 08:20:59 +0800 Received: from G08CNEXMBPEKD06.g08.fujitsu.local (unknown [10.167.33.206]) by cn.fujitsu.com (Postfix) with ESMTP id 163FD4CE76F9; Fri, 26 Feb 2021 08:20:59 +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, 26 Feb 2021 08:20: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, 26 Feb 2021 08:20:53 +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, 26 Feb 2021 08:20:53 +0800 From: Shiyang Ruan To: , , , CC: , , , , , , , , , Subject: [PATCH v2 03/10] fsdax: Output address in dax_iomap_pfn() and rename it Date: Fri, 26 Feb 2021 08:20:23 +0800 Message-ID: <20210226002030.653855-4-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210226002030.653855-1-ruansy.fnst@fujitsu.com> References: <20210226002030.653855-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-yoursite-MailScanner-ID: 163FD4CE76F9.A8627 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 9dea1572868e..1459ef4095fb 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; @@ -1357,7 +1365,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) goto error_fault; -- 2.30.1