Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp54061pxb; Sun, 15 Aug 2021 23:05:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz20vcOcy5uoQu4vWEO34SvveXYLWGSYQqIfi5xANiNebVfLORFS2lyJEoCzpLMVJrSQur3 X-Received: by 2002:a92:9502:: with SMTP id y2mr7938080ilh.170.1629093919525; Sun, 15 Aug 2021 23:05:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629093919; cv=none; d=google.com; s=arc-20160816; b=uf5nkWzaaiqaXi0DKKxDBBgqWO4uQnNVC2TFoU8Z75AAUkqkjBfWD28rLia++tLi/H ikX5VqmJ2xYKz7hx19ySFtZUXML2Ynho9IeE3gWiVvm6/B30i1Jn49j0I7S7xSKg2xVM alwWcx8kre9v9DQPq2hhEzCHjjRvDVED2oFQHlFuwnqDmHKhN8whME2OYIUV0MEIhqQh 4iWEMGawfLwivve28Ms4Yr2eNW9rmC9MkCv945Gk5jMsDML9YL+qG1x4teUP3VbjobKP 7LrEFr0E5T6l0vzIhaoUNtDtOJMm1/L1PM/NAazIY2Zyn/xX95k59JW/8g6DfS4F1kHD RpEg== 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=0XRGb2GJ+4NQm2focZ6PUN1vkhHf2hX2uxzIHv6Nfds=; b=M23KxHuW+DYaAxa0YHs8fk9J/S/Q9j3QKE0ppz4CtkYTQ7G7H/Xs9EGcDnv2j74he/ oQkN/LHpfMiEjprERKiRINXvlpdo9T8FsA9o4GChlpqQF+OYjT7wN+GPararIVuSkS03 sg0XMN3OzblrKU6AjFY9YcibiX5NpUxTuhxVeyh57IWCoBTJl6N4bYiXTY6wBjAlc8VK 10cRDcrQGplGBdry9C9qYdSjJoVy1bIxhPXDnGVgSRl+kX/buI4ExM8Le6gBWoeeY+BD SGgFQeDmsa884+HjDCoV1krqIG7QNNLA+SNgG675vnmSt9hRdBDHFVAqS2noN2jF5XNL P03w== 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 a17si10400745jal.77.2021.08.15.23.05.08; Sun, 15 Aug 2021 23:05:19 -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 S233329AbhHPGEt (ORCPT + 99 others); Mon, 16 Aug 2021 02:04:49 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:53856 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231680AbhHPGEs (ORCPT ); Mon, 16 Aug 2021 02:04:48 -0400 IronPort-HdrOrdr: =?us-ascii?q?A9a23=3AaxeTIaO5krVJ98BcTv2jsMiBIKoaSvp037BL?= =?us-ascii?q?7TEUdfUxSKGlfq+V8sjzqiWftN98YhAdcLO7Scy9qBHnhP1ICOAqVN/MYOCMgh?= =?us-ascii?q?rLEGgN1+vf6gylMyj/28oY7q14bpV5YeeaMXFKyer8/ym0euxN/OW6?= X-IronPort-AV: E=Sophos;i="5.84,324,1620662400"; d="scan'208";a="112944839" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 16 Aug 2021 14:04:16 +0800 Received: from G08CNEXMBPEKD05.g08.fujitsu.local (unknown [10.167.33.204]) by cn.fujitsu.com (Postfix) with ESMTP id 6D5A94D0D4BB; Mon, 16 Aug 2021 14:04:14 +0800 (CST) Received: from G08CNEXCHPEKD09.g08.fujitsu.local (10.167.33.85) by G08CNEXMBPEKD05.g08.fujitsu.local (10.167.33.204) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Mon, 16 Aug 2021 14:04:11 +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; Mon, 16 Aug 2021 14:04:07 +0800 From: Shiyang Ruan To: , , CC: , , , , , , , , , Ritesh Harjani Subject: [PATCH v7 1/8] fsdax: Output address in dax_iomap_pfn() and rename it Date: Mon, 16 Aug 2021 14:03:52 +0800 Message-ID: <20210816060359.1442450-2-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210816060359.1442450-1-ruansy.fnst@fujitsu.com> References: <20210816060359.1442450-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-yoursite-MailScanner-ID: 6D5A94D0D4BB.A3FB5 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 --- fs/dax.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 118c9e2923f5..9fb6218f42be 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.32.0