diff options
| author | bing zhao - Sun Microsystems - Beijing China <Bing.Zhao@Sun.COM> | 2009-11-18 10:34:36 +0800 |
|---|---|---|
| committer | bing zhao - Sun Microsystems - Beijing China <Bing.Zhao@Sun.COM> | 2009-11-18 10:34:36 +0800 |
| commit | aefdd1313598221872b3e520302b40e1874f2dc7 (patch) | |
| tree | 84c235df9336e774a04cd27a24d92b7f8fd77cf9 | |
| parent | af68568220d139fee6e01579437e660dbfee20a8 (diff) | |
| download | illumos-joyent-aefdd1313598221872b3e520302b40e1874f2dc7.tar.gz | |
6898392 shutdown through desktop is slow over iscsi boot
6896538 Finding iscsi session protocol error on a x86 (i.e. Initiator) test system during Vdbench test run.
| -rw-r--r-- | usr/src/cmd/iscsid/iscsid.c | 31 | ||||
| -rw-r--r-- | usr/src/uts/common/io/scsi/adapters/iscsi/iscsi_io.c | 45 | ||||
| -rw-r--r-- | usr/src/uts/common/io/scsi/adapters/iscsi/iscsid.c | 14 |
3 files changed, 65 insertions, 25 deletions
diff --git a/usr/src/cmd/iscsid/iscsid.c b/usr/src/cmd/iscsid/iscsid.c index e5a674c3cd..268dcfe3c0 100644 --- a/usr/src/cmd/iscsid/iscsid.c +++ b/usr/src/cmd/iscsid/iscsid.c @@ -53,6 +53,8 @@ #define ISCSI_DOOR_DAEMON_SYSLOG_PP "iscsid" #define ISCSI_DISCOVERY_POLL_DELAY1 1 /* Seconds */ #define ISCSI_DISCOVERY_POLL_DELAY2 60 /* Seconds */ +#define ISCSI_SMF_OFFLINE_DELAY 10 /* Seconds */ +#define ISCSI_SMF_OFFLINE_MAX_RETRY_TIMES 60 #if !defined(SMF_EXIT_ERR_OTHER) #define SMF_EXIT_ERR_OTHER -1 @@ -126,6 +128,8 @@ main( { int i; int sig; + int ret = -1; + int retry = 0; sigset_t sigs, allsigs; struct sigaction act; @@ -256,18 +260,21 @@ main( case SIGQUIT: case SIGINT: case SIGTERM: - if (ioctl( - iscsi_dev_handle, - ISCSI_SMF_OFFLINE, - NULL) == -1) { - perror(gettext("ioctl: disable" - " iscsi initiator")); - /* - * Keep running if unable - * to stop - */ - break; - } + do { + ret = ioctl(iscsi_dev_handle, + ISCSI_SMF_OFFLINE, NULL); + if (ret == -1) { + perror(gettext("ioctl: disable" + " iscsi initiator")); + /* + * Keep retrying if unable + * to stop + */ + (void) sleep(ISCSI_SMF_OFFLINE_DELAY); + retry++; + } + } while (ret == -1 && + retry < ISCSI_SMF_OFFLINE_MAX_RETRY_TIMES); (void) close(iscsi_dev_handle); return (0); break; diff --git a/usr/src/uts/common/io/scsi/adapters/iscsi/iscsi_io.c b/usr/src/uts/common/io/scsi/adapters/iscsi/iscsi_io.c index 73cd096206..c44af8b60b 100644 --- a/usr/src/uts/common/io/scsi/adapters/iscsi/iscsi_io.c +++ b/usr/src/uts/common/io/scsi/adapters/iscsi/iscsi_io.c @@ -1044,20 +1044,38 @@ iscsi_rx_process_reject_rsp(idm_conn_t *ic, idm_pdu_t *pdu) iscsi_hdr_t *old_ihp = NULL; iscsi_conn_t *icp = ic->ic_handle; uint8_t *data = pdu->isp_data; - iscsi_hdr_t *ihp = (iscsi_hdr_t *)irrhp; - idm_status_t status; - iscsi_cmd_t *icmdp = NULL; + idm_status_t status = IDM_STATUS_SUCCESS; + int i = 0; ASSERT(data != NULL); isp = icp->conn_sess; ASSERT(isp != NULL); - mutex_enter(&icp->conn_queue_active.mutex); - if ((status = iscsi_rx_chk(icp, isp, (iscsi_scsi_rsp_hdr_t *)irrhp, - &icmdp)) != IDM_STATUS_SUCCESS) { - mutex_exit(&icp->conn_queue_active.mutex); - return (status); + /* + * In RFC3720 section 10.17, this 4 bytes should be all 0xff. + */ + for (i = 0; i < 4; i++) { + if (irrhp->must_be_ff[i] != 0xff) { + return (IDM_STATUS_PROTOCOL_ERROR); + } + } + mutex_enter(&isp->sess_cmdsn_mutex); + + if (icp->conn_expstatsn == ntohl(irrhp->statsn)) { + icp->conn_expstatsn++; + } else { + cmn_err(CE_WARN, "iscsi connection(%u/%x) protocol error - " + "received status out of order statsn:0x%x " + "expstatsn:0x%x", icp->conn_oid, irrhp->opcode, + ntohl(irrhp->statsn), icp->conn_expstatsn); + mutex_exit(&isp->sess_cmdsn_mutex); + return (IDM_STATUS_PROTOCOL_ERROR); } + /* update expcmdsn and maxcmdsn */ + iscsi_update_flow_control(isp, ntohl(irrhp->maxcmdsn), + ntohl(irrhp->expcmdsn)); + + mutex_exit(&isp->sess_cmdsn_mutex); /* If we don't have the rejected header we can't do anything */ dlength = n2h24(irrhp->dlength); @@ -1098,7 +1116,8 @@ iscsi_rx_process_reject_rsp(idm_conn_t *ic, idm_pdu_t *pdu) */ break; case ISCSI_OP_SCSI_TASK_MGT_MSG: - (void) iscsi_rx_process_rejected_tsk_mgt(ic, old_ihp); + status = + iscsi_rx_process_rejected_tsk_mgt(ic, old_ihp); break; default: cmn_err(CE_WARN, "iscsi connection(%u) protocol error " @@ -1126,14 +1145,14 @@ iscsi_rx_process_reject_rsp(idm_conn_t *ic, idm_pdu_t *pdu) case ISCSI_REJECT_LONG_OPERATION_REJECT: case ISCSI_REJECT_NEGOTIATION_RESET: default: - cmn_err(CE_WARN, "iscsi connection(%u) closing connection - " - "target requested itt:0x%x reason:0x%x", - icp->conn_oid, ihp->itt, irrhp->reason); + cmn_err(CE_WARN, "iscsi connection(%u/%x) closing connection - " + "target requested reason:0x%x", + icp->conn_oid, irrhp->opcode, irrhp->reason); status = IDM_STATUS_PROTOCOL_ERROR; break; } - return (IDM_STATUS_SUCCESS); + return (status); } diff --git a/usr/src/uts/common/io/scsi/adapters/iscsi/iscsid.c b/usr/src/uts/common/io/scsi/adapters/iscsi/iscsid.c index fe65417245..25ea6d52ba 100644 --- a/usr/src/uts/common/io/scsi/adapters/iscsi/iscsid.c +++ b/usr/src/uts/common/io/scsi/adapters/iscsi/iscsid.c @@ -341,6 +341,7 @@ iscsid_start(iscsi_hba_t *ihp) { boolean_t iscsid_stop(iscsi_hba_t *ihp) { boolean_t rval = B_FALSE; + iscsi_sess_t *isp = NULL; if (iscsid_disable_discovery(ihp, ISCSI_ALL_DISCOVERY_METHODS) == B_FALSE) { @@ -353,6 +354,19 @@ iscsid_stop(iscsi_hba_t *ihp) { rw_enter(&ihp->hba_sess_list_rwlock, RW_READER); if (ihp->hba_sess_list == NULL) { rval = B_TRUE; + } else { + /* + * If only boot session is left, that is OK. + * Otherwise, we should consider stop failed. + */ + rval = B_TRUE; + for (isp = ihp->hba_sess_list; isp != NULL; + isp = isp->sess_next) { + if (isp->sess_boot == B_FALSE) { + rval = B_FALSE; + break; + } + } } rw_exit(&ihp->hba_sess_list_rwlock); |
