Skip to content

Commit

Permalink
[SCSI] iser: convert iser to new alloc_pdu api
Browse files Browse the repository at this point in the history
This just converts iser to new alloc_pdu api. It still
preallocates the pdu, so there is no difference.

Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
  • Loading branch information
Mike Christie authored and James Bottomley committed Dec 29, 2008
1 parent 577577d commit 0f9c744
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 26 deletions.
48 changes: 25 additions & 23 deletions drivers/infiniband/ulp/iser/iscsi_iser.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ iscsi_iser_recv(struct iscsi_conn *conn,
iscsi_conn_failure(conn, rc);
}

static int iscsi_iser_pdu_alloc(struct iscsi_task *task)
{
struct iscsi_iser_task *iser_task = task->dd_data;

task->hdr = (struct iscsi_hdr *)&iser_task->desc.iscsi_header;
task->hdr_max = sizeof(iser_task->desc.iscsi_header);
return 0;
}

/**
* iscsi_iser_task_init - Initialize task
Expand Down Expand Up @@ -180,25 +188,26 @@ static int
iscsi_iser_task_xmit_unsol_data(struct iscsi_conn *conn,
struct iscsi_task *task)
{
struct iscsi_data hdr;
struct iscsi_r2t_info *r2t = &task->unsol_r2t;
struct iscsi_data hdr;
int error = 0;

/* Send data-out PDUs while there's still unsolicited data to send */
while (task->unsol_count > 0) {
iscsi_prep_unsolicit_data_pdu(task, &hdr);
while (iscsi_task_has_unsol_data(task)) {
iscsi_prep_data_out_pdu(task, r2t, &hdr);
debug_scsi("Sending data-out: itt 0x%x, data count %d\n",
hdr.itt, task->data_count);
hdr.itt, r2t->data_count);

/* the buffer description has been passed with the command */
/* Send the command */
error = iser_send_data_out(conn, task, &hdr);
if (error) {
task->unsol_datasn--;
r2t->datasn--;
goto iscsi_iser_task_xmit_unsol_data_exit;
}
task->unsol_count -= task->data_count;
r2t->sent += r2t->data_count;
debug_scsi("Need to send %d more as data-out PDUs\n",
task->unsol_count);
r2t->data_length - r2t->sent);
}

iscsi_iser_task_xmit_unsol_data_exit:
Expand All @@ -220,7 +229,7 @@ iscsi_iser_task_xmit(struct iscsi_task *task)

debug_scsi("cmd [itt %x total %d imm %d unsol_data %d\n",
task->itt, scsi_bufflen(task->sc),
task->imm_count, task->unsol_count);
task->imm_count, task->unsol_r2t.data_length);
}

debug_scsi("task deq [cid %d itt 0x%x]\n",
Expand All @@ -235,7 +244,7 @@ iscsi_iser_task_xmit(struct iscsi_task *task)
}

/* Send unsolicited data-out PDU(s) if necessary */
if (task->unsol_count)
if (iscsi_task_has_unsol_data(task))
error = iscsi_iser_task_xmit_unsol_data(conn, task);

iscsi_iser_task_xmit_exit:
Expand All @@ -244,13 +253,15 @@ iscsi_iser_task_xmit(struct iscsi_task *task)
return error;
}

static void
iscsi_iser_cleanup_task(struct iscsi_conn *conn, struct iscsi_task *task)
static void iscsi_iser_cleanup_task(struct iscsi_task *task)
{
struct iscsi_iser_task *iser_task = task->dd_data;

/* mgmt tasks do not need special cleanup */
if (!task->sc)
/*
* mgmt tasks do not need special cleanup and we do not
* allocate anything in the init task callout
*/
if (!task->sc || task->state == ISCSI_TASK_PENDING)
return;

if (iser_task->status == ISER_TASK_STATUS_STARTED) {
Expand Down Expand Up @@ -391,9 +402,6 @@ iscsi_iser_session_create(struct iscsi_endpoint *ep,
struct iscsi_cls_session *cls_session;
struct iscsi_session *session;
struct Scsi_Host *shost;
int i;
struct iscsi_task *task;
struct iscsi_iser_task *iser_task;
struct iser_conn *ib_conn;

shost = iscsi_host_alloc(&iscsi_iser_sht, 0, ISCSI_MAX_CMD_PER_LUN);
Expand Down Expand Up @@ -430,13 +438,6 @@ iscsi_iser_session_create(struct iscsi_endpoint *ep,
session = cls_session->dd_data;

shost->can_queue = session->scsi_cmds_max;
/* libiscsi setup itts, data and pool so just set desc fields */
for (i = 0; i < session->cmds_max; i++) {
task = session->cmds[i];
iser_task = task->dd_data;
task->hdr = (struct iscsi_cmd *)&iser_task->desc.iscsi_header;
task->hdr_max = sizeof(iser_task->desc.iscsi_header);
}
return cls_session;

remove_host:
Expand Down Expand Up @@ -652,6 +653,7 @@ static struct iscsi_transport iscsi_iser_transport = {
.init_task = iscsi_iser_task_init,
.xmit_task = iscsi_iser_task_xmit,
.cleanup_task = iscsi_iser_cleanup_task,
.alloc_pdu = iscsi_iser_pdu_alloc,
/* recovery */
.session_recovery_timedout = iscsi_session_recovery_timedout,

Expand Down
5 changes: 2 additions & 3 deletions drivers/infiniband/ulp/iser/iser_initiator.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,7 @@ int iser_send_command(struct iscsi_conn *conn,
unsigned long edtl;
int err = 0;
struct iser_data_buf *data_buf;

struct iscsi_cmd *hdr = task->hdr;
struct iscsi_cmd *hdr = (struct iscsi_cmd *)task->hdr;
struct scsi_cmnd *sc = task->sc;

if (!iser_conn_state_comp(iser_conn->ib_conn, ISER_CONN_UP)) {
Expand Down Expand Up @@ -393,7 +392,7 @@ int iser_send_command(struct iscsi_conn *conn,
err = iser_prepare_write_cmd(task,
task->imm_count,
task->imm_count +
task->unsol_count,
task->unsol_r2t.data_length,
edtl);
if (err)
goto send_command_error;
Expand Down

0 comments on commit 0f9c744

Please sign in to comment.