aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorJayamohan Kallickal <jayamohank@serverengines.com>2010-01-04 18:35:34 -0500
committerJames Bottomley <James.Bottomley@suse.de>2010-01-18 11:48:18 -0500
commitc24622886fb934313a2a43ea1f516cbf1ddd947b (patch)
treeabeb895ec84227b356b53d06219d13a512f9b4cf /drivers/scsi
parent7da5087971b1a187f92be4efb74a991ac9ccb0a3 (diff)
[SCSI] be2iscsi: Move freeing of resources to stop_conn
We need to hold on to ep resources untill invalidate and close connection are completed Signed-off-by: Jayamohan Kallickal <jayamohank@serverengines.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/be2iscsi/be_iscsi.c23
-rw-r--r--drivers/scsi/be2iscsi/be_main.c31
-rw-r--r--drivers/scsi/be2iscsi/be_mgmt.h1
3 files changed, 21 insertions, 34 deletions
diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index 2b3c58bd6529..f22918427a2e 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -460,14 +460,12 @@ static void beiscsi_put_cid(struct beiscsi_hba *phba, unsigned short cid)
460 * beiscsi_free_ep - free endpoint 460 * beiscsi_free_ep - free endpoint
461 * @ep: pointer to iscsi endpoint structure 461 * @ep: pointer to iscsi endpoint structure
462 */ 462 */
463static void beiscsi_free_ep(struct iscsi_endpoint *ep) 463static void beiscsi_free_ep(struct beiscsi_endpoint *beiscsi_ep)
464{ 464{
465 struct beiscsi_endpoint *beiscsi_ep = ep->dd_data;
466 struct beiscsi_hba *phba = beiscsi_ep->phba; 465 struct beiscsi_hba *phba = beiscsi_ep->phba;
467 466
468 beiscsi_put_cid(phba, beiscsi_ep->ep_cid); 467 beiscsi_put_cid(phba, beiscsi_ep->ep_cid);
469 beiscsi_ep->phba = NULL; 468 beiscsi_ep->phba = NULL;
470 iscsi_destroy_endpoint(ep);
471} 469}
472 470
473/** 471/**
@@ -498,7 +496,7 @@ beiscsi_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr,
498 496
499 if (phba->state) { 497 if (phba->state) {
500 ret = -EBUSY; 498 ret = -EBUSY;
501 SE_DEBUG(DBG_LVL_1, "The Adapet state is Not UP \n"); 499 SE_DEBUG(DBG_LVL_1, "The Adapter state is Not UP \n");
502 return ERR_PTR(ret); 500 return ERR_PTR(ret);
503 } 501 }
504 502
@@ -510,9 +508,10 @@ beiscsi_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr,
510 508
511 beiscsi_ep = ep->dd_data; 509 beiscsi_ep = ep->dd_data;
512 beiscsi_ep->phba = phba; 510 beiscsi_ep->phba = phba;
511 beiscsi_ep->openiscsi_ep = ep;
513 512
514 if (beiscsi_open_conn(ep, NULL, dst_addr, non_blocking)) { 513 if (beiscsi_open_conn(ep, NULL, dst_addr, non_blocking)) {
515 SE_DEBUG(DBG_LVL_1, "Failed in allocate iscsi cid\n"); 514 SE_DEBUG(DBG_LVL_1, "Failed in beiscsi_open_conn \n");
516 ret = -ENOMEM; 515 ret = -ENOMEM;
517 goto free_ep; 516 goto free_ep;
518 } 517 }
@@ -520,7 +519,7 @@ beiscsi_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr,
520 return ep; 519 return ep;
521 520
522free_ep: 521free_ep:
523 beiscsi_free_ep(ep); 522 beiscsi_free_ep(beiscsi_ep);
524 return ERR_PTR(ret); 523 return ERR_PTR(ret);
525} 524}
526 525
@@ -547,15 +546,14 @@ int beiscsi_ep_poll(struct iscsi_endpoint *ep, int timeout_ms)
547 * @ep: The iscsi endpoint 546 * @ep: The iscsi endpoint
548 * @flag: The type of connection closure 547 * @flag: The type of connection closure
549 */ 548 */
550static int beiscsi_close_conn(struct iscsi_endpoint *ep, int flag) 549static int beiscsi_close_conn(struct beiscsi_endpoint *beiscsi_ep, int flag)
551{ 550{
552 int ret = 0; 551 int ret = 0;
553 struct beiscsi_endpoint *beiscsi_ep = ep->dd_data;
554 struct beiscsi_hba *phba = beiscsi_ep->phba; 552 struct beiscsi_hba *phba = beiscsi_ep->phba;
555 553
556 if (MGMT_STATUS_SUCCESS != 554 if (MGMT_STATUS_SUCCESS !=
557 mgmt_upload_connection(phba, beiscsi_ep->ep_cid, 555 mgmt_upload_connection(phba, beiscsi_ep->ep_cid,
558 CONNECTION_UPLOAD_GRACEFUL)) { 556 flag)) {
559 SE_DEBUG(DBG_LVL_8, "upload failed for cid 0x%x", 557 SE_DEBUG(DBG_LVL_8, "upload failed for cid 0x%x",
560 beiscsi_ep->ep_cid); 558 beiscsi_ep->ep_cid);
561 ret = -1; 559 ret = -1;
@@ -575,19 +573,15 @@ void beiscsi_ep_disconnect(struct iscsi_endpoint *ep)
575 struct beiscsi_conn *beiscsi_conn; 573 struct beiscsi_conn *beiscsi_conn;
576 struct beiscsi_endpoint *beiscsi_ep; 574 struct beiscsi_endpoint *beiscsi_ep;
577 struct beiscsi_hba *phba; 575 struct beiscsi_hba *phba;
578 int flag = 0;
579 576
580 beiscsi_ep = ep->dd_data; 577 beiscsi_ep = ep->dd_data;
581 phba = beiscsi_ep->phba; 578 phba = beiscsi_ep->phba;
582 SE_DEBUG(DBG_LVL_8, "In beiscsi_ep_disconnect\n");
583 579
584 if (beiscsi_ep->conn) { 580 if (beiscsi_ep->conn) {
585 beiscsi_conn = beiscsi_ep->conn; 581 beiscsi_conn = beiscsi_ep->conn;
586 iscsi_suspend_queue(beiscsi_conn->conn); 582 iscsi_suspend_queue(beiscsi_conn->conn);
587 beiscsi_close_conn(ep, flag);
588 } 583 }
589 584
590 beiscsi_free_ep(ep);
591} 585}
592 586
593/** 587/**
@@ -637,6 +631,9 @@ void beiscsi_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)
637 "mgmt_invalidate_connection Failed for cid=%d \n", 631 "mgmt_invalidate_connection Failed for cid=%d \n",
638 beiscsi_ep->ep_cid); 632 beiscsi_ep->ep_cid);
639 } 633 }
634 beiscsi_close_conn(beiscsi_ep, CONNECTION_UPLOAD_GRACEFUL);
635 beiscsi_free_ep(beiscsi_ep);
636 iscsi_destroy_endpoint(beiscsi_ep->openiscsi_ep);
640 beiscsi_unbind_conn_to_cid(phba, beiscsi_ep->ep_cid); 637 beiscsi_unbind_conn_to_cid(phba, beiscsi_ep->ep_cid);
641 iscsi_conn_stop(cls_conn, flag); 638 iscsi_conn_stop(cls_conn, flag);
642} 639}
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 6c512b6416c2..139002395d99 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -1434,6 +1434,8 @@ static unsigned int beiscsi_process_cq(struct be_eq_obj *pbe_eq)
1434 unsigned int tot_nump = 0; 1434 unsigned int tot_nump = 0;
1435 struct beiscsi_conn *beiscsi_conn; 1435 struct beiscsi_conn *beiscsi_conn;
1436 struct sgl_handle *psgl_handle = NULL; 1436 struct sgl_handle *psgl_handle = NULL;
1437 struct beiscsi_endpoint *beiscsi_ep;
1438 struct iscsi_endpoint *ep;
1437 struct beiscsi_hba *phba; 1439 struct beiscsi_hba *phba;
1438 1440
1439 cq = pbe_eq->cq; 1441 cq = pbe_eq->cq;
@@ -1449,28 +1451,15 @@ static unsigned int beiscsi_process_cq(struct be_eq_obj *pbe_eq)
1449 dw[offsetof(struct amap_sol_cqe_ring, 1451 dw[offsetof(struct amap_sol_cqe_ring,
1450 icd_index) / 32] & SOL_ICD_INDEX_MASK) 1452 icd_index) / 32] & SOL_ICD_INDEX_MASK)
1451 >> 6)]; 1453 >> 6)];
1452 beiscsi_conn = phba->conn_table[psgl_handle->cid]; 1454 ep = phba->ep_array[psgl_handle->cid];
1453 if (!beiscsi_conn || !beiscsi_conn->ep) {
1454 shost_printk(KERN_WARNING, phba->shost,
1455 "Connection table empty for cid = %d\n",
1456 psgl_handle->cid);
1457 return 0;
1458 }
1459
1460 } else { 1455 } else {
1461 beiscsi_conn = phba->conn_table[(u32) ((sol-> 1456 ep = phba->ep_array[(u32) ((sol->
1462 dw[offsetof(struct amap_sol_cqe, cid) / 32] & 1457 dw[offsetof(struct amap_sol_cqe, cid) / 32] &
1463 SOL_CID_MASK) >> 6) - 1458 SOL_CID_MASK) >> 6) -
1464 phba->fw_config.iscsi_cid_start]; 1459 phba->fw_config.iscsi_cid_start];
1465 if (!beiscsi_conn || !beiscsi_conn->ep) {
1466 shost_printk(KERN_WARNING, phba->shost,
1467 "Connection table empty for cid = %d\n",
1468 (u32)(sol->dw[offsetof(struct amap_sol_cqe,
1469 cid) / 32] & SOL_CID_MASK) >> 6);
1470 return 0;
1471 }
1472 } 1460 }
1473 1461 beiscsi_ep = ep->dd_data;
1462 beiscsi_conn = beiscsi_ep->conn;
1474 if (num_processed >= 32) { 1463 if (num_processed >= 32) {
1475 hwi_ring_cq_db(phba, cq->id, 1464 hwi_ring_cq_db(phba, cq->id,
1476 num_processed, 0, 0); 1465 num_processed, 0, 0);
@@ -3044,7 +3033,7 @@ static int hba_setup_cid_tbls(struct beiscsi_hba *phba)
3044{ 3033{
3045 int i, new_cid; 3034 int i, new_cid;
3046 3035
3047 phba->cid_array = kmalloc(sizeof(void *) * phba->params.cxns_per_ctrl, 3036 phba->cid_array = kzalloc(sizeof(void *) * phba->params.cxns_per_ctrl,
3048 GFP_KERNEL); 3037 GFP_KERNEL);
3049 if (!phba->cid_array) { 3038 if (!phba->cid_array) {
3050 shost_printk(KERN_ERR, phba->shost, 3039 shost_printk(KERN_ERR, phba->shost,
@@ -3052,7 +3041,7 @@ static int hba_setup_cid_tbls(struct beiscsi_hba *phba)
3052 "hba_setup_cid_tbls\n"); 3041 "hba_setup_cid_tbls\n");
3053 return -ENOMEM; 3042 return -ENOMEM;
3054 } 3043 }
3055 phba->ep_array = kmalloc(sizeof(struct iscsi_endpoint *) * 3044 phba->ep_array = kzalloc(sizeof(struct iscsi_endpoint *) *
3056 phba->params.cxns_per_ctrl * 2, GFP_KERNEL); 3045 phba->params.cxns_per_ctrl * 2, GFP_KERNEL);
3057 if (!phba->ep_array) { 3046 if (!phba->ep_array) {
3058 shost_printk(KERN_ERR, phba->shost, 3047 shost_printk(KERN_ERR, phba->shost,
diff --git a/drivers/scsi/be2iscsi/be_mgmt.h b/drivers/scsi/be2iscsi/be_mgmt.h
index 24eaff923f85..6bc59e8e1fe5 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.h
+++ b/drivers/scsi/be2iscsi/be_mgmt.h
@@ -231,6 +231,7 @@ struct beiscsi_endpoint {
231 struct beiscsi_hba *phba; 231 struct beiscsi_hba *phba;
232 struct beiscsi_sess *sess; 232 struct beiscsi_sess *sess;
233 struct beiscsi_conn *conn; 233 struct beiscsi_conn *conn;
234 struct iscsi_endpoint *openiscsi_ep;
234 unsigned short ip_type; 235 unsigned short ip_type;
235 char dst6_addr[ISCSI_ADDRESS_BUF_LEN]; 236 char dst6_addr[ISCSI_ADDRESS_BUF_LEN];
236 unsigned long dst_addr; 237 unsigned long dst_addr;