Re: [PATCH v4 02/11] block: copy back bounce buffer to user-space correctly in case of split

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 16, 2024 at 04:59:03PM +0530, Anuj Gupta wrote:
> Copy back the bounce buffer to user-space in entirety when the parent
> bio completes.

This commit message is a bit sparse..

> --- a/block/bio-integrity.c
> +++ b/block/bio-integrity.c
> @@ -119,8 +119,8 @@ static void bio_integrity_unpin_bvec(struct bio_vec *bv, int nr_vecs,
>  static void bio_integrity_uncopy_user(struct bio_integrity_payload *bip)
>  {
>  	unsigned short nr_vecs = bip->bip_max_vcnt - 1;
> -	struct bio_vec *copy = &bip->bip_vec[1];
> -	size_t bytes = bip->bip_iter.bi_size;
> +	struct bio_vec *copy = &bip->bip_vec[1], *bvec = &bip->bip_vec[0];
> +	size_t bytes = bvec->bv_len;
>  	struct iov_iter iter;
>  	int ret;

And while trying to understand what this code does I keep getting
confused by what bio_integrity_uncopy_user actually does.

And I think a bit part of that is the "creative" abuse of bip_vec
by the copy-based integrity code, where bip_vec[0] is the vector
passed to the block layer, and the rest contains the user buffer.

Maybe it's just me, but not stashing the user pages in the bvecs
but just stasing away the actual iov_iter would be much preferable
for this code?

Either way, back to the code.  The existing code uses
bip_iter.bi_size for sizing the copy, and that can be modified when
the bio is cloned (or at least by the rules for the bio data) be
modified by the driver.  So yes, switching away from that is
good and the change looks correct.  That being said, even if we
aren't going to fix up the logic as mentioned above instantly,
can we pick better names for the variables?

static void bio_integrity_uncopy_user(struct bio_integrity_payload *bip)
{
 	unsigned short orig_nr_vecs = bip->bip_max_vcnt - 1;
	struct bio_vec *orig_bvecs = &bip->bip_vec[1];
	struct bio_vec *bounce_bvec = &bip->bip_vec[0];
	size_t bytes = boune_bvec->bv_len;
 	struct iov_iter orig_iter;
	int ret;

	iov_iter_bvec(&orig_iter, ITER_DEST, orig_bvecs, orig_nr_vecs, bytes);
	ret = copy_to_iter(bvec_virt(bounce_bvec), bytes, &orig_iter);
	WARN_ON_ONCE(ret != bytes);

	bio_integrity_unpin_bvec(orig_bvecs, orig_nr_vecs, true);
}

?

Also please add a Fixes tag.




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux