Sorry, please ignore the previous patch. There was some minor error in that. Re-attaching the patch here.
Thanks, Aastha. On 8 September 2011 01:44, Aastha Mehta <[email protected]> wrote: > Hi, > > Thanks for the feedback. I have included changes mentioned by different > people. Attaching patch again. Please review it once more. > > Thanks, > Aastha. > > > On 2 September 2011 13:27, Ankit Jain <[email protected]> wrote: > >> On Wed, Aug 31, 2011 at 10:27 PM, Aastha Mehta <[email protected]> >> wrote: >> > Hello, >> > >> > Attached is the patch for the first kernel TODO item in the TODO list >> > circulated earlier. I could not send the patch through git send-email, >> so >> > have attached it here. >> >> I'm new to the code base. Some comments inline: >> >> >diff --git a/usr/initiator.c b/usr/initiator.c >> >index 0350ff8..a2f412a 100644 >> [...] >> > >> >- log_warning("Kernel reported iSCSI connection %d:%d error (%d) " >> >- "state (%d)", session->id, conn->id, error, >> >+ char *err_desc = err_code_to_string(error); >> >+ >> >+ log_warning("Kernel reported iSCSI connection %d:%d error (%d) %s" >> >+ "state (%d)", session->id, conn->id, error, err_desc, >> > conn->state); >> > iscsi_ev_context_put(ev_context); >> >> You probably need a space after the "%s" for err_desc, and also it might >> be >> nice to quote the error desc, to differentiate it from rest of the >> message. eg: >> >> log_warning("Kernel reported iSCSI connection %d:%d error (%d) '%s' " >> >> >diff --git a/usr/kern_error_table.c b/usr/kern_error_table.c >> >+ >> >+char *err_table[NUM_ERRORS] = { >> >+ "ISCSI_OK: iscsi ok", >> >+ "ISCSI_ERR_DATASN: Got invalid data sequence from iSCSI target", >> >> AFAIU, this error is when we get an unexpected data sequence number. >> >> >+ "ISCSI_ERR_DATALEN: Invalid R2T, unexpected datalen value", >> >> This is not R2T specific, AFAICS. >> >> >+ "ISCSI_ERR_BAD_ITT: Invalid invitation to transmit", >> >> ITT is 'Initiator Task Tag'. >> >> >+ >> >+char *err_code_to_string(int code){ >> >+ char *err_string; >> >+ switch(code%1000){ >> >+ case 0: err_string = err_table[0]; >> >+ break; >> >> Wouldn't this be equivalent ? : >> err_string = err_table [code % ISCSI_ERR_BASE]; >> >> Also, probably check for error code for which the table has no entry >> (eg. a new error code added but the table hasn't been updated) and >> handle it accordingly. Also, I would add a comment in iscsi_if.h, >> suggesting >> that this error table needs to be updated when adding new error codes. >> >> Regards, >> Ankit >> >> -- >> You received this message because you are subscribed to the Google Groups >> "open-iscsi" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/open-iscsi?hl=en. >> >> > > > -- > Aastha Mehta > B.E. (Hons.) Computer Science > BITS Pilani > E-mail: [email protected] > > > -- Aastha Mehta B.E. (Hons.) Computer Science BITS Pilani E-mail: [email protected] -- You received this message because you are subscribed to the Google Groups "open-iscsi" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.
From 1bd3d3f9f4c72a3916012edadbd3fc7f9d4f7793 Mon Sep 17 00:00:00 2001 From: Aastha Mehta <[email protected]> Date: Thu, 8 Sep 2011 22:39:14 -0700 Subject: [PATCH 1/1] added code to display verbose messages on session connection error --- usr/Makefile | 2 +- usr/initiator.c | 7 +++++++ usr/kern_error_table.c | 34 ++++++++++++++++++++++++++++++++++ usr/kern_error_table.h | 5 +++++ 4 files changed, 47 insertions(+), 1 deletions(-) create mode 100644 usr/kern_error_table.c create mode 100644 usr/kern_error_table.h diff --git a/usr/Makefile b/usr/Makefile index 3ee0cb4..382139a 100644 --- a/usr/Makefile +++ b/usr/Makefile @@ -44,7 +44,7 @@ ISCSI_LIB_SRCS = iscsi_util.o io.o auth.o iscsi_timer.o login.o log.o md5.o \ iscsi_net_util.o iscsid_req.o transport.o cxgbi.o be2iscsi.o \ initiator_common.o iscsi_err.o $(IPC_OBJ) $(SYSDEPS_SRCS) $(DCB_OBJ) # core initiator files -INITIATOR_SRCS = initiator.o scsi.o actor.o event_poll.o mgmt_ipc.o +INITIATOR_SRCS = initiator.o scsi.o actor.o event_poll.o mgmt_ipc.o kern_error_table.o # fw boot files FW_BOOT_SRCS = $(wildcard ../utils/fwparam_ibft/*.o) diff --git a/usr/initiator.c b/usr/initiator.c index 0350ff8..2507760 100644 --- a/usr/initiator.c +++ b/usr/initiator.c @@ -48,6 +48,8 @@ #include "sysdeps.h" #include "iscsi_err.h" +#include "kern_error_table.h" + #define ISCSI_CONN_ERR_REOPEN_DELAY 3 #define ISCSI_INTERNAL_ERR_REOPEN_DELAY 5 @@ -847,9 +849,14 @@ static void session_conn_error(void *data) iscsi_conn_t *conn = ev_context->conn; iscsi_session_t *session = conn->session; + const char *err_desc = err_code_to_string(error); + log_warning("Kernel reported iSCSI connection %d:%d error (%d) " "state (%d)", session->id, conn->id, error, conn->state); + + log_warning("error %d: %s ", error, err_desc); + iscsi_ev_context_put(ev_context); switch (error) { diff --git a/usr/kern_error_table.c b/usr/kern_error_table.c new file mode 100644 index 0000000..c18d558 --- /dev/null +++ b/usr/kern_error_table.c @@ -0,0 +1,34 @@ +#include<stdio.h> +#include<stdlib.h> +#include<string.h> +#include "iscsi_if.h" +#include"kern_error_table.h" +#define NUM_ERRORS 22 + +const char *err_code_to_string(int code){ + switch(code % ISCSI_ERR_BASE){ + case 0: return "ISCSI_OK: operation successful"; + case 1: return "ISCSI_ERR_DATASN: Received invalid data sequence number from target"; + case 2: return "ISCSI_ERR_DATA_OFFSET: Seeking offset beyond the size of the iSCSI segment"; + case 3: return "ISCSI_ERR_MAX_CMDSN: Received invalid command sequence number from target"; + case 4: return "ISCSI_ERR_EXP_CMDSN: Received invalid expected command sequence number from target"; + case 5: return "ISCSI_ERR_BAD_OPCODE: Received an invalid iSCSI opcode"; + case 6: return "ISCSI_ERR_DATALEN: Invalid R2T, unexpected datalen value"; + case 7: return "ISCSI_ERR_AHSLEN: Received an invalid AHS len"; + case 8: return "ISCSI_ERR_PROTO: iSCSI protocol violation"; + case 9: return "ISCSI_ERR_LUN: LUN mismatch"; + case 10: return "ISCSI_ERR_BAD_ITT: Received invalid initiator task tag from target"; + case 11: return "ISCSI_ERR_CONN_FAILED: iSCSI connection failed"; + case 12: return "ISCSI_ERR_R2TSN: Received invalid R2T (Ready to Transfer) data sequence number from target"; + case 13: return "ISCSI_ERR_SESSION_FAILED: iSCSI session failed"; + case 14: return "ISCSI_ERR_HDR_DGST: Header digest mismatch"; + case 15: return "ISCSI_ERR_DATA_DGST: Data digest mismatch"; + case 16: return "ISCSI_ERR_PARAM_NOT_FOUND: Parameter not found"; + case 17: return "ISCSI_ERR_NO_SCSI_CMD: Could not look up SCSI command"; + case 18: return "ISCSI_ERR_INVALID_HOST: iSCSI host is in an invalid state"; + case 19: return "ISCSI_ERR_XMIT_FAILED: Transmission of iSCSI packet failed"; + case 20: return "ISCSI_ERR_TCP_CONN_CLOSE: TCP connection closed down"; + case 21: return "ISCSI_ERR_SCSI_EH_SESSION_RST: Session was dropped as a result of SCSI error discovery"; + default: return "Invalid error code. Is there a new error code added which is not handled?"; + } +} diff --git a/usr/kern_error_table.h b/usr/kern_error_table.h new file mode 100644 index 0000000..221ac5a --- /dev/null +++ b/usr/kern_error_table.h @@ -0,0 +1,5 @@ +#ifndef __KERN_ERR_TABLE_H__ +#define __KERN_ERR_TABLE_H__ + +extern const char *err_code_to_string(int); +#endif -- 1.7.4.1
