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 <cunyin.chang@intel.com>
Reviewed-on: https://review.gerrithub.io/371823
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Cunyin Chang 2017-07-31 03:49:34 +08:00 committed by Jim Harris
parent 8eba104b73
commit e0e038ec00

View File

@ -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;