/** * Frees all conn objects and deallocs conn descriptor */ static void iser_conn_release(struct iser_conn *ib_conn) { struct iser_device *device = ib_conn->device; BUG_ON(ib_conn->state != ISER_CONN_DOWN); mutex_lock(&ig.connlist_mutex); list_del(&ib_conn->conn_list); mutex_unlock(&ig.connlist_mutex); iser_free_ib_conn_res(ib_conn); ib_conn->device = NULL; /* on EVENT_ADDR_ERROR there's no device yet for this conn */ if (device != NULL) iser_device_try_release(device); if (ib_conn->iser_conn) ib_conn->iser_conn->ib_conn = NULL; iscsi2_destroy_endpoint(ib_conn->ep); }
/** * beiscsi_conn_stop - Invalidate and stop the connection * @cls_conn: pointer to get iscsi_conn * @flag: The type of connection closure */ void beiscsi_conn_stop(struct iscsi_cls_conn *cls_conn, int flag) { struct iscsi_conn *conn = cls_conn->dd_data; struct beiscsi_conn *beiscsi_conn = conn->dd_data; struct beiscsi_endpoint *beiscsi_ep; struct iscsi_session *session = conn->session; struct Scsi_Host *shost = iscsi_session_to_shost(session->cls_session); struct beiscsi_hba *phba = iscsi_host_priv(shost); unsigned int tag; unsigned short savecfg_flag = CMD_ISCSI_SESSION_SAVE_CFG_ON_FLASH; beiscsi_ep = beiscsi_conn->ep; if (!beiscsi_ep) { SE_DEBUG(DBG_LVL_8, "In beiscsi_conn_stop , no beiscsi_ep\n"); return; } SE_DEBUG(DBG_LVL_8, "In beiscsi_conn_stop ep_cid = %d\n", beiscsi_ep->ep_cid); tag = mgmt_invalidate_connection(phba, beiscsi_ep, beiscsi_ep->ep_cid, 0, savecfg_flag); if (!tag) { SE_DEBUG(DBG_LVL_1, "mgmt_invalidate_connection Failed for cid=%d \n", beiscsi_ep->ep_cid); } else { wait_event_interruptible(phba->ctrl.mcc_wait[tag], phba->ctrl.mcc_numtag[tag]); free_mcc_tag(&phba->ctrl, tag); } beiscsi_close_conn(beiscsi_ep, CONNECTION_UPLOAD_GRACEFUL); beiscsi_free_ep(beiscsi_ep); iscsi2_destroy_endpoint(beiscsi_ep->openiscsi_ep); SE_DEBUG(DBG_LVL_8, "In beiscsi_conn_stop for ep_cid = %d\n", beiscsi_ep->ep_cid); beiscsi_unbind_conn_to_cid(phba, beiscsi_ep->ep_cid); iscsi2_conn_stop(cls_conn, flag); }
static struct iscsi_endpoint * iscsi_iser_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr, int non_blocking) { int err; struct iser_conn *ib_conn; struct iscsi_endpoint *ep; ep = iscsi2_create_endpoint(sizeof(*ib_conn)); if (!ep) return ERR_PTR(-ENOMEM); ib_conn = ep->dd_data; ib_conn->ep = ep; iser_conn_init(ib_conn); err = iser_connect(ib_conn, NULL, (struct sockaddr_in *)dst_addr, non_blocking); if (err) { iscsi2_destroy_endpoint(ep); return ERR_PTR(err); } return ep; }