Skip to content

Commit 844c6a1

Browse files
Christoph Hellwigmartinkpetersen
authored andcommitted
scsi: RDMA/srp: Don't set a max_segment_size when virt_boundary_mask is set
virt_boundary_mask implies an unlimited max_segment_size. Setting both can lead to data corruption because __blk_rq_map_sg() can split requests so that the virt_boundary_mask is not respected if max_segment_size is not UINT_MAX. Signed-off-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: John Garry <[email protected]> Acked-by: Bart Van Assche <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 8889676 commit 844c6a1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/infiniband/ulp/srp/ib_srp.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3705,9 +3705,10 @@ static ssize_t add_target_store(struct device *dev,
37053705
target_host->max_id = 1;
37063706
target_host->max_lun = -1LL;
37073707
target_host->max_cmd_len = sizeof ((struct srp_cmd *) (void *) 0L)->cdb;
3708-
target_host->max_segment_size = ib_dma_max_seg_size(ibdev);
37093708

3710-
if (!(ibdev->attrs.kernel_cap_flags & IBK_SG_GAPS_REG))
3709+
if (ibdev->attrs.kernel_cap_flags & IBK_SG_GAPS_REG)
3710+
target_host->max_segment_size = ib_dma_max_seg_size(ibdev);
3711+
else
37113712
target_host->virt_boundary_mask = ~srp_dev->mr_page_mask;
37123713

37133714
target = host_to_target(target_host);

0 commit comments

Comments
 (0)