Re: [PATCH 1/1] scsi: sas: skip opt_sectors when DMA reports no real optimization hint
From: Christoph Hellwig
Date: Wed Mar 18 2026 - 03:57:17 EST
> if (dma_dev->dma_mask) {
> - shost->opt_sectors = min_t(unsigned int, shost->max_sectors,
> - dma_opt_mapping_size(dma_dev) >> SECTOR_SHIFT);
> + size_t opt = dma_opt_mapping_size(dma_dev);
> +
> + /*
> + * Only set opt_sectors when the DMA layer reports a
> + * genuine optimization constraint. When opt equals
> + * dma_max_mapping_size() no backend provided a real
> + * hint — the value is just the DMA maximum, which is
> + * not useful as an optimal I/O size and can cause
> + * mkfs.xfs to compute invalid stripe geometry.
> + */
> + if (opt < dma_max_mapping_size(dma_dev))
> + shost->opt_sectors = min_t(unsigned int,
> + shost->max_sectors,
> + opt >> SECTOR_SHIFT);
This looks reasonable, but please also round down the opt value
to a power of two when you touch this anyway.
And especially with that this logic is complicated enough that it
warrants a little helper that is clearly split out.