Re: [PATCH 3/3] block: make bio auto-integrity deadlock safe

Kanchan Joshi
2025-10-27T06:03:18Z

On 10/23/2025 1:38 PM, Christoph Hellwig wrote:
> @@ -194,6 +194,17 @@ static int blk_validate_integrity_limits(struct queue_limits *lim)
> (1U << bi->interval_exp) - 1);
> }
>
> + /*
> + * The block layer automatically adds integrity data for bios that don't
> + * already have it. It allocates a single segment. Limit the I/O size
> + * so that a single maximum size metadata segment can cover the
> + * integrity data for the entire I/O.
> + */
> + lim->max_sectors = min3(lim->max_sectors,
> + BLK_INTEGRITY_MAX_SIZE /
> + bi->pi_tuple_size * lim->logical_block_size,
> + lim->max_segment_size >> SECTOR_SHIFT);

Two issues:
- When underlying device has pi-type 0, pi_tuple_size will be 0 and this
will cause divide-by-zero.
- The second value in above min3() is in bytes, and other two in
sectors. So this clamping may not be happening correctly.