RECONNCT fix broken reconnect for iov out vectors
We where modifying out_offset and out_len in iscsi_write_to_socket(). If the packet that was being sent before reconnect was a write command the was a significant change that out_offset and out_len where already touched. When requeing the packet after reconnect we where sending garbage! Signed-off-by: Peter Lieven <pl@kamp.de>
This commit is contained in:
@@ -218,7 +218,8 @@ struct iscsi_pdu {
|
|||||||
|
|
||||||
struct iscsi_data outdata; /* Header for PDU to send */
|
struct iscsi_data outdata; /* Header for PDU to send */
|
||||||
uint32_t out_offset; /* Offset into data-out iovector */
|
uint32_t out_offset; /* Offset into data-out iovector */
|
||||||
uint32_t out_len; /* Amount of data to sent */
|
uint32_t out_len; /* Amount of data to sent starting at out_offset */
|
||||||
|
uint32_t out_written; /* Number of bytes written to socket */
|
||||||
|
|
||||||
struct iscsi_data indata;
|
struct iscsi_data indata;
|
||||||
|
|
||||||
|
|||||||
@@ -308,6 +308,7 @@ try_again:
|
|||||||
iscsi->statsn++;
|
iscsi->statsn++;
|
||||||
|
|
||||||
pdu->written = 0;
|
pdu->written = 0;
|
||||||
|
pdu->out_written = 0;
|
||||||
iscsi_add_to_outqueue(iscsi, pdu);
|
iscsi_add_to_outqueue(iscsi, pdu);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,6 +342,7 @@ try_again:
|
|||||||
iscsi->statsn++;
|
iscsi->statsn++;
|
||||||
|
|
||||||
pdu->written = 0;
|
pdu->written = 0;
|
||||||
|
pdu->out_written = 0;
|
||||||
iscsi_add_to_outqueue(iscsi, pdu);
|
iscsi_add_to_outqueue(iscsi, pdu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-5
@@ -517,11 +517,11 @@ iscsi_write_to_socket(struct iscsi_context *iscsi)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Write any iovectors that might have been passed to us */
|
/* Write any iovectors that might have been passed to us */
|
||||||
while (pdu->out_len > 0) {
|
while (pdu->out_written < pdu->out_len) {
|
||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
|
|
||||||
count = pdu->out_len;
|
count = pdu->out_len - pdu->out_written;
|
||||||
buf = iscsi_get_user_out_buffer(iscsi, pdu, pdu->out_offset, &count);
|
buf = iscsi_get_user_out_buffer(iscsi, pdu, pdu->out_offset + pdu->out_written, &count);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
iscsi_set_error(iscsi, "Can't find iovector data for DATA-OUT");
|
iscsi_set_error(iscsi, "Can't find iovector data for DATA-OUT");
|
||||||
return -1;
|
return -1;
|
||||||
@@ -539,8 +539,7 @@ iscsi_write_to_socket(struct iscsi_context *iscsi)
|
|||||||
"socket :%d", errno);
|
"socket :%d", errno);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
pdu->out_offset += count;
|
pdu->out_written += count;
|
||||||
pdu->out_len -= count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pdu->written == total) {
|
if (pdu->written == total) {
|
||||||
|
|||||||
Reference in New Issue
Block a user