[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAPcyv4gFDyXqu5NyrWQ9Y_JqjLmCb8pWQgPZVBYE=dOir2KdzA@mail.gmail.com>
Date: Thu, 19 Aug 2021 19:39:00 -0700
From: Dan Williams <dan.j.williams@...el.com>
To: Shiyang Ruan <ruansy.fnst@...itsu.com>
Cc: "Darrick J. Wong" <djwong@...nel.org>,
Christoph Hellwig <hch@....de>,
linux-xfs <linux-xfs@...r.kernel.org>,
david <david@...morbit.com>,
linux-fsdevel <linux-fsdevel@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Linux NVDIMM <nvdimm@...ts.linux.dev>,
Goldwyn Rodrigues <rgoldwyn@...e.de>,
Al Viro <viro@...iv.linux.org.uk>,
Matthew Wilcox <willy@...radead.org>,
Ritesh Harjani <riteshh@...ux.ibm.com>
Subject: Re: [PATCH v7 4/8] fsdax: Add dax_iomap_cow_copy() for dax_iomap_zero
On Sun, Aug 15, 2021 at 11:04 PM Shiyang Ruan <ruansy.fnst@...itsu.com> 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 <ruansy.fnst@...itsu.com>
> Reviewed-by: Ritesh Harjani <riteshh@...ux.ibm.com>
> Reviewed-by: Darrick J. Wong <djwong@...nel.org>
> ---
> 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?
Powered by blists - more mailing lists