From patchwork Tue Jun 7 14:38:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12872023 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D025C43334 for ; Tue, 7 Jun 2022 14:38:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B38ED6B0073; Tue, 7 Jun 2022 10:38:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AE7FF6B0074; Tue, 7 Jun 2022 10:38:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B0EE6B0075; Tue, 7 Jun 2022 10:38:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 8C08C6B0073 for ; Tue, 7 Jun 2022 10:38:44 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 652196065A for ; Tue, 7 Jun 2022 14:38:44 +0000 (UTC) X-FDA: 79551696168.10.561801B Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by imf23.hostedemail.com (Postfix) with ESMTP id A352F140026 for ; Tue, 7 Jun 2022 14:38:14 +0000 (UTC) IronPort-Data: A9a23:EtuDyqqieERBcSCcMmlSjOXrUbJeBmKGZBIvgKrLsJaIsI5as4F+vjAZXWyEaffYazf0L98gboWy9U4E75PQnIVmS1A4/CAxQiMRo6IpJ/zDcB6oYHn6wu4v7a5fx5xHLIGGdajYd1eEzvuWGuWn/SkUOZ2gHOKmUraeYnkpHGeIdQ964f5ds79g6mJXqYjha++9kYuaT/z3YDdJ6RYtWo4nw/7rRCdUgRjHkGhwUmrSyhx8lAS2e3E9VPrzLEwqRpfyatE88uWSH44vwFwll1418SvBCvv9+lr6WkYMBLDPPwmSkWcQUK+n6vRAjnVqlP9la7xHMgEK49mKt4kZJNFlr4G5Txw4eKPKg/g1XQRaEj1lIOtN/7qvzX2X6JbPkBOfIyG0qxlpJARsVWECwc57CH9P+dQWMjcIaQqJhv7wy7W+IsFoh8ImLcDsPI43umxp0jzYS/0hRPjrQ67Kzd5e0i05is1HEbDZfcVxQSVuaBDRSxxJNE0eBJ83kKGvnHaXWzFRrhSX47U252zSxQlq+LnrLNfRPNeNQK19kkSHoWTJ12f0GBcXMJqY0zXt2natgPLf2Cb+cIEMHba7sPlwjzW7z28LDTUSVF2msby3jVO4V9tDKksSvC00osAa7k23Q8L9XzW8oXiZrlgdUd8WGOo/gCmL1KbV5gOxAmkfUiUHbN0gqd9wSTE0vneJlNPBASdz9rGYIVqb/7CFpHWyPjIUInIJZS4sSwYOpdLkpekbjBvJQ5BoELOdicf8EjX9hTuNqUAWnboUicIUxqOT5k3cjnSgq/DhSg8z+xWSUHmp4x10YKa7aIGyr1vW9/BNKMCeVFbplHwFndWOqeMDF5eAkASTT+gXWrKk/fCINHvbm1EHN50g8Sm9vm6tZqhO7zxkYkRkKMAJfXnuekC7kR1Q/ph7LnasbLExZ4O3FtRsyrLvU8nmPs04xPImjoNZLVfBpX8xIxXLmT2FraTlqolnUb/zTCpmJS9y5Xxb8QeL IronPort-HdrOrdr: A9a23:smxAfq3JLcwF/YSkKxBzBgqjBI4kLtp133Aq2lEZdPU1SL39qynKppkmPHDP5gr5J0tLpTntAsi9qBDnhPtICOsqTNSftWDd0QPGEGgI1/qB/9SPIU3D398Y/aJhXow7M9foEGV95PyQ3CCIV/om3/mLmZrFudvj X-IronPort-AV: E=Sophos;i="5.88,333,1635177600"; d="scan'208";a="124761820" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 07 Jun 2022 22:38:40 +0800 Received: from G08CNEXMBPEKD04.g08.fujitsu.local (unknown [10.167.33.201]) by cn.fujitsu.com (Postfix) with ESMTP id 98CEE4D17196; Tue, 7 Jun 2022 22:38:39 +0800 (CST) Received: from G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) by G08CNEXMBPEKD04.g08.fujitsu.local (10.167.33.201) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Tue, 7 Jun 2022 22:38:39 +0800 Received: from irides.mr.mr (10.167.225.141) by G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.23 via Frontend Transport; Tue, 7 Jun 2022 22:38:38 +0800 From: Shiyang Ruan To: , , , , , CC: , , , , , , , , , , Christoph Hellwig , Ritesh Harjani Subject: [PATCH v2.1 08/14] fsdax: Output address in dax_iomap_pfn() and rename it Date: Tue, 7 Jun 2022 22:38:37 +0800 Message-ID: <20220607143837.161174-1-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220603053738.1218681-9-ruansy.fnst@fujitsu.com> References: <20220603053738.1218681-9-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: 98CEE4D17196.A17C2 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: ruansy.fnst@fujitsu.com X-Stat-Signature: kuef1gag4rir13zx6j7pdgaxpym3wryq X-Rspam-User: Authentication-Results: imf23.hostedemail.com; dkim=none; spf=none (imf23.hostedemail.com: domain of ruansy.fnst@fujitsu.com has no SPF policy when checking 183.91.158.132) smtp.mailfrom=ruansy.fnst@fujitsu.com; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=fujitsu.com (policy=none) X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: A352F140026 X-HE-Tag: 1654612694-633595 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 == Hi Andrew, As Dan mentioned[1], the rc should be initialized. I fixed it and resend this patch. [1] https://lore.kernel.org/linux-fsdevel/Yp8FUZnO64Qvyx5G@kili/ --- fs/dax.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index b59b864017ad..7a8eb1e30a1b 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -1026,20 +1026,22 @@ int dax_writeback_mapping_range(struct address_space *mapping, } EXPORT_SYMBOL_GPL(dax_writeback_mapping_range); -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) { pgoff_t pgoff = dax_iomap_pgoff(iomap, pos); - int id, rc; + int id, rc = 0; long length; id = dax_read_lock(); length = dax_direct_access(iomap->dax_dev, pgoff, PHYS_PFN(size), - DAX_ACCESS, NULL, pfnp); + DAX_ACCESS, kaddr, pfnp); if (length < 0) { rc = length; goto out; } + if (!pfnp) + goto out_check_addr; rc = -EINVAL; if (PFN_PHYS(length) < size) goto out; @@ -1049,6 +1051,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; @@ -1456,7 +1464,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);