aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/be2iscsi/be_iscsi.c
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/be2iscsi/be_iscsi.c
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/be2iscsi/be_iscsi.c')
-rw-r--r--drivers/scsi/be2iscsi/be_iscsi.c23
1 files changed, 10 insertions, 13 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}