diff mbox series

[44/44] expand those iov_iter_advance()...

Message ID 20220622041552.737754-44-viro@zeniv.linux.org.uk (mailing list archive)
State New, archived
Headers show
Series [01/44] 9p: handling Rerror without copy_from_iter_full() | expand

Commit Message

Al Viro June 22, 2022, 4:15 a.m. UTC
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 lib/iov_iter.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

Jeff Layton June 28, 2022, 12:23 p.m. UTC | #1
On Wed, 2022-06-22 at 05:15 +0100, Al Viro wrote:
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
> ---
>  lib/iov_iter.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/iov_iter.c b/lib/iov_iter.c
> index a8045c97b975..79c86add8dea 100644
> --- a/lib/iov_iter.c
> +++ b/lib/iov_iter.c
> @@ -1284,7 +1284,8 @@ static ssize_t iter_xarray_get_pages(struct iov_iter *i,
>  		return 0;
>  
>  	maxsize = min_t(size_t, nr * PAGE_SIZE - offset, maxsize);
> -	iov_iter_advance(i, maxsize);
> +	i->iov_offset += maxsize;
> +	i->count -= maxsize;
>  	return maxsize;
>  }
>  
> @@ -1373,7 +1374,13 @@ static ssize_t __iov_iter_get_pages_alloc(struct iov_iter *i,
>  		for (int k = 0; k < n; k++)
>  			get_page(p[k] = page + k);
>  		maxsize = min_t(size_t, maxsize, n * PAGE_SIZE - *start);
> -		iov_iter_advance(i, maxsize);
> +		i->count -= maxsize;
> +		i->iov_offset += maxsize;
> +		if (i->iov_offset == i->bvec->bv_len) {
> +			i->iov_offset = 0;
> +			i->bvec++;
> +			i->nr_segs--;
> +		}
>  		return maxsize;
>  	}
>  	if (iov_iter_is_pipe(i))

Why do this? iov_iter_advance makes it clearer as to what's going on
here.
diff mbox series

Patch

diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index a8045c97b975..79c86add8dea 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -1284,7 +1284,8 @@  static ssize_t iter_xarray_get_pages(struct iov_iter *i,
 		return 0;
 
 	maxsize = min_t(size_t, nr * PAGE_SIZE - offset, maxsize);
-	iov_iter_advance(i, maxsize);
+	i->iov_offset += maxsize;
+	i->count -= maxsize;
 	return maxsize;
 }
 
@@ -1373,7 +1374,13 @@  static ssize_t __iov_iter_get_pages_alloc(struct iov_iter *i,
 		for (int k = 0; k < n; k++)
 			get_page(p[k] = page + k);
 		maxsize = min_t(size_t, maxsize, n * PAGE_SIZE - *start);
-		iov_iter_advance(i, maxsize);
+		i->count -= maxsize;
+		i->iov_offset += maxsize;
+		if (i->iov_offset == i->bvec->bv_len) {
+			i->iov_offset = 0;
+			i->bvec++;
+			i->nr_segs--;
+		}
 		return maxsize;
 	}
 	if (iov_iter_is_pipe(i))