reconnect logic and pdu handling

Rework the reconnect logic so we just call iscsi_scsi_command_async()
for the scsi commands we are re-quining instead of poking into the
private fields of the structures themself.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
Ronnie Sahlberg
2015-02-23 19:28:56 -08:00
parent aedced3b95
commit 76f8296dbb
3 changed files with 14 additions and 26 deletions
-1
View File
@@ -276,7 +276,6 @@ void iscsi_pdu_set_bufferoffset(struct iscsi_pdu *pdu, uint32_t bufferoffset);
int iscsi_pdu_add_data(struct iscsi_context *iscsi, struct iscsi_pdu *pdu, int iscsi_pdu_add_data(struct iscsi_context *iscsi, struct iscsi_pdu *pdu,
unsigned char *dptr, int dsize); unsigned char *dptr, int dsize);
int iscsi_queue_pdu(struct iscsi_context *iscsi, struct iscsi_pdu *pdu); int iscsi_queue_pdu(struct iscsi_context *iscsi, struct iscsi_pdu *pdu);
int iscsi_send_unsolicited_data_out(struct iscsi_context *iscsi, struct iscsi_pdu *pdu);
int iscsi_add_data(struct iscsi_context *iscsi, struct iscsi_data *data, int iscsi_add_data(struct iscsi_context *iscsi, struct iscsi_data *data,
unsigned char *dptr, int dsize, int pdualignment); unsigned char *dptr, int dsize, int pdualignment);
+13 -24
View File
@@ -344,36 +344,25 @@ try_again:
if (pdu->flags & ISCSI_PDU_DROP_ON_RECONNECT) { if (pdu->flags & ISCSI_PDU_DROP_ON_RECONNECT) {
/* /*
* We don't want to requeue NOPs or DATA-OUT PDUs. * We don't want to requeue NOPs or DATA-OUT PDUs.
* In case of DATA-OUT PDUs that are part of the * Any DATA-OUTs we need will be regenerated when we
* initial unsolicited data we have to regenerate * call iscsi_scsi_command_async() below.
* them forther down so that we end the re-queued */
* WRITE + DATA-OUT train with a PDU with the F bit.
*/
iscsi_free_pdu(old_iscsi, pdu); iscsi_free_pdu(old_iscsi, pdu);
continue; continue;
} }
pdu->itt = iscsi_itt_post_increment(iscsi); /* We pass NULL as 'd' since any databuffer has already
iscsi_pdu_set_itt(pdu, pdu->itt); * been converted to a task-> iovector first time this
* PDU was sent.
/* do not increase cmdsn for PDUs marked for immediate delivery
* this will result in a protocol error */
pdu->cmdsn = (pdu->outdata.data[0] & ISCSI_PDU_IMMEDIATE)?iscsi->cmdsn:iscsi->cmdsn++;
iscsi_pdu_set_cmdsn(pdu, pdu->cmdsn);
iscsi_pdu_set_expstatsn(pdu, iscsi->statsn);
iscsi->statsn++;
pdu->outdata_written = 0;
pdu->payload_written = 0;
iscsi_queue_pdu(iscsi, pdu);
/* Requeue any unsolicited data-out for the command PDU we
* just re-queued. These are commands that write data to the
* device but does not have the F bit set.
*/ */
if ((pdu->outdata.data[1] & (ISCSI_PDU_SCSI_WRITE | ISCSI_PDU_SCSI_FINAL)) == ISCSI_PDU_SCSI_WRITE) { if (iscsi_scsi_command_async(iscsi, pdu->lun,
iscsi_send_unsolicited_data_out(iscsi, pdu); pdu->scsi_cbdata.task,
pdu->scsi_cbdata.callback,
NULL,
pdu->scsi_cbdata.private_data)) {
/* not much we can really do at this point */
} }
iscsi_free_pdu(old_iscsi, pdu);
} }
if (dup2(iscsi->fd, old_iscsi->fd) == -1) { if (dup2(iscsi->fd, old_iscsi->fd) == -1) {
+1 -1
View File
@@ -189,7 +189,7 @@ iscsi_timeout_scan(struct iscsi_context *iscsi)
} }
} }
int static int
iscsi_send_unsolicited_data_out(struct iscsi_context *iscsi, struct iscsi_pdu *pdu) iscsi_send_unsolicited_data_out(struct iscsi_context *iscsi, struct iscsi_pdu *pdu)
{ {
uint32_t len = MIN(pdu->expxferlen, iscsi->first_burst_length) - pdu->payload_len; uint32_t len = MIN(pdu->expxferlen, iscsi->first_burst_length) - pdu->payload_len;