Re: [PATCH 12/26] iov_iter: Add a segmented queue of bio_vec[]

Paulo Alcantara
2026-03-28T18:39:57Z

David Howells <dhowells@redhat.com> writes:

> Add the concept of a segmented queue of bio_vec[] arrays. This allows an
> indefinite quantity of elements to be handled and allows things like
> network filesystems and crypto drivers to glue bits on the ends without
> having to reallocate the array.
>
> The bvecq struct that defines each segment also carries capacity/usage
> information along with flags indicating whether the constituent memory
> regions need freeing or unpinning and the file position of the first
> element in a segment. The bvecq structs are refcounted to allow a queue to
> be extracted in batches and split between a number of subrequests.
>
> The bvecq can have the bio_vec[] it manages allocated in with it, but this
> is not required. A flag is provided for if this is the case as comparing
> ->bv to ->__bv is not sufficient to detect this case.
>
> Add an iterator type ITER_BVECQ for it. This is intended to replace
> ITER_FOLIOQ (and ITER_XARRAY).
>
> Note that the prev pointer is only really needed for iov_iter_revert() and
> could be dispensed with if struct iov_iter contained the head information
> as well as the current point.
>
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Paulo Alcantara <pc@manguebit.org>
> cc: Matthew Wilcox <willy@infradead.org>
> cc: Christoph Hellwig <hch@infradead.org>
> cc: Jens Axboe <axboe@kernel.dk>
> cc: linux-block@vger.kernel.org
> cc: netfs@lists.linux.dev
> cc: linux-fsdevel@vger.kernel.org
> ---
> include/linux/bvecq.h | 46 ++++++
> include/linux/iov_iter.h | 63 +++++++-
> include/linux/uio.h | 11 ++
> lib/iov_iter.c | 288 ++++++++++++++++++++++++++++++++++++-
> lib/scatterlist.c | 66 +++++++++
> lib/tests/kunit_iov_iter.c | 180 +++++++++++++++++++++++
> 6 files changed, 649 insertions(+), 5 deletions(-)
> create mode 100644 include/linux/bvecq.h

Reviewed-by: Paulo Alcantara (Red Hat) <pc@manguebit.org>