Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp963379pxb; Thu, 26 Aug 2021 20:26:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+OBwbDTggqTBcU+EvuilOCeztqsnfElok1tS5DAdCF1BgQevq0jaksn/LYhAfjSXq/6u/ X-Received: by 2002:a02:7348:: with SMTP id a8mr6126876jae.116.1630034764271; Thu, 26 Aug 2021 20:26:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630034764; cv=none; d=google.com; s=arc-20160816; b=rXh3ug4sKN3QVkJyNBwRVFmslKUcPAbW9AxgIILIDc45tHqb259HJ7/2ZSBZ76YQg/ BTexOAV/6Thh2+lf2VRXFTdSRLfesyFbaR5SGUK3R+yu2E1Yag34Vrh8YDvtmGSm9Jb5 mCr5e4Q+JOel7rm3Vqo7ae9hsVFNqL2NRCzq8ObZkR1PdnGkbZT7NBKoZJhw2IDaZALV 5MCKz5dXvhEJ5sInc6tnwMxafoqmp41yl6N+hW0q5hVtdOVtd6zDWVLc/45DAA3zVW33 cfldot6+oCC8EQC6OgpYf6o2z2o1RfeumvEujCM6lll3xhTgsv3YZuzGY7MyH2w04gJS 66XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject:ironport-hdrordr; bh=0j8bNYJOgp4TcaCk35tGeNbA3c5Cou5LnC/Q15jfL/U=; b=J7w9FF+2lvsxuaig6cdAvIUji9Fvoa+TjSBoTXO600Y7jISgO/YTXiir7ciJEiTuDU LdaIiClIp7PAwu6t24fr7LfQtZi3k477NZhDyvlu3igseLdH8aRBfVGTPJoS8qt62Xd6 7YBdw76HIdnnDZs/RlFU4Bf3UxbeZtQA3yh870rjMFirqcFdj6v1A8M4cFIDbc/NRFs7 dZ0TXxlsyvKmWglIPEOr0quX8le7wufetFMonhtvpQMJmdJqkKJmB7IelmQRXSVc52gv WK6pk1eoDp6e0Nz6cplHtYUjAOSKUqaYOnd3QDgBob/KV99Nrcr4DXiYJFeRdI+g1Sem nj8Q== 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 b135si5031938iof.27.2021.08.26.20.25.51; Thu, 26 Aug 2021 20:26:04 -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 S244204AbhH0DYr (ORCPT + 99 others); Thu, 26 Aug 2021 23:24:47 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:44899 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S244100AbhH0DYq (ORCPT ); Thu, 26 Aug 2021 23:24:46 -0400 IronPort-HdrOrdr: =?us-ascii?q?A9a23=3AXPiOwq8oukES4tm1kO1uk+DkI+orL9Y04lQ7?= =?us-ascii?q?vn2ZKCYlFvBw8vrCoB1173HJYUkqMk3I9ergBEDiewK4yXcW2/hzAV7KZmCP11?= =?us-ascii?q?dAR7sSj7cKrQeBJwTOssZZ1YpFN5N1EcDMCzFB5vrS0U2VFMkBzbC8nJyVuQ?= =?us-ascii?q?=3D=3D?= X-IronPort-AV: E=Sophos;i="5.84,355,1620662400"; d="scan'208";a="113546575" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 27 Aug 2021 11:23:55 +0800 Received: from G08CNEXMBPEKD05.g08.fujitsu.local (unknown [10.167.33.204]) by cn.fujitsu.com (Postfix) with ESMTP id 0A9C04D0D9CD; Fri, 27 Aug 2021 11:23:54 +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; Fri, 27 Aug 2021 11:23:50 +0800 Received: from [192.168.22.65] (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; Fri, 27 Aug 2021 11:23:47 +0800 Subject: Re: [PATCH v7 4/8] fsdax: Add dax_iomap_cow_copy() for dax_iomap_zero To: Dan Williams CC: "Darrick J. Wong" , Christoph Hellwig , linux-xfs , david , linux-fsdevel , Linux Kernel Mailing List , Linux NVDIMM , Goldwyn Rodrigues , Al Viro , Matthew Wilcox , Ritesh Harjani References: <20210816060359.1442450-1-ruansy.fnst@fujitsu.com> <20210816060359.1442450-5-ruansy.fnst@fujitsu.com> From: Shiyang Ruan Message-ID: <6ac5dda5-9681-6b6f-7a84-55215578f0c3@fujitsu.com> Date: Fri, 27 Aug 2021 11:23:47 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-yoursite-MailScanner-ID: 0A9C04D0D9CD.A4211 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 On 2021/8/20 10:39, Dan Williams wrote: > On Sun, Aug 15, 2021 at 11:04 PM Shiyang Ruan wrote: >> >> Punch hole on a reflinked file needs dax_iomap_cow_copy() too. >> Otherwise, data in not aligned area will be not correct. So, add the >> srcmap to dax_iomap_zero() and replace memset() as dax_iomap_cow_copy(). >> >> Signed-off-by: Shiyang Ruan >> Reviewed-by: Ritesh Harjani >> Reviewed-by: Darrick J. Wong >> --- >> fs/dax.c | 25 +++++++++++++++---------- >> fs/iomap/buffered-io.c | 4 ++-- >> include/linux/dax.h | 3 ++- >> 3 files changed, 19 insertions(+), 13 deletions(-) >> >> diff --git a/fs/dax.c b/fs/dax.c >> index e49ba68cc7e4..91ceb518f66a 100644 >> --- a/fs/dax.c >> +++ b/fs/dax.c >> @@ -1198,7 +1198,8 @@ static vm_fault_t dax_pmd_load_hole(struct xa_state *xas, struct vm_fault *vmf, >> } >> #endif /* CONFIG_FS_DAX_PMD */ >> >> -s64 dax_iomap_zero(loff_t pos, u64 length, struct iomap *iomap) >> +s64 dax_iomap_zero(loff_t pos, u64 length, const struct iomap *iomap, >> + const struct iomap *srcmap) >> { >> sector_t sector = iomap_sector(iomap, pos & PAGE_MASK); >> pgoff_t pgoff; >> @@ -1220,19 +1221,23 @@ s64 dax_iomap_zero(loff_t pos, u64 length, struct iomap *iomap) >> >> if (page_aligned) >> rc = dax_zero_page_range(iomap->dax_dev, pgoff, 1); >> - else >> + else { >> rc = dax_direct_access(iomap->dax_dev, pgoff, 1, &kaddr, NULL); >> - if (rc < 0) { >> - dax_read_unlock(id); >> - return rc; >> - } >> - >> - if (!page_aligned) { >> - memset(kaddr + offset, 0, size); >> + if (rc < 0) >> + goto out; >> + if (iomap->addr != srcmap->addr) { >> + rc = dax_iomap_cow_copy(pos, size, PAGE_SIZE, srcmap, >> + kaddr); > > Apologies, I'm confused, why is it ok to skip zeroing here? > That was a mistake. Will be fixed in next version. -- Thanks, Ruan.