@@ -360,8 +360,6 @@ void
|
|||||||
iscsi_add_to_outqueue(struct iscsi_context *iscsi, struct iscsi_pdu *pdu);
|
iscsi_add_to_outqueue(struct iscsi_context *iscsi, struct iscsi_pdu *pdu);
|
||||||
|
|
||||||
int iscsi_serial32_compare(uint32_t s1, uint32_t s2);
|
int iscsi_serial32_compare(uint32_t s1, uint32_t s2);
|
||||||
void iscsi_adjust_statsn(struct iscsi_context *iscsi, struct iscsi_in_pdu *in);
|
|
||||||
void iscsi_adjust_maxexpcmdsn(struct iscsi_context *iscsi, struct iscsi_in_pdu *in);
|
|
||||||
|
|
||||||
uint32_t iscsi_itt_post_increment(struct iscsi_context *iscsi);
|
uint32_t iscsi_itt_post_increment(struct iscsi_context *iscsi);
|
||||||
|
|
||||||
|
|||||||
@@ -348,9 +348,6 @@ iscsi_process_scsi_reply(struct iscsi_context *iscsi, struct iscsi_pdu *pdu,
|
|||||||
struct iscsi_scsi_cbdata *scsi_cbdata = &pdu->scsi_cbdata;
|
struct iscsi_scsi_cbdata *scsi_cbdata = &pdu->scsi_cbdata;
|
||||||
struct scsi_task *task = scsi_cbdata->task;
|
struct scsi_task *task = scsi_cbdata->task;
|
||||||
|
|
||||||
iscsi_adjust_statsn(iscsi, in);
|
|
||||||
iscsi_adjust_maxexpcmdsn(iscsi, in);
|
|
||||||
|
|
||||||
flags = in->hdr[1];
|
flags = in->hdr[1];
|
||||||
if ((flags&ISCSI_PDU_DATA_FINAL) == 0) {
|
if ((flags&ISCSI_PDU_DATA_FINAL) == 0) {
|
||||||
iscsi_set_error(iscsi, "scsi response pdu but Final bit is "
|
iscsi_set_error(iscsi, "scsi response pdu but Final bit is "
|
||||||
@@ -487,9 +484,6 @@ iscsi_process_scsi_data_in(struct iscsi_context *iscsi, struct iscsi_pdu *pdu,
|
|||||||
struct scsi_task *task = scsi_cbdata->task;
|
struct scsi_task *task = scsi_cbdata->task;
|
||||||
int dsl;
|
int dsl;
|
||||||
|
|
||||||
iscsi_adjust_statsn(iscsi, in);
|
|
||||||
iscsi_adjust_maxexpcmdsn(iscsi, in);
|
|
||||||
|
|
||||||
flags = in->hdr[1];
|
flags = in->hdr[1];
|
||||||
if ((flags&ISCSI_PDU_DATA_ACK_REQUESTED) != 0) {
|
if ((flags&ISCSI_PDU_DATA_ACK_REQUESTED) != 0) {
|
||||||
iscsi_set_error(iscsi, "scsi response asked for ACK "
|
iscsi_set_error(iscsi, "scsi response asked for ACK "
|
||||||
@@ -567,8 +561,6 @@ iscsi_process_r2t(struct iscsi_context *iscsi, struct iscsi_pdu *pdu,
|
|||||||
offset = scsi_get_uint32(&in->hdr[40]);
|
offset = scsi_get_uint32(&in->hdr[40]);
|
||||||
len = scsi_get_uint32(&in->hdr[44]);
|
len = scsi_get_uint32(&in->hdr[44]);
|
||||||
|
|
||||||
iscsi_adjust_maxexpcmdsn(iscsi, in);
|
|
||||||
|
|
||||||
pdu->datasn = 0;
|
pdu->datasn = 0;
|
||||||
iscsi_send_data_out(iscsi, pdu, ttt, offset, len);
|
iscsi_send_data_out(iscsi, pdu, ttt, offset, len);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -1049,9 +1049,7 @@ iscsi_process_login_reply(struct iscsi_context *iscsi, struct iscsi_pdu *pdu,
|
|||||||
if (!iscsi->current_phase && !iscsi->secneg_phase) {
|
if (!iscsi->current_phase && !iscsi->secneg_phase) {
|
||||||
iscsi->statsn = scsi_get_uint32(&in->hdr[24]);
|
iscsi->statsn = scsi_get_uint32(&in->hdr[24]);
|
||||||
}
|
}
|
||||||
iscsi_adjust_statsn(iscsi, in);
|
|
||||||
}
|
}
|
||||||
iscsi_adjust_maxexpcmdsn(iscsi, in);
|
|
||||||
|
|
||||||
/* Using bidirectional CHAP? Then we must see a chap_n and chap_r
|
/* Using bidirectional CHAP? Then we must see a chap_n and chap_r
|
||||||
* field in this PDU
|
* field in this PDU
|
||||||
@@ -1299,10 +1297,8 @@ iscsi_logout_async(struct iscsi_context *iscsi, iscsi_command_cb cb,
|
|||||||
|
|
||||||
int
|
int
|
||||||
iscsi_process_logout_reply(struct iscsi_context *iscsi, struct iscsi_pdu *pdu,
|
iscsi_process_logout_reply(struct iscsi_context *iscsi, struct iscsi_pdu *pdu,
|
||||||
struct iscsi_in_pdu *in)
|
struct iscsi_in_pdu *in _U_)
|
||||||
{
|
{
|
||||||
iscsi_adjust_maxexpcmdsn(iscsi, in);
|
|
||||||
|
|
||||||
iscsi->is_loggedin = 0;
|
iscsi->is_loggedin = 0;
|
||||||
ISCSI_LOG(iscsi, 2, "logout successful");
|
ISCSI_LOG(iscsi, 2, "logout successful");
|
||||||
pdu->callback(iscsi, SCSI_STATUS_GOOD, NULL, pdu->private_data);
|
pdu->callback(iscsi, SCSI_STATUS_GOOD, NULL, pdu->private_data);
|
||||||
|
|||||||
@@ -139,9 +139,6 @@ iscsi_process_nop_out_reply(struct iscsi_context *iscsi, struct iscsi_pdu *pdu,
|
|||||||
{
|
{
|
||||||
struct iscsi_data data;
|
struct iscsi_data data;
|
||||||
|
|
||||||
iscsi_adjust_maxexpcmdsn(iscsi, in);
|
|
||||||
iscsi_adjust_statsn(iscsi, in);
|
|
||||||
|
|
||||||
ISCSI_LOG(iscsi, (iscsi->nops_in_flight > 1) ? 1 : 6,
|
ISCSI_LOG(iscsi, (iscsi->nops_in_flight > 1) ? 1 : 6,
|
||||||
"NOP-In received (pdu->itt %08x, pdu->ttt %08x, iscsi->maxcmdsn %08x, iscsi->expcmdsn %08x, iscsi->statsn %08x)",
|
"NOP-In received (pdu->itt %08x, pdu->ttt %08x, iscsi->maxcmdsn %08x, iscsi->expcmdsn %08x, iscsi->statsn %08x)",
|
||||||
pdu->itt, 0xffffffff, iscsi->maxcmdsn, iscsi->expcmdsn, iscsi->statsn);
|
pdu->itt, 0xffffffff, iscsi->maxcmdsn, iscsi->expcmdsn, iscsi->statsn);
|
||||||
|
|||||||
60
lib/pdu.c
60
lib/pdu.c
@@ -69,31 +69,6 @@ iscsi_itt_post_increment(struct iscsi_context *iscsi) {
|
|||||||
return old_itt;
|
return old_itt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void iscsi_adjust_statsn(struct iscsi_context *iscsi, struct iscsi_in_pdu *in) {
|
|
||||||
uint32_t statsn = scsi_get_uint32(&in->hdr[24]);
|
|
||||||
uint32_t itt = scsi_get_uint32(&in->hdr[16]);
|
|
||||||
|
|
||||||
if (itt == 0xffffffff) {
|
|
||||||
/* target will not increase statsn if itt == 0xffffffff */
|
|
||||||
statsn--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (iscsi_serial32_compare(statsn, iscsi->statsn) > 0) {
|
|
||||||
iscsi->statsn = statsn;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void iscsi_adjust_maxexpcmdsn(struct iscsi_context *iscsi, struct iscsi_in_pdu *in) {
|
|
||||||
uint32_t maxcmdsn = scsi_get_uint32(&in->hdr[32]);
|
|
||||||
if (iscsi_serial32_compare(maxcmdsn, iscsi->maxcmdsn) > 0) {
|
|
||||||
iscsi->maxcmdsn = maxcmdsn;
|
|
||||||
}
|
|
||||||
uint32_t expcmdsn = scsi_get_uint32(&in->hdr[28]);
|
|
||||||
if (iscsi_serial32_compare(expcmdsn, iscsi->expcmdsn) > 0) {
|
|
||||||
iscsi->expcmdsn = expcmdsn;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void iscsi_dump_pdu_header(struct iscsi_context *iscsi, unsigned char *data) {
|
void iscsi_dump_pdu_header(struct iscsi_context *iscsi, unsigned char *data) {
|
||||||
char dump[ISCSI_RAW_HEADER_SIZE*3+1]={0};
|
char dump[ISCSI_RAW_HEADER_SIZE*3+1]={0};
|
||||||
int i;
|
int i;
|
||||||
@@ -323,9 +298,6 @@ int iscsi_process_target_nop_in(struct iscsi_context *iscsi,
|
|||||||
uint32_t itt = scsi_get_uint32(&in->hdr[16]);
|
uint32_t itt = scsi_get_uint32(&in->hdr[16]);
|
||||||
uint32_t lun = scsi_get_uint16(&in->hdr[8]);
|
uint32_t lun = scsi_get_uint16(&in->hdr[8]);
|
||||||
|
|
||||||
iscsi_adjust_statsn(iscsi, in);
|
|
||||||
iscsi_adjust_maxexpcmdsn(iscsi, in);
|
|
||||||
|
|
||||||
ISCSI_LOG(iscsi, (iscsi->nops_in_flight > 1) ? 1 : 6,
|
ISCSI_LOG(iscsi, (iscsi->nops_in_flight > 1) ? 1 : 6,
|
||||||
"NOP-In received (pdu->itt %08x, pdu->ttt %08x, pdu->lun %8x, iscsi->maxcmdsn %08x, iscsi->expcmdsn %08x, iscsi->statsn %08x)",
|
"NOP-In received (pdu->itt %08x, pdu->ttt %08x, pdu->lun %8x, iscsi->maxcmdsn %08x, iscsi->expcmdsn %08x, iscsi->statsn %08x)",
|
||||||
itt, ttt, lun, iscsi->maxcmdsn, iscsi->expcmdsn, iscsi->statsn);
|
itt, ttt, lun, iscsi->maxcmdsn, iscsi->expcmdsn, iscsi->statsn);
|
||||||
@@ -346,8 +318,6 @@ static void iscsi_reconnect_after_logout(struct iscsi_context *iscsi, int status
|
|||||||
{
|
{
|
||||||
if (status) {
|
if (status) {
|
||||||
ISCSI_LOG(iscsi, 1, "logout failed: %s", iscsi_get_error(iscsi));
|
ISCSI_LOG(iscsi, 1, "logout failed: %s", iscsi_get_error(iscsi));
|
||||||
} else {
|
|
||||||
ISCSI_LOG(iscsi, 2, "logout was successful");
|
|
||||||
}
|
}
|
||||||
iscsi->pending_reconnect = 1;
|
iscsi->pending_reconnect = 1;
|
||||||
}
|
}
|
||||||
@@ -409,20 +379,35 @@ int iscsi_process_reject(struct iscsi_context *iscsi,
|
|||||||
int
|
int
|
||||||
iscsi_process_pdu(struct iscsi_context *iscsi, struct iscsi_in_pdu *in)
|
iscsi_process_pdu(struct iscsi_context *iscsi, struct iscsi_in_pdu *in)
|
||||||
{
|
{
|
||||||
uint32_t itt;
|
uint32_t itt = scsi_get_uint32(&in->hdr[16]);
|
||||||
enum iscsi_opcode opcode;
|
uint32_t statsn = scsi_get_uint32(&in->hdr[24]);
|
||||||
|
uint32_t maxcmdsn = scsi_get_uint32(&in->hdr[32]);
|
||||||
|
uint32_t expcmdsn = scsi_get_uint32(&in->hdr[28]);
|
||||||
|
enum iscsi_opcode opcode = in->hdr[0] & 0x3f;
|
||||||
|
uint8_t ahslen = in->hdr[4];
|
||||||
struct iscsi_pdu *pdu;
|
struct iscsi_pdu *pdu;
|
||||||
uint8_t ahslen;
|
|
||||||
|
|
||||||
opcode = in->hdr[0] & 0x3f;
|
|
||||||
ahslen = in->hdr[4];
|
|
||||||
itt = scsi_get_uint32(&in->hdr[16]);
|
|
||||||
|
|
||||||
if (ahslen != 0) {
|
if (ahslen != 0) {
|
||||||
iscsi_set_error(iscsi, "cant handle expanded headers yet");
|
iscsi_set_error(iscsi, "cant handle expanded headers yet");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* All target PDUs expect update the serials */
|
||||||
|
if (itt == 0xffffffff) {
|
||||||
|
/* target will not increase statsn if itt == 0xffffffff */
|
||||||
|
statsn--;
|
||||||
|
}
|
||||||
|
if (iscsi_serial32_compare(statsn, iscsi->statsn) > 0) {
|
||||||
|
iscsi->statsn = statsn;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iscsi_serial32_compare(maxcmdsn, iscsi->maxcmdsn) > 0) {
|
||||||
|
iscsi->maxcmdsn = maxcmdsn;
|
||||||
|
}
|
||||||
|
if (iscsi_serial32_compare(expcmdsn, iscsi->expcmdsn) > 0) {
|
||||||
|
iscsi->expcmdsn = expcmdsn;
|
||||||
|
}
|
||||||
|
|
||||||
if (opcode == ISCSI_PDU_ASYNC_MSG) {
|
if (opcode == ISCSI_PDU_ASYNC_MSG) {
|
||||||
uint8_t event = in->hdr[36];
|
uint8_t event = in->hdr[36];
|
||||||
uint16_t param1 = scsi_get_uint16(&in->hdr[38]);
|
uint16_t param1 = scsi_get_uint16(&in->hdr[38]);
|
||||||
@@ -445,7 +430,6 @@ iscsi_process_pdu(struct iscsi_context *iscsi, struct iscsi_in_pdu *in)
|
|||||||
* Bug_73732 - I/O errors during volume move operation (still present in 7.0.9)
|
* Bug_73732 - I/O errors during volume move operation (still present in 7.0.9)
|
||||||
*/
|
*/
|
||||||
if (getenv("LIBISCSI_DROP_CONN_ON_ASYNC_EVENT1") != NULL) {
|
if (getenv("LIBISCSI_DROP_CONN_ON_ASYNC_EVENT1") != NULL) {
|
||||||
|
|
||||||
ISCSI_LOG(iscsi, 2, "dropping connection to fix errors with broken DELL Equallogic firmware 7.x");
|
ISCSI_LOG(iscsi, 2, "dropping connection to fix errors with broken DELL Equallogic firmware 7.x");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -377,7 +377,8 @@ iscsi_disconnect(struct iscsi_context *iscsi)
|
|||||||
|
|
||||||
close(iscsi->fd);
|
close(iscsi->fd);
|
||||||
|
|
||||||
if (!iscsi->pending_reconnect && iscsi->connected_portal[0]) {
|
if (!(iscsi->pending_reconnect && iscsi->old_iscsi) &&
|
||||||
|
iscsi->connected_portal[0]) {
|
||||||
ISCSI_LOG(iscsi, 2, "disconnected from portal %s",iscsi->connected_portal);
|
ISCSI_LOG(iscsi, 2, "disconnected from portal %s",iscsi->connected_portal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -94,14 +94,9 @@ int
|
|||||||
iscsi_process_task_mgmt_reply(struct iscsi_context *iscsi, struct iscsi_pdu *pdu,
|
iscsi_process_task_mgmt_reply(struct iscsi_context *iscsi, struct iscsi_pdu *pdu,
|
||||||
struct iscsi_in_pdu *in)
|
struct iscsi_in_pdu *in)
|
||||||
{
|
{
|
||||||
uint32_t response;
|
uint32_t response = in->hdr[2];
|
||||||
|
|
||||||
response = in->hdr[2];
|
|
||||||
|
|
||||||
iscsi_adjust_maxexpcmdsn(iscsi, in);
|
|
||||||
|
|
||||||
pdu->callback(iscsi, SCSI_STATUS_GOOD, &response, pdu->private_data);
|
pdu->callback(iscsi, SCSI_STATUS_GOOD, &response, pdu->private_data);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user