max_sectors can be modified via sysfs, but only in kb units. Which leads to a misalignment on stacked devices if the original max_sector size is an odd number. So align the max_sectors setting to kb to avoid this issue. Reported-by: Martin Wilck <martin.wilck@xxxxxxxx> Signed-off-by: Hannes Reinecke <hare@xxxxxxxxxx> --- drivers/scsi/scsi_lib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 2e28e2360c85..aad2ac1353d1 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1983,7 +1983,8 @@ void __scsi_init_queue(struct Scsi_Host *shost, struct request_queue *q) blk_queue_max_integrity_segments(q, shost->sg_prot_tablesize); } - blk_queue_max_hw_sectors(q, shost->max_sectors); + /* Align to kb to avoid conflicts with Sysfs settings */ + blk_queue_max_hw_sectors(q, shost->max_sectors & ~0x1); blk_queue_segment_boundary(q, shost->dma_boundary); dma_set_seg_boundary(dev, shost->dma_boundary); -- 2.35.3