scsi: remove SCSI task id and add iSCSI task tag

The SCSI layer was not using the task ID for anything; the iSCSI layer
was using it to store the task tag, so move it there and rename it to
"tag" to make its purpose clear.

Change-Id: Ibda4f4e215056116b9be4a3a0264f98bc4c29535
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Daniel Verkamp 2017-05-03 13:36:58 -07:00
parent 4ccf74ab3b
commit 414b754579
9 changed files with 15 additions and 23 deletions

View File

@ -107,7 +107,6 @@ struct spdk_scsi_task {
struct spdk_event *cb_event;
uint32_t ref;
uint32_t id;
uint32_t transfer_len;
uint32_t data_out_cnt;
uint32_t dxfer_dir;

View File

@ -941,7 +941,7 @@ void process_task_completion(void *arg1, void *arg2)
}
if (primary->scsi.bytes_completed == primary->scsi.transfer_len) {
spdk_del_transfer_task(conn, primary->scsi.id);
spdk_del_transfer_task(conn, primary->tag);
spdk_iscsi_task_response(conn, primary);
/*
* Check if this is the last task completed for an iSCSI write

View File

@ -2601,7 +2601,7 @@ spdk_get_scsi_task_from_itt(struct spdk_iscsi_conn *conn,
TAILQ_FOREACH(pdu, &conn->snack_pdu_list, tailq) {
if (pdu->bhs.opcode == opcode &&
pdu->task != NULL &&
pdu->task->scsi.id == task_tag) {
pdu->task->tag == task_tag) {
task = pdu->task;
break;
}
@ -2630,7 +2630,7 @@ spdk_iscsi_send_datain(struct spdk_iscsi_conn *conn,
rsp_pdu->data = task->scsi.iovs[0].iov_base + offset;
rsp_pdu->data_from_mempool = true;
task_tag = task->scsi.id;
task_tag = task->tag;
transfer_tag = 0xffffffffU;
F_bit = datain_flag & ISCSI_FLAG_FINAL;
@ -2969,7 +2969,7 @@ spdk_iscsi_op_scsi(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
}
task->scsi.cdb = cdb;
task->scsi.id = task_tag;
task->tag = task_tag;
task->scsi.transfer_len = transfer_len;
task->scsi.target_port = conn->target_port;
task->scsi.initiator_port = conn->initiator_port;
@ -3126,7 +3126,7 @@ void spdk_iscsi_task_response(struct spdk_iscsi_conn *conn,
primary = spdk_iscsi_task_get_primary(task);
transfer_len = primary->scsi.transfer_len;
task_tag = task->scsi.id;
task_tag = task->tag;
/* transfer data from logical unit */
/* (direction is view of initiator side) */
@ -3277,7 +3277,7 @@ spdk_iscsi_op_task(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
spdk_iscsi_task_associate_pdu(task, pdu);
task->scsi.target_port = conn->target_port;
task->scsi.initiator_port = conn->initiator_port;
task->scsi.id = task_tag;
task->tag = task_tag;
task->scsi.lun = spdk_scsi_dev_get_lun(dev, lun_i);
switch (function) {
@ -3542,7 +3542,7 @@ void spdk_del_transfer_task(struct spdk_iscsi_conn *conn, uint32_t task_tag)
int i;
for (i = 0; i < conn->pending_r2t; i++) {
if (conn->outstanding_r2t_tasks[i]->scsi.id == task_tag) {
if (conn->outstanding_r2t_tasks[i]->tag == task_tag) {
task = conn->outstanding_r2t_tasks[i];
conn->outstanding_r2t_tasks[i] = NULL;
conn->data_out_cnt -= task->scsi.data_out_cnt;
@ -4068,9 +4068,9 @@ static int spdk_iscsi_op_data(struct spdk_iscsi_conn *conn,
return SPDK_ISCSI_CONNECTION_FATAL;
}
if (task->scsi.id != task_tag) {
if (task->tag != task_tag) {
SPDK_ERRLOG("The r2t task tag is %u, and the dataout task tag is %u\n",
task->scsi.id, task_tag);
task->tag, task_tag);
goto reject_return;
}
@ -4167,7 +4167,7 @@ spdk_iscsi_send_r2t(struct spdk_iscsi_conn *conn,
rsph->opcode = ISCSI_OP_R2T;
rsph->flags |= 0x80; /* bit 0 is default to 1 */
to_be64(&rsph->lun, spdk_scsi_lun_get_id(task->scsi.lun));
to_be32(&rsph->itt, task->scsi.id);
to_be32(&rsph->itt, task->tag);
to_be32(&rsph->ttt, transfer_tag);
to_be32(&rsph->stat_sn, conn->StatSN);

View File

@ -60,6 +60,9 @@ spdk_iscsi_task_get(uint32_t *owner_task_ctr, struct spdk_iscsi_task *parent)
memset(task, 0, sizeof(*task));
spdk_scsi_task_construct((struct spdk_scsi_task *)task, owner_task_ctr,
(struct spdk_scsi_task *)parent);
if (parent) {
task->tag = parent->tag;
}
task->scsi.free_fn = spdk_iscsi_task_free;
return task;

View File

@ -74,6 +74,8 @@ struct spdk_iscsi_task {
uint32_t acked_data_sn; /* next expected datain datasn */
uint32_t ttt;
uint32_t tag;
TAILQ_ENTRY(spdk_iscsi_task) link;
TAILQ_HEAD(subtask_list, spdk_iscsi_task) subtask_list;

View File

@ -102,7 +102,6 @@ spdk_scsi_task_construct(struct spdk_scsi_task *task, uint32_t *owner_task_ctr,
task->cdb = parent->cdb;
task->target_port = parent->target_port;
task->initiator_port = parent->initiator_port;
task->id = parent->id;
}
}

View File

@ -41,7 +41,6 @@
#include "dev.c"
#include "port.c"
static uint32_t g_task_count = 0;
static struct spdk_bdev g_bdev = {};
struct lun_entry {
@ -72,18 +71,12 @@ spdk_get_task(uint32_t *owner_task_ctr)
return NULL;
}
task->id = g_task_count;
g_task_count++;
return task;
}
void
spdk_scsi_task_put(struct spdk_scsi_task *task)
{
g_task_count--;
free(task);
}

View File

@ -271,9 +271,6 @@ lun_task_mgmt_execute_abort_task_not_supported(void)
task->lun = lun;
task->cdb = cdb;
/* Set the task's id and abort_id to the same value */
mgmt_task->abort_id = task->id;
spdk_scsi_lun_append_task(lun, task);
/* task should now be on the pending_task list */

View File

@ -103,7 +103,6 @@ static void
spdk_init_task(struct spdk_scsi_task *task)
{
memset(task, 0, sizeof(*task));
task->id = 1;
task->iovs = &task->iov;
task->iovcnt = 1;
}