From 0110aad7184ecda81896f54abf5b68b2e5eaf9cf Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Fri, 15 Nov 2019 14:44:46 +0900 Subject: [PATCH] lib/iscsi: Re-check primary task in SCSI Data-Out PDU payload handler We had checked LUN again but we had not checked primary task in iscsi_pdu_payload_op_data(). This had caused unexpected behavior during LUN hotplug. Hence we check if primary task exists again in iscsi_pdu_payload_op_data(), and abort the subtask immediately if not. This change fixes one of the failures we observed. Signed-off-by: Shuhei Matsumoto Change-Id: I5315badf0b90902e77dd5270dd0eda1437a771da Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/474440 Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- lib/iscsi/iscsi.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c index 35bb4e956..754c4d4a5 100644 --- a/lib/iscsi/iscsi.c +++ b/lib/iscsi/iscsi.c @@ -4511,7 +4511,9 @@ reject_return: static int iscsi_pdu_payload_op_data(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu) { - struct spdk_iscsi_task *subtask; + struct spdk_iscsi_task *subtask; + struct iscsi_bhs_data_out *reqh; + uint32_t transfer_tag; if (pdu->task == NULL) { return 0; @@ -4519,6 +4521,17 @@ iscsi_pdu_payload_op_data(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *p subtask = pdu->task; + reqh = (struct iscsi_bhs_data_out *)&pdu->bhs; + transfer_tag = from_be32(&reqh->ttt); + + if (get_transfer_task(conn, transfer_tag) == NULL) { + SPDK_ERRLOG("Not found for transfer_tag=%x\n", transfer_tag); + subtask->scsi.transfer_len = subtask->scsi.length; + spdk_scsi_task_process_abort(&subtask->scsi); + spdk_iscsi_task_cpl(&subtask->scsi); + return 0; + } + if (spdk_likely(!pdu->dif_insert_or_strip)) { spdk_scsi_task_set_data(&subtask->scsi, pdu->data, pdu->data_segment_len); } else {