On Wed, Jul 16, 2025 at 01:45:33PM +0800, Christoph Hellwig wrote: > On Wed, Jul 16, 2025 at 07:44:38PM +0800, Coly Li wrote: > > Do you mean setting max_hw_sectors as (chunk_size * data_disks)? > > If that is what works best: yes. > Simplying setting max_hw_sectors as opt_io_size doesn't solve 2 issues, 1, the split length might be aligned to opt_io_size, but the start offset of a split bio cannot alwasy be aligned to opt_io_size. Current code in bio_split_rw() doesn't handle the alignment. 2, opt_io_size is not large enough comparing max_hw_sector, extra bios in the recursive md code path may hurt performance. Anyway this can be solved by setting max_hw_size as multiple of opt_io_size. Just like hanlding discard requests, handling raid5 read/write bios should try to split the large bio into opt_io_size aligned both *offset* and *length*. If I understand correctly, bio_split_to_limits() doesn't handle offset alignment for read5 read/write bios. Coly Li