From e0e038ec008e124fac78dbaa75d997326302c3f9 Mon Sep 17 00:00:00 2001 From: Cunyin Chang Date: Mon, 31 Jul 2017 03:49:34 +0800 Subject: [PATCH] iscsi: Fix the bug for hotplug when test with write IO need R2T. This patch fix the bug for hotplug when test with write IO load which need r2t, when the data out data pdus received at target side, the target will try to add subtasks to the luns they are belong to, but the lun probably invalid at this moment because we hot remove it. Change-Id: I3d45dc6b7837944c105c2cca70e63dd4b608706b Signed-off-by: Cunyin Chang Reviewed-on: https://review.gerrithub.io/371823 Tested-by: SPDK Automated Test System Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- lib/iscsi/iscsi.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c index 46dfeeb21b..620b1efdc7 100644 --- a/lib/iscsi/iscsi.c +++ b/lib/iscsi/iscsi.c @@ -4040,12 +4040,15 @@ static int spdk_iscsi_op_data(struct spdk_iscsi_conn *conn, { struct spdk_iscsi_task *task, *subtask; struct iscsi_bhs_data_out *reqh; + struct spdk_scsi_lun *lun_dev; uint32_t transfer_tag; uint32_t task_tag; uint32_t transfer_len; uint32_t DataSN; uint32_t buffer_offset; uint32_t len; + uint64_t lun; + int lun_i; int F_bit; int rc; @@ -4060,6 +4063,9 @@ static int spdk_iscsi_op_data(struct spdk_iscsi_conn *conn, task_tag = from_be32(&reqh->itt); DataSN = from_be32(&reqh->data_sn); buffer_offset = from_be32(&reqh->buffer_offset); + lun = from_be64(&reqh->lun); + lun_i = spdk_islun2lun(lun); + lun_dev = spdk_scsi_dev_get_lun(conn->dev, lun_i); task = spdk_get_transfer_task(conn, transfer_tag); if (task == NULL) { @@ -4137,6 +4143,14 @@ static int spdk_iscsi_op_data(struct spdk_iscsi_conn *conn, task->next_r2t_offset += len; } + if (lun_dev == NULL) { + SPDK_TRACELOG(SPDK_TRACE_DEBUG, "LUN %d is removed, complete the task immediately\n", lun_i); + subtask->scsi.transfer_len = subtask->scsi.length; + spdk_scsi_task_process_null_lun(&subtask->scsi); + spdk_iscsi_task_cpl(&subtask->scsi); + return 0; + } + spdk_iscsi_queue_task(conn, subtask); return 0;