iovectors: don't reset nalloc when resetting an iovector

Don't reset nalloc when resetting an iovector during reconnect.
Resetting offset/consumed should be sufficient.

Also, don't reset the iovectors when we detect an error condition in
iscsi_iovector_readv_writev. If there is a bug feeding an invalid
pos into this function, where pos suddently points before the amount
of data we have already read/written, then singlan this as an error
and return -EINVAL.

Previosly we did not reset the iovectors correctly when we re-queued
PDUs after a reconnect and thus relied on the iovectors being automatically
reset if/when we detected this type of error in readv_writev.
Now we do reset the iovectors properly so we do nt need to atuo reset them
here anymore and we can change this check to test for and abort the transfer
if an error is detected.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
Ronnie Sahlberg
2015-03-22 08:20:29 -07:00
parent 373d5883d4
commit 2f94f16d02
2 changed files with 8 additions and 6 deletions

View File

@@ -3820,7 +3820,6 @@ scsi_task_set_iov_in(struct scsi_task *task, struct scsi_iovec *iov, int niov)
void
scsi_task_reset_iov(struct scsi_iovector *iovector)
{
iovector->nalloc = 0;
iovector->offset = 0;
iovector->consumed = 0;
}

View File

@@ -420,9 +420,10 @@ iscsi_iovector_readv_writev(struct iscsi_context *iscsi, struct scsi_iovector *i
}
if (pos < iovector->offset) {
/* start over in case we are going backwards */
iovector->offset = 0;
iovector->consumed = 0;
iscsi_set_error(iscsi, "iovector reset. pos is smaller than"
"current offset");
errno = EINVAL;
return -1;
}
if (iovector->niov <= iovector->consumed) {
@@ -578,7 +579,8 @@ iscsi_read_from_socket(struct iscsi_context *iscsi)
return 0;
}
iscsi_set_error(iscsi, "read from socket failed, "
"errno:%d", errno);
"errno:%d %s", errno,
iscsi_get_error(iscsi));
return -1;
}
@@ -689,7 +691,8 @@ iscsi_write_to_socket(struct iscsi_context *iscsi)
return 0;
}
iscsi_set_error(iscsi, "Error when writing to "
"socket :%d", errno);
"socket :%d %s", errno,
iscsi_get_error(iscsi));
return -1;
}