From 26edfdee11eb2afe08fb5f874edcdf0786d6b66c Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Wed, 28 Oct 2026 10:41:47 -0600 Subject: block: apply the segment size to the integrity buffer The integrity buffer is a single segment and must not exceed max_segment_size. max_integrity_io_size() applies that limit to the data size instead, which is off by a factor of 64 for 8 bytes of PI per 512 bytes of data. A SCSI host that doesn't set a maximum segment size gets 64KiB, lpfc and qla2xxx among them, so a DIX disk behind one of those does no IO above 64KiB. Limit the buffer and derive the data size from that, which makes it 4MiB for that case. Fixes: ec7f31b2a2d3 ("block: make bio auto-integrity deadlock safe") Signed-off-by: Josef Bacik Reviewed-by: Christoph Hellwig Link: https://patch.msgid.link/20261028164415.1262013-45-axboe@kernel.dk Signed-off-by: Jens Axboe --- include/linux/blkdev.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'include/linux/blkdev.h') diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index d003a9d2d1f6..1a965fb5ae6f 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1819,11 +1819,12 @@ static inline int bio_split_rw_at(struct bio *bio, */ static inline unsigned int max_integrity_io_size(struct queue_limits *lim) { - u64 max_intervals; + unsigned int buf_size = min_t(unsigned int, lim->max_segment_size, + BLK_INTEGRITY_MAX_SIZE); - max_intervals = BLK_INTEGRITY_MAX_SIZE / lim->integrity.metadata_size; - return min_t(u64, lim->max_segment_size, - max_intervals << lim->integrity.interval_exp); + return min_t(u64, UINT_MAX, + (u64)(buf_size / lim->integrity.metadata_size) << + lim->integrity.interval_exp); } #define DEFINE_IO_COMP_BATCH(name) struct io_comp_batch name = { } -- cgit v1.2.3