linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Brian Foster <bfoster@redhat.com>
Cc: linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org,
	Christoph Hellwig <hch@infradead.org>
Subject: Re: [PATCH v2 06/12] dax: advance the iomap_iter on zero range
Date: Wed, 19 Feb 2025 14:34:54 -0800	[thread overview]
Message-ID: <20250219223454.GL21808@frogsfrogsfrogs> (raw)
In-Reply-To: <20250219175050.83986-7-bfoster@redhat.com>

On Wed, Feb 19, 2025 at 12:50:44PM -0500, Brian Foster wrote:
> Update the DAX zero range iomap iter handler to advance the iter
> directly. Advance by the full length in the hole/unwritten case, or
> otherwise advance incrementally in the zeroing loop. In either case,
> return 0 or an error code for success or failure.
> 
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Pretty straightforward
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> ---
>  fs/dax.c | 33 +++++++++++++++++----------------
>  1 file changed, 17 insertions(+), 16 deletions(-)
> 
> diff --git a/fs/dax.c b/fs/dax.c
> index 139e299e53e6..f4d8c8c10086 100644
> --- a/fs/dax.c
> +++ b/fs/dax.c
> @@ -1358,13 +1358,12 @@ static s64 dax_zero_iter(struct iomap_iter *iter, bool *did_zero)
>  {
>  	const struct iomap *iomap = &iter->iomap;
>  	const struct iomap *srcmap = iomap_iter_srcmap(iter);
> -	loff_t pos = iter->pos;
>  	u64 length = iomap_length(iter);
> -	s64 written = 0;
> +	s64 ret;
>  
>  	/* already zeroed?  we're done. */
>  	if (srcmap->type == IOMAP_HOLE || srcmap->type == IOMAP_UNWRITTEN)
> -		return length;
> +		return iomap_iter_advance(iter, &length);
>  
>  	/*
>  	 * invalidate the pages whose sharing state is to be changed
> @@ -1372,33 +1371,35 @@ static s64 dax_zero_iter(struct iomap_iter *iter, bool *did_zero)
>  	 */
>  	if (iomap->flags & IOMAP_F_SHARED)
>  		invalidate_inode_pages2_range(iter->inode->i_mapping,
> -					      pos >> PAGE_SHIFT,
> -					      (pos + length - 1) >> PAGE_SHIFT);
> +				iter->pos >> PAGE_SHIFT,
> +				(iter->pos + length - 1) >> PAGE_SHIFT);
>  
>  	do {
> +		loff_t pos = iter->pos;
>  		unsigned offset = offset_in_page(pos);
> -		unsigned size = min_t(u64, PAGE_SIZE - offset, length);
>  		pgoff_t pgoff = dax_iomap_pgoff(iomap, pos);
> -		long rc;
>  		int id;
>  
> +		length = min_t(u64, PAGE_SIZE - offset, length);
> +
>  		id = dax_read_lock();
> -		if (IS_ALIGNED(pos, PAGE_SIZE) && size == PAGE_SIZE)
> -			rc = dax_zero_page_range(iomap->dax_dev, pgoff, 1);
> +		if (IS_ALIGNED(pos, PAGE_SIZE) && length == PAGE_SIZE)
> +			ret = dax_zero_page_range(iomap->dax_dev, pgoff, 1);
>  		else
> -			rc = dax_memzero(iter, pos, size);
> +			ret = dax_memzero(iter, pos, length);
>  		dax_read_unlock(id);
>  
> -		if (rc < 0)
> -			return rc;
> -		pos += size;
> -		length -= size;
> -		written += size;
> +		if (ret < 0)
> +			return ret;
> +
> +		ret = iomap_iter_advance(iter, &length);
> +		if (ret)
> +			return ret;
>  	} while (length > 0);
>  
>  	if (did_zero)
>  		*did_zero = true;
> -	return written;
> +	return ret;
>  }
>  
>  int dax_zero_range(struct inode *inode, loff_t pos, loff_t len, bool *did_zero,
> -- 
> 2.48.1
> 
> 

  reply	other threads:[~2025-02-19 22:34 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-19 17:50 [PATCH v2 00/12] iomap: incremental advance conversion -- phase 2 Brian Foster
2025-02-19 17:50 ` [PATCH v2 01/12] iomap: advance the iter directly on buffered read Brian Foster
2025-02-19 22:22   ` Darrick J. Wong
2025-02-19 22:31     ` Darrick J. Wong
2025-02-19 17:50 ` [PATCH v2 02/12] iomap: advance the iter on direct I/O Brian Foster
2025-02-19 22:22   ` Darrick J. Wong
2025-02-19 17:50 ` [PATCH v2 03/12] iomap: convert misc simple ops to incremental advance Brian Foster
2025-02-19 22:24   ` Darrick J. Wong
2025-02-19 22:31     ` Darrick J. Wong
2025-02-19 17:50 ` [PATCH v2 04/12] dax: advance the iomap_iter in the read/write path Brian Foster
2025-02-19 22:33   ` Darrick J. Wong
2025-02-20 14:58     ` Brian Foster
2025-02-19 17:50 ` [PATCH v2 05/12] dax: push advance down into dax_iomap_iter() for read and write Brian Foster
2025-02-19 22:34   ` Darrick J. Wong
2025-02-19 17:50 ` [PATCH v2 06/12] dax: advance the iomap_iter on zero range Brian Foster
2025-02-19 22:34   ` Darrick J. Wong [this message]
2025-02-19 17:50 ` [PATCH v2 07/12] dax: advance the iomap_iter on unshare range Brian Foster
2025-02-19 22:35   ` Darrick J. Wong
2025-02-19 17:50 ` [PATCH v2 08/12] dax: advance the iomap_iter on dedupe range Brian Foster
2025-02-19 22:35   ` Darrick J. Wong
2025-02-19 17:50 ` [PATCH v2 09/12] dax: advance the iomap_iter on pte and pmd faults Brian Foster
2025-02-19 22:36   ` Darrick J. Wong
2025-02-19 17:50 ` [PATCH v2 10/12] iomap: remove unnecessary advance from iomap_iter() Brian Foster
2025-02-19 22:30   ` Darrick J. Wong
2025-02-19 17:50 ` [PATCH v2 11/12] iomap: rename iomap_iter processed field to status Brian Foster
2025-02-19 22:30   ` Darrick J. Wong
2025-02-19 17:50 ` [PATCH v2 12/12] iomap: introduce a full map advance helper Brian Foster
2025-02-19 22:31   ` Darrick J. Wong
2025-02-20  9:10 ` [PATCH v2 00/12] iomap: incremental advance conversion -- phase 2 Christian Brauner
2025-02-20 14:59   ` Brian Foster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250219223454.GL21808@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=bfoster@redhat.com \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).