From 1bec7d572cf3de6b26b4777f4c8b8d9255a4feae Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Wed, 13 Mar 2019 17:45:21 +0900 Subject: [PATCH] iscsi: Fix the bug when querying DIF context for Data In PDU spdk_iscsi_get_dif_ctx() didn't work correctly for Data In PDU because we had to get iSCSI task from PDU directly for Data In PDU, and lun_id was not copied in spdk_iscsi_task_get(). This patch fixes these bugs and the DIF strip feature was verified after applying this patch. Change-Id: I74d404b82c4a9502a9a8e166748f817d3c2e4368 Signed-off-by: Shuhei Matsumoto Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/447884 Reviewed-by: Ziye Yang Reviewed-by: Changpeng Liu Reviewed-by: Ben Walker Reviewed-by: Jim Harris Tested-by: SPDK CI Jenkins --- lib/iscsi/iscsi.c | 20 ++++++++++++++------ lib/iscsi/task.c | 1 + 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c index 1c6dd571a..f7a8c9c69 100644 --- a/lib/iscsi/iscsi.c +++ b/lib/iscsi/iscsi.c @@ -4686,16 +4686,12 @@ spdk_iscsi_get_dif_ctx(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu, lun_id = spdk_islun2lun(lun); break; } - case ISCSI_OP_SCSI_DATAIN: case ISCSI_OP_SCSI_DATAOUT: { - /* Location of Buffer Offset and TTT in PDU are same - * for Data In and Out, so unify them. - */ - struct iscsi_bhs_data_in *dbhs; + struct iscsi_bhs_data_out *dbhs; struct spdk_iscsi_task *task; int transfer_tag; - dbhs = (struct iscsi_bhs_data_in *)bhs; + dbhs = (struct iscsi_bhs_data_out *)bhs; offset = from_be32(&dbhs->buffer_offset); transfer_tag = from_be32(&dbhs->ttt); task = spdk_get_transfer_task(conn, transfer_tag); @@ -4706,6 +4702,18 @@ spdk_iscsi_get_dif_ctx(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu, lun_id = task->lun_id; break; } + case ISCSI_OP_SCSI_DATAIN: { + struct iscsi_bhs_data_in *dbhs; + struct spdk_iscsi_task *task; + + dbhs = (struct iscsi_bhs_data_in *)bhs; + offset = from_be32(&dbhs->buffer_offset); + task = pdu->task; + assert(task != NULL); + cdb = task->scsi.cdb; + lun_id = task->lun_id; + break; + } default: return false; } diff --git a/lib/iscsi/task.c b/lib/iscsi/task.c index 6b56cd978..1a9a192c6 100644 --- a/lib/iscsi/task.c +++ b/lib/iscsi/task.c @@ -76,6 +76,7 @@ spdk_iscsi_task_get(struct spdk_iscsi_conn *conn, struct spdk_iscsi_task *parent parent->scsi.ref++; task->parent = parent; task->tag = parent->tag; + task->lun_id = parent->lun_id; task->scsi.dxfer_dir = parent->scsi.dxfer_dir; task->scsi.transfer_len = parent->scsi.transfer_len; task->scsi.lun = parent->scsi.lun;