Re: [PATCH v2 2/2] block: Rework splitting of encrypted bios

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

 



On Fri, Jul 11, 2025 at 10:18:52AM -0700, Bart Van Assche wrote:
> @@ -289,9 +266,12 @@ static bool blk_crypto_fallback_encrypt_bio(struct bio **bio_ptr)
>  	bool ret = false;
>  	blk_status_t blk_st;
>  
> -	/* Split the bio if it's too big for single page bvec */
> -	if (!blk_crypto_fallback_split_bio_if_needed(bio_ptr))
> +	/* Verify that bio splitting has occurred. */
> +	if (WARN_ON_ONCE(bio_sectors(*bio_ptr) >
> +			 blk_crypto_max_io_size(*bio_ptr))) {
> +		(*bio_ptr)->bi_status = BLK_STS_IOERR;
>  		return false;
> +	}
>  
>  	src_bio = *bio_ptr;

I'd move the check below this line so that you can use src_bio instead
of dereferencing bio_ptr multiple times.

> +	if (unlikely(!blk_crypto_bio_prep(&bio)))
> +		return NULL;
> +

It feels like returning the new bio would be a better calling
convention than the in-out argument.

> @@ -355,9 +360,12 @@ EXPORT_SYMBOL_GPL(bio_split_rw_at);
>  struct bio *bio_split_rw(struct bio *bio, const struct queue_limits *lim,
>  		unsigned *nr_segs)
>  {
> +	u32 max_sectors =
> +		min(get_max_io_size(bio, lim), blk_crypto_max_io_size(bio));

The blk_crypto_max_io_size should move into get_max_io_size to keep
this tidy.




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux