static struct iscsi_r2t_info *iscsi_tcp_get_curr_r2t(struct iscsi_task *task) { struct iscsi_session *session = task->conn->session; struct iscsi_tcp_task *tcp_task = task->dd_data; struct iscsi_r2t_info *r2t = NULL; if (iscsi_task_has_unsol_data(task)) r2t = &task->unsol_r2t; else { spin_lock_bh(&session->lock); if (tcp_task->r2t) { r2t = tcp_task->r2t; /* Continue with this R2T? */ if (r2t->data_length <= r2t->sent) { ISCSI_DBG_TCP(task->conn, " done with r2t %p\n", r2t); __kfifo_put(tcp_task->r2tpool.queue, (void *)&tcp_task->r2t, sizeof(void *)); tcp_task->r2t = r2t = NULL; } } if (r2t == NULL) { __kfifo_get(tcp_task->r2tqueue, (void *)&tcp_task->r2t, sizeof(void *)); r2t = tcp_task->r2t; } spin_unlock_bh(&session->lock); } return r2t; }
static int iscsi_iser_task_xmit_unsol_data(struct iscsi_conn *conn, struct iscsi_task *task) { 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 (iscsi_task_has_unsol_data(task)) { iscsi_prep_data_out_pdu(task, r2t, &hdr); iser_dbg("Sending data-out: itt 0x%x, data count %d\n", 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) { r2t->datasn--; goto iscsi_iser_task_xmit_unsol_data_exit; } r2t->sent += r2t->data_count; iser_dbg("Need to send %d more as data-out PDUs\n", r2t->data_length - r2t->sent); } iscsi_iser_task_xmit_unsol_data_exit: return error; }
static int iscsi_iser_task_xmit_unsol_data(struct iscsi_conn *conn, struct iscsi_task *task) { struct iscsi_r2t_info *r2t = &task->unsol_r2t; struct iscsi_data hdr; int error = 0; while (iscsi_task_has_unsol_data(task)) { iscsi_prep_data_out_pdu(task, r2t, &hdr); iser_dbg("Sending data-out: itt 0x%x, data count %d\n", hdr.itt, r2t->data_count); error = iser_send_data_out(conn, task, &hdr); if (error) { r2t->datasn--; goto iscsi_iser_task_xmit_unsol_data_exit; } r2t->sent += r2t->data_count; iser_dbg("Need to send %d more as data-out PDUs\n", r2t->data_length - r2t->sent); } iscsi_iser_task_xmit_unsol_data_exit: return error; }
static int iscsi_iser_task_xmit(struct iscsi_task *task) { struct iscsi_conn *conn = task->conn; struct iscsi_iser_task *iser_task = task->dd_data; int error = 0; if (!task->sc) return iscsi_iser_mtask_xmit(conn, task); if (task->sc->sc_data_direction == DMA_TO_DEVICE) { BUG_ON(scsi_bufflen(task->sc) == 0); debug_scsi("cmd [itt %x total %d imm %d unsol_data %d\n", task->itt, scsi_bufflen(task->sc), task->imm_count, task->unsol_r2t.data_length); } debug_scsi("task deq [cid %d itt 0x%x]\n", conn->id, task->itt); /* Send the cmd PDU */ if (!iser_task->command_sent) { error = iser_send_command(conn, task); if (error) goto iscsi_iser_task_xmit_exit; iser_task->command_sent = 1; } /* Send unsolicited data-out PDU(s) if necessary */ if (iscsi_task_has_unsol_data(task)) error = iscsi_iser_task_xmit_unsol_data(conn, task); iscsi_iser_task_xmit_exit: if (error && error != -ENOBUFS) iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); return error; }