public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Bart Van Assche <bvanassche@acm.org>,
	Ming Lei <ming.lei@redhat.com>,
	"K. Y. Srinivasan" <kys@microsoft.com>,
	Haiyang Zhang <haiyangz@microsoft.com>,
	Wei Liu <wei.liu@kernel.org>, "Ewan D. Milne" <emilne@redhat.com>,
	Laurence Oberman <loberman@redhat.com>,
	linux-rdma@vger.kernel.org, linux-scsi@vger.kernel.org,
	linux-block@vger.kernel.org, Hannes Reinecke <hare@suse.de>
Subject: [PATCH 1/2] RDMA/srp: don't set a max_segment_size when virt_boundary_mask is set
Date: Tue, 24 Jun 2025 14:52:27 +0200	[thread overview]
Message-ID: <20250624125233.219635-2-hch@lst.de> (raw)
In-Reply-To: <20250624125233.219635-1-hch@lst.de>

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 <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
---
 drivers/infiniband/ulp/srp/ib_srp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 1378651735f6..23ed2fc688f0 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -3705,9 +3705,10 @@ static ssize_t add_target_store(struct device *dev,
 	target_host->max_id      = 1;
 	target_host->max_lun     = -1LL;
 	target_host->max_cmd_len = sizeof ((struct srp_cmd *) (void *) 0L)->cdb;
-	target_host->max_segment_size = ib_dma_max_seg_size(ibdev);
 
-	if (!(ibdev->attrs.kernel_cap_flags & IBK_SG_GAPS_REG))
+	if (ibdev->attrs.kernel_cap_flags & IBK_SG_GAPS_REG)
+		target_host->max_segment_size = ib_dma_max_seg_size(ibdev);
+	else
 		target_host->virt_boundary_mask = ~srp_dev->mr_page_mask;
 
 	target = host_to_target(target_host);
-- 
2.47.2


  reply	other threads:[~2025-06-24 12:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-24 12:52 fix virt_boundary_mask handling in SCSI v2 Christoph Hellwig
2025-06-24 12:52 ` Christoph Hellwig [this message]
2025-06-24 13:25   ` [PATCH 1/2] RDMA/srp: don't set a max_segment_size when virt_boundary_mask is set John Garry
2025-06-24 15:54   ` Bart Van Assche
2025-06-24 12:52 ` [PATCH 2/2] scsi: enforce unlimited " Christoph Hellwig
2025-06-24 15:56   ` Bart Van Assche
2025-06-25  1:47 ` fix virt_boundary_mask handling in SCSI v2 Martin K. Petersen
  -- strict thread matches above, loose matches on Subject: below --
2025-06-23  8:02 fix virt_boundary_mask handling in SCSI Christoph Hellwig
2025-06-23  8:02 ` [PATCH 1/2] RDMA/srp: don't set a max_segment_size when virt_boundary_mask is set Christoph Hellwig
2025-06-23 15:31   ` Bart Van Assche
2025-06-24  5:57   ` Hannes Reinecke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250624125233.219635-2-hch@lst.de \
    --to=hch@lst.de \
    --cc=bvanassche@acm.org \
    --cc=emilne@redhat.com \
    --cc=haiyangz@microsoft.com \
    --cc=hare@suse.de \
    --cc=kys@microsoft.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=loberman@redhat.com \
    --cc=martin.petersen@oracle.com \
    --cc=ming.lei@redhat.com \
    --cc=wei.liu@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox