reconnect: we need to reset the in/out iovectors on reconnect
This is a bug that has been there a long time. When we reconnect and requeue a PDU we must reset the iovectors for the task. Otherwise, any partially sent/received data when the command is reconnected would end up containing garbage. Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
@@ -324,6 +324,7 @@ void iscsi_set_error(struct iscsi_context *iscsi, const char *error_string,
|
||||
|
||||
struct scsi_iovector *iscsi_get_scsi_task_iovector_in(struct iscsi_context *iscsi, struct iscsi_in_pdu *in);
|
||||
struct scsi_iovector *iscsi_get_scsi_task_iovector_out(struct iscsi_context *iscsi, struct iscsi_pdu *pdu);
|
||||
void scsi_task_reset_iov(struct scsi_iovector *iovector);
|
||||
|
||||
void* iscsi_malloc(struct iscsi_context *iscsi, size_t size);
|
||||
void* iscsi_zmalloc(struct iscsi_context *iscsi, size_t size);
|
||||
|
||||
@@ -351,6 +351,9 @@ try_again:
|
||||
continue;
|
||||
}
|
||||
|
||||
scsi_task_reset_iov(&pdu->scsi_cbdata.task->iovector_in);
|
||||
scsi_task_reset_iov(&pdu->scsi_cbdata.task->iovector_out);
|
||||
|
||||
/* We pass NULL as 'd' since any databuffer has already
|
||||
* been converted to a task-> iovector first time this
|
||||
* PDU was sent.
|
||||
|
||||
@@ -3817,6 +3817,14 @@ scsi_task_set_iov_in(struct scsi_task *task, struct scsi_iovec *iov, int niov)
|
||||
task->iovector_in.niov = niov;
|
||||
}
|
||||
|
||||
void
|
||||
scsi_task_reset_iov(struct scsi_iovector *iovector)
|
||||
{
|
||||
iovector->nalloc = 0;
|
||||
iovector->offset = 0;
|
||||
iovector->consumed = 0;
|
||||
}
|
||||
|
||||
#define IOVECTOR_INITAL_ALLOC (16)
|
||||
|
||||
static int
|
||||
|
||||
Reference in New Issue
Block a user