diff mbox series

[v4,04/10] iomap: lift error code check out of iomap_iter_advance()

Message ID 20250204133044.80551-5-bfoster@redhat.com (mailing list archive)
State New
Headers show
Series iomap: incremental per-operation iter advance | expand

Commit Message

Brian Foster Feb. 4, 2025, 1:30 p.m. UTC
The error code is only used to check whether iomap_iter() should
terminate due to an error returned in iter.processed. Lift the check
out of iomap_iter_advance() in preparation to make it more generic.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/iomap/iter.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Christoph Hellwig Feb. 4, 2025, 1:51 p.m. UTC | #1
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Darrick J. Wong Feb. 4, 2025, 7:23 p.m. UTC | #2
On Tue, Feb 04, 2025 at 08:30:38AM -0500, Brian Foster wrote:
> The error code is only used to check whether iomap_iter() should
> terminate due to an error returned in iter.processed. Lift the check
> out of iomap_iter_advance() in preparation to make it more generic.
> 
> Signed-off-by: Brian Foster <bfoster@redhat.com>
> ---
>  fs/iomap/iter.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/iomap/iter.c b/fs/iomap/iter.c
> index a2ae99fe6431..fcc8d75dd22f 100644
> --- a/fs/iomap/iter.c
> +++ b/fs/iomap/iter.c
> @@ -30,8 +30,6 @@ static inline int iomap_iter_advance(struct iomap_iter *iter, s64 count)
>  	bool stale = iter->iomap.flags & IOMAP_F_STALE;
>  	int ret = 1;
>  
> -	if (count < 0)
> -		return count;
>  	if (WARN_ON_ONCE(count > iomap_length(iter)))
>  		return -EIO;
>  	iter->pos += count;
> @@ -86,6 +84,11 @@ int iomap_iter(struct iomap_iter *iter, const struct iomap_ops *ops)
>  			return ret;
>  	}
>  
> +	if (iter->processed < 0) {
> +		iomap_iter_reset_iomap(iter);
> +		return iter->processed;

Doesn't iomap_iter_reset_iomap reset iter->processed to zero?

--D

> +	}
> +
>  	/* advance and clear state from the previous iteration */
>  	ret = iomap_iter_advance(iter, iter->processed);
>  	iomap_iter_reset_iomap(iter);
> -- 
> 2.48.1
> 
>
Brian Foster Feb. 4, 2025, 7:48 p.m. UTC | #3
On Tue, Feb 04, 2025 at 11:23:53AM -0800, Darrick J. Wong wrote:
> On Tue, Feb 04, 2025 at 08:30:38AM -0500, Brian Foster wrote:
> > The error code is only used to check whether iomap_iter() should
> > terminate due to an error returned in iter.processed. Lift the check
> > out of iomap_iter_advance() in preparation to make it more generic.
> > 
> > Signed-off-by: Brian Foster <bfoster@redhat.com>
> > ---
> >  fs/iomap/iter.c | 7 +++++--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> > 
> > diff --git a/fs/iomap/iter.c b/fs/iomap/iter.c
> > index a2ae99fe6431..fcc8d75dd22f 100644
> > --- a/fs/iomap/iter.c
> > +++ b/fs/iomap/iter.c
> > @@ -30,8 +30,6 @@ static inline int iomap_iter_advance(struct iomap_iter *iter, s64 count)
> >  	bool stale = iter->iomap.flags & IOMAP_F_STALE;
> >  	int ret = 1;
> >  
> > -	if (count < 0)
> > -		return count;
> >  	if (WARN_ON_ONCE(count > iomap_length(iter)))
> >  		return -EIO;
> >  	iter->pos += count;
> > @@ -86,6 +84,11 @@ int iomap_iter(struct iomap_iter *iter, const struct iomap_ops *ops)
> >  			return ret;
> >  	}
> >  
> > +	if (iter->processed < 0) {
> > +		iomap_iter_reset_iomap(iter);
> > +		return iter->processed;
> 
> Doesn't iomap_iter_reset_iomap reset iter->processed to zero?
> 

Urgh.. factoring breakage. Patches 3-6 were all one patch in v3 and for
some reason I left the processed = iter->processed assignment that
avoids this problem for patch 6. That should probably get pulled back to
here. I'll fix that up in v5.

Brian

> --D
> 
> > +	}
> > +
> >  	/* advance and clear state from the previous iteration */
> >  	ret = iomap_iter_advance(iter, iter->processed);
> >  	iomap_iter_reset_iomap(iter);
> > -- 
> > 2.48.1
> > 
> > 
>
diff mbox series

Patch

diff --git a/fs/iomap/iter.c b/fs/iomap/iter.c
index a2ae99fe6431..fcc8d75dd22f 100644
--- a/fs/iomap/iter.c
+++ b/fs/iomap/iter.c
@@ -30,8 +30,6 @@  static inline int iomap_iter_advance(struct iomap_iter *iter, s64 count)
 	bool stale = iter->iomap.flags & IOMAP_F_STALE;
 	int ret = 1;
 
-	if (count < 0)
-		return count;
 	if (WARN_ON_ONCE(count > iomap_length(iter)))
 		return -EIO;
 	iter->pos += count;
@@ -86,6 +84,11 @@  int iomap_iter(struct iomap_iter *iter, const struct iomap_ops *ops)
 			return ret;
 	}
 
+	if (iter->processed < 0) {
+		iomap_iter_reset_iomap(iter);
+		return iter->processed;
+	}
+
 	/* advance and clear state from the previous iteration */
 	ret = iomap_iter_advance(iter, iter->processed);
 	iomap_iter_reset_iomap(iter);