Re: [PATCH 02/10] block: copy bip_max_vcnt vecs instead of bip_vcnt during clone

Christoph Hellwig
2024-05-01T07:50:44Z

On Mon, Apr 29, 2024 at 04:58:37PM +0530, Kanchan Joshi wrote:
> On 4/27/2024 12:33 PM, Christoph Hellwig wrote:
> >> If bio_integrity_copy_user is used to process the meta buffer, bip_max_vcnt
> >> is one greater than bip_vcnt. In this case bip_max_vcnt vecs needs to be
> >> copied to cloned bip.
> > Can you explain this a bit more? The clone should only allocate what
> > is actually used, so this leaves be a bit confused.
> >
>
> Will expand the commit description.
>
> Usually the meta buffer is pinned and used directly (say N bio vecs).
> In case kernel has to make a copy (in bio_integrity_copy_user), it
> factors these N vecs in, and one extra for the bounce buffer.
> So for read IO, bip_max_vcnt is N+1, while bip_vcnt is N.
>
> The clone bio also needs to be aware of all N+1 vecs, so that we can
> copy the data from the bounce buffer to pinned user pages correctly
> during read-completion.

No. The underlying layer below the clone/split/etc should never have
to care about your bounce buffer. The bvecs are just data containers,
and if they are mapped, copied or used in any other way should remain
entirely encapsulated in the caller.