Skip to content

Commit 15ade5b

Browse files
israelrukeithbusch
authored andcommitted
nvme-rdma: Fix transfer length when write_generate/read_verify are 0
When the block layer doesn't generate/verify metadata, the SG length is smaller than the transfer length. This is because the SG length doesn't include the metadata length that is added by the HW on the wire. The target failes those commands with "Data SGL Length Invalid" by comparing the transfer length and the SG length. Fix it by adding the metadata length to the transfer length when there is no metadata SGL. The bug reproduces when setting read_verify/write_generate configs to 0 at the child multipath device or at the primary device when NVMe multipath is disabled. Note that setting those configs to 0 on the multipath device (ns_head) doesn't have any impact on the I/Os. Fixes: 5ec5d3b ("nvme-rdma: add metadata/T10-PI support") Signed-off-by: Israel Rukshin <israelr@nvidia.com> Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Keith Busch <kbusch@kernel.org>
1 parent 41951f8 commit 15ade5b

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

drivers/nvme/host/rdma.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,6 +1410,8 @@ static int nvme_rdma_map_sg_pi(struct nvme_rdma_queue *queue,
14101410
struct nvme_ns *ns = rq->q->queuedata;
14111411
struct bio *bio = rq->bio;
14121412
struct nvme_keyed_sgl_desc *sg = &c->common.dptr.ksgl;
1413+
struct blk_integrity *bi = blk_get_integrity(bio->bi_bdev->bd_disk);
1414+
u32 xfer_len;
14131415
int nr;
14141416

14151417
req->mr = ib_mr_pool_get(queue->qp, &queue->qp->sig_mrs);
@@ -1422,8 +1424,7 @@ static int nvme_rdma_map_sg_pi(struct nvme_rdma_queue *queue,
14221424
if (unlikely(nr))
14231425
goto mr_put;
14241426

1425-
nvme_rdma_set_sig_attrs(blk_get_integrity(bio->bi_bdev->bd_disk), c,
1426-
req->mr->sig_attrs, ns->head->pi_type);
1427+
nvme_rdma_set_sig_attrs(bi, c, req->mr->sig_attrs, ns->head->pi_type);
14271428
nvme_rdma_set_prot_checks(c, &req->mr->sig_attrs->check_mask);
14281429

14291430
ib_update_fast_reg_key(req->mr, ib_inc_rkey(req->mr->rkey));
@@ -1441,7 +1442,11 @@ static int nvme_rdma_map_sg_pi(struct nvme_rdma_queue *queue,
14411442
IB_ACCESS_REMOTE_WRITE;
14421443

14431444
sg->addr = cpu_to_le64(req->mr->iova);
1444-
put_unaligned_le24(req->mr->length, sg->length);
1445+
xfer_len = req->mr->length;
1446+
/* Check if PI is added by the HW */
1447+
if (!pi_count)
1448+
xfer_len += (xfer_len >> bi->interval_exp) * ns->head->pi_size;
1449+
put_unaligned_le24(xfer_len, sg->length);
14451450
put_unaligned_le32(req->mr->rkey, sg->key);
14461451
sg->type = NVME_KEY_SGL_FMT_DATA_DESC << 4;
14471452

0 commit comments

Comments
 (0)