Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4756512pxj; Tue, 25 May 2021 16:01:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFJ46os4AyGWF4H5HN8A+3QfzoYhBTRvN0SOvMC1onuZkO35dLNn6YIoLbhTN1WOJfmyqw X-Received: by 2002:a05:6e02:1541:: with SMTP id j1mr25163496ilu.146.1621983664281; Tue, 25 May 2021 16:01:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621983664; cv=none; d=google.com; s=arc-20160816; b=eR+FyFL0RuFmvAXo3/06fGRTvtwd8Jhu6h4ABUOezkoDRegrYyomaMxBNCls6m8yNB n8FsTc0w6mOs4jOIr4XU7MmWIImekRCMqtU0EbY6fiVWVcJFyB4sPa7IvQTwvByjSTyR a++L9MOf6qdHS0ZTKWHrvH0quDLwuHm9QSS1Z0CzL7OzOl/43kG/xvuA953396QoYiFV Mes+YL4BD4GzoJIQ65gEin9sRXLErG0P+XR0HyNkRwuJ4B//yfjiXb/Ynq7rxrapeYit 4Yas/j88lm955QKiTWKljYBJe5pDsAoVKiWrNfPP71T5PJz68hcB8DnMujNJFueSmWWR 6jWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=6JBtOsDXeX/tMeY87NVjAV9hKtsSNN+xwz5TAFOfP8A=; b=N2v87lpiMgUUkqaNXtQPvLLstuVMmG8olpzBVp81MXJqDMgCf/1RjH+Owdgb6IlgXx sE9rFyJ5dq8ZVMd282pCF5B48oZ4pdq0HnKHk4hVTniXyVT1ZHgOYB2dILJ4crUxQmpI A93x/3XpnQRqlQCj1G8J4QHL9zPQ2c9CX/dtO7gisAuj274LPNIrOuN4fyCFXgY7ckb3 60UAKoZTbVvpV2KXrXdQuek6WqdMLH4gRryjmXQp8uIdQEWRrH69RGXnqighqY8RZdMy dDtWJL+yUjkh7h2kO9Q33Tbm23gPg8varVU3O4/oDBGxT/oRXp+eH8I7JQ3Uvz8RLVHG Mn6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FGZHuBwg; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l2si15935583ilj.152.2021.05.25.16.00.51; Tue, 25 May 2021 16:01: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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FGZHuBwg; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232439AbhEYWTX (ORCPT + 99 others); Tue, 25 May 2021 18:19:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:54576 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232514AbhEYWTW (ORCPT ); Tue, 25 May 2021 18:19:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1A761613D2; Tue, 25 May 2021 22:17:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621981072; bh=WDYe4wXn7eUjM5C32cO832fX/btSTLyy60ptnCxqzQo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FGZHuBwgpzurmbJAYffUKSaOQ8RQO9M9+ITG5+loT417RjO/uIWiVwgS8e3nOvNkE K0VVTlOLv7U1vW/N1nx+jD6EG5z7SiT5RW3rru8syZ5V4rv8xLfQctczLfzZSWpmtn zpJ8cvXmqJSBtIMGoXJZm9zO8+4acewGi1eATIiR7HFP28Q9UHKp3PKI4YWcR/ZeAp sznb7kwf9LP7svUMv/DhxjaidgRdi0N1R3VG95ygGeqJTJQmVtdF4NoE33teJ9SKlV G4/gwYc3YHU0spOfFcKJBJrEDZsVv9hnM7tSM8g8SBlbmxKFtGeqWOf+vL0aE2olWh aWvmik33uAVPw== Date: Tue, 25 May 2021 15:17:51 -0700 From: "Darrick J. Wong" To: "ruansy.fnst@fujitsu.com" Cc: "linux-kernel@vger.kernel.org" , "linux-xfs@vger.kernel.org" , "linux-nvdimm@lists.01.org" , "linux-fsdevel@vger.kernel.org" , "darrick.wong@oracle.com" , "dan.j.williams@intel.com" , "willy@infradead.org" , "viro@zeniv.linux.org.uk" , "david@fromorbit.com" , "hch@lst.de" , "rgoldwyn@suse.de" , Ritesh Harjani Subject: Re: [PATCH v5 3/7] fsdax: Add dax_iomap_cow_copy() for dax_iomap_zero Message-ID: <20210525221751.GQ202121@locust> References: <20210511030933.3080921-1-ruansy.fnst@fujitsu.com> <20210511030933.3080921-4-ruansy.fnst@fujitsu.com> <20210512011738.GT8582@magnolia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 12, 2021 at 01:37:24AM +0000, ruansy.fnst@fujitsu.com wrote: > > -----Original Message----- > > From: Darrick J. Wong > > Subject: Re: [PATCH v5 3/7] fsdax: Add dax_iomap_cow_copy() for > > dax_iomap_zero > > > > On Tue, May 11, 2021 at 11:09:29AM +0800, Shiyang Ruan wrote: > > > Punch hole on a reflinked file needs dax_copy_edge() too. Otherwise, > > > data in not aligned area will be not correct. So, add the srcmap to > > > dax_iomap_zero() and replace memset() as dax_copy_edge(). > > > > > > Signed-off-by: Shiyang Ruan > > > Reviewed-by: Ritesh Harjani > > > --- > > > fs/dax.c | 25 +++++++++++++++---------- > > > fs/iomap/buffered-io.c | 2 +- > > > include/linux/dax.h | 3 ++- > > > 3 files changed, 18 insertions(+), 12 deletions(-) > > > > > > diff --git a/fs/dax.c b/fs/dax.c > > > index ef0e564e7904..ee9d28a79bfb 100644 > > > --- a/fs/dax.c > > > +++ b/fs/dax.c > > > @@ -1186,7 +1186,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, struct iomap *iomap, > > > + struct iomap *srcmap) > > > { > > > sector_t sector = iomap_sector(iomap, pos & PAGE_MASK); > > > pgoff_t pgoff; > > > @@ -1208,19 +1209,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) { > > > > Why isn't this "if (srcmap->type != IOMAP_HOLE)" ? > > > > I suppose it has the same effect, since @iomap should never be a hole and we > > should never have a @srcmap that's the same as @iomap, but still, we use > > IOMAP_HOLE checks in most other parts of fs/iomap/. > > According to its caller `iomap_zero_range_actor()`, whether > srcmap->type is IOMAP_HOLE has already been checked before > `dax_iomap_zero()`. So the check you suggested will always be true... Ah right, so it is. I'll go review the newest version of this patch. --D > > > -- > Thanks, > Ruan Shiyang. > > > > > Other than that, the logic looks decent to me. > > > > --D > > > > > + rc = dax_iomap_cow_copy(offset, size, PAGE_SIZE, srcmap, > > > + kaddr); > > > + if (rc < 0) > > > + goto out; > > > + } else > > > + memset(kaddr + offset, 0, size); > > > dax_flush(iomap->dax_dev, kaddr + offset, size); > > > } > > > + > > > +out: > > > dax_read_unlock(id); > > > - return size; > > > + return rc < 0 ? rc : size; > > > } > > > > > > static loff_t > > > diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index > > > f2cd2034a87b..2734955ea67f 100644 > > > --- a/fs/iomap/buffered-io.c > > > +++ b/fs/iomap/buffered-io.c > > > @@ -933,7 +933,7 @@ static loff_t iomap_zero_range_actor(struct inode > > *inode, loff_t pos, > > > s64 bytes; > > > > > > if (IS_DAX(inode)) > > > - bytes = dax_iomap_zero(pos, length, iomap); > > > + bytes = dax_iomap_zero(pos, length, iomap, srcmap); > > > else > > > bytes = iomap_zero(inode, pos, length, iomap, srcmap); > > > if (bytes < 0) > > > diff --git a/include/linux/dax.h b/include/linux/dax.h index > > > b52f084aa643..3275e01ed33d 100644 > > > --- a/include/linux/dax.h > > > +++ b/include/linux/dax.h > > > @@ -237,7 +237,8 @@ vm_fault_t dax_finish_sync_fault(struct vm_fault > > > *vmf, int dax_delete_mapping_entry(struct address_space *mapping, > > > pgoff_t index); int dax_invalidate_mapping_entry_sync(struct > > address_space *mapping, > > > pgoff_t index); > > > -s64 dax_iomap_zero(loff_t pos, u64 length, struct iomap *iomap); > > > +s64 dax_iomap_zero(loff_t pos, u64 length, struct iomap *iomap, > > > + struct iomap *srcmap); > > > static inline bool dax_mapping(struct address_space *mapping) { > > > return mapping->host && IS_DAX(mapping->host); > > > -- > > > 2.31.1 > > > > > > > > > > > >