Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3433051pxb; Sun, 7 Feb 2021 09:12:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJzusRBCYnr/vZ1BNfUpw1bVr2tvFoY4DIGlxoSO7FbhummCYzoQxWNNyJD87dQ4MAOeNewt X-Received: by 2002:a05:6402:4312:: with SMTP id m18mr13583595edc.99.1612717963791; Sun, 07 Feb 2021 09:12:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612717963; cv=none; d=google.com; s=arc-20160816; b=ts5yMhZMQX5wDat8J0c291T73BpJpRXPowsTkrJeFojTq+IaNfTzZOGyXgKSrSjeQm McJ6xHeQfO3RWTYyNryvEP5VuLTK/F7vHZai7ySp0t/vxECa9eUMPqb6XEhGyyi5/io9 e3SE8CnIb3gWASR+240RQWsLcZVreQQstv8oLC17EGLn5n+By//oVfqAonPByan+pvJ+ s0db2/+EY9k1rWCcj/QUqaoBEMl/HhHMGq8bn73d1ET3z1tdlIJnTKyn/MdE890bZyPj cYu3S9ArGHBqwC0ZS7bGtQoMhvhyNwWvKU2MMYT5llAnDhJXF5N4MICt/39KYfyAjjYd Vrxg== 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=biQF0I/jiFICbHVKHIY/Lce1lQHlfwGw6slQzOw/xDo=; b=g2m3SxcdYxXbGvRk1LimAZqD/Zc1HluOb8ZjRGldTFTBPXjMkfu20CQt2RFlR8B48k hHP77BA2H/Xl/AwY9ps7HnA5PV4J5cwV8BhY1KTrCIfVyeLKO/Nv2pllrQjTQkC2jbGW UJOI9L9e2JBwzhfkY/Lel6iDGktbBuZ1h6e8d7Uzp9DkDzTZMng56NiuYNaCuLT3m8zr m+2Gp8hgrPndH3NqJ3P4ufITAxpn0KxdF//xjwJB8nnOwqDXFpDNMtolCrkPnx8bdGDh B17JveJNv2tCSE50STCeO76vC/c7VObJg6be1hgBgnzEgjGdCEM/pUKPJG0tBjmSvZOp qkUw== 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 lw18si563781ejb.271.2021.02.07.09.12.02; Sun, 07 Feb 2021 09:12:43 -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 S229596AbhBGRKV (ORCPT + 99 others); Sun, 7 Feb 2021 12:10:21 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:52559 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229445AbhBGRKU (ORCPT ); Sun, 7 Feb 2021 12:10:20 -0500 X-IronPort-AV: E=Sophos;i="5.81,160,1610380800"; d="scan'208";a="104299365" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 08 Feb 2021 01:09:32 +0800 Received: from G08CNEXMBPEKD04.g08.fujitsu.local (unknown [10.167.33.201]) by cn.fujitsu.com (Postfix) with ESMTP id C6D914CE6033; Mon, 8 Feb 2021 01:09:29 +0800 (CST) Received: from G08CNEXJMPEKD02.g08.fujitsu.local (10.167.33.202) by G08CNEXMBPEKD04.g08.fujitsu.local (10.167.33.201) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 8 Feb 2021 01:09:32 +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; Mon, 8 Feb 2021 01:09:31 +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; Mon, 8 Feb 2021 01:09:30 +0800 From: Shiyang Ruan To: , , , CC: , , , , , , , , , Subject: [PATCH 1/7] fsdax: Output address in dax_iomap_pfn() and rename it Date: Mon, 8 Feb 2021 01:09:18 +0800 Message-ID: <20210207170924.2933035-2-ruansy.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210207170924.2933035-1-ruansy.fnst@cn.fujitsu.com> References: <20210207170924.2933035-1-ruansy.fnst@cn.fujitsu.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-yoursite-MailScanner-ID: C6D914CE6033.AD132 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: ruansy.fnst@cn.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 --- fs/dax.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 5b47834f2e1b..b012b2db7ba2 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -998,8 +998,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; @@ -1011,11 +1011,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; @@ -1025,6 +1027,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; @@ -1348,7 +1356,8 @@ static vm_fault_t dax_iomap_pte_fault(struct vm_fault *vmf, pfn_t *pfnp, count_memcg_event_mm(vma->vm_mm, PGMAJFAULT); major = VM_FAULT_MAJOR; } - error = dax_iomap_pfn(&iomap, pos, PAGE_SIZE, &pfn); + error = dax_iomap_direct_access(&iomap, pos, PAGE_SIZE, + NULL, &pfn); if (error < 0) goto error_finish_iomap; @@ -1566,7 +1575,8 @@ static vm_fault_t dax_iomap_pmd_fault(struct vm_fault *vmf, pfn_t *pfnp, switch (iomap.type) { case IOMAP_MAPPED: - error = dax_iomap_pfn(&iomap, pos, PMD_SIZE, &pfn); + error = dax_iomap_direct_access(&iomap, pos, PMD_SIZE, + NULL, &pfn); if (error < 0) goto finish_iomap; -- 2.30.0