diff options
Diffstat (limited to 'drivers/scsi/libfc')
-rw-r--r-- | drivers/scsi/libfc/fc_disc.c | 54 | ||||
-rw-r--r-- | drivers/scsi/libfc/fc_elsct.c | 2 | ||||
-rw-r--r-- | drivers/scsi/libfc/fc_fcp.c | 7 | ||||
-rw-r--r-- | drivers/scsi/libfc/fc_lport.c | 74 | ||||
-rw-r--r-- | drivers/scsi/libfc/fc_rport.c | 82 |
5 files changed, 150 insertions, 69 deletions
diff --git a/drivers/scsi/libfc/fc_disc.c b/drivers/scsi/libfc/fc_disc.c index e57556ea5b48..4c880656990b 100644 --- a/drivers/scsi/libfc/fc_disc.c +++ b/drivers/scsi/libfc/fc_disc.c | |||
@@ -113,6 +113,11 @@ void fc_disc_stop_rports(struct fc_disc *disc) | |||
113 | lport->tt.rport_logoff(rport); | 113 | lport->tt.rport_logoff(rport); |
114 | } | 114 | } |
115 | 115 | ||
116 | list_for_each_entry_safe(rdata, next, &disc->rogue_rports, peers) { | ||
117 | rport = PRIV_TO_RPORT(rdata); | ||
118 | lport->tt.rport_logoff(rport); | ||
119 | } | ||
120 | |||
116 | mutex_unlock(&disc->disc_mutex); | 121 | mutex_unlock(&disc->disc_mutex); |
117 | } | 122 | } |
118 | 123 | ||
@@ -131,23 +136,32 @@ static void fc_disc_rport_callback(struct fc_lport *lport, | |||
131 | { | 136 | { |
132 | struct fc_rport_libfc_priv *rdata = rport->dd_data; | 137 | struct fc_rport_libfc_priv *rdata = rport->dd_data; |
133 | struct fc_disc *disc = &lport->disc; | 138 | struct fc_disc *disc = &lport->disc; |
134 | int found = 0; | ||
135 | 139 | ||
136 | FC_DEBUG_DISC("Received a %d event for port (%6x)\n", event, | 140 | FC_DEBUG_DISC("Received a %d event for port (%6x)\n", event, |
137 | rport->port_id); | 141 | rport->port_id); |
138 | 142 | ||
139 | if (event == RPORT_EV_CREATED) { | 143 | switch (event) { |
144 | case RPORT_EV_CREATED: | ||
140 | if (disc) { | 145 | if (disc) { |
141 | found = 1; | ||
142 | mutex_lock(&disc->disc_mutex); | 146 | mutex_lock(&disc->disc_mutex); |
143 | list_add_tail(&rdata->peers, &disc->rports); | 147 | list_add_tail(&rdata->peers, &disc->rports); |
144 | mutex_unlock(&disc->disc_mutex); | 148 | mutex_unlock(&disc->disc_mutex); |
145 | } | 149 | } |
150 | break; | ||
151 | case RPORT_EV_LOGO: | ||
152 | case RPORT_EV_FAILED: | ||
153 | case RPORT_EV_STOP: | ||
154 | mutex_lock(&disc->disc_mutex); | ||
155 | mutex_lock(&rdata->rp_mutex); | ||
156 | if (rdata->trans_state == FC_PORTSTATE_ROGUE) | ||
157 | list_del(&rdata->peers); | ||
158 | mutex_unlock(&rdata->rp_mutex); | ||
159 | mutex_unlock(&disc->disc_mutex); | ||
160 | break; | ||
161 | default: | ||
162 | break; | ||
146 | } | 163 | } |
147 | 164 | ||
148 | if (!found) | ||
149 | FC_DEBUG_DISC("The rport (%6x) is not maintained " | ||
150 | "by the discovery layer\n", rport->port_id); | ||
151 | } | 165 | } |
152 | 166 | ||
153 | /** | 167 | /** |
@@ -439,6 +453,7 @@ static int fc_disc_new_target(struct fc_disc *disc, | |||
439 | rdata = rport->dd_data; | 453 | rdata = rport->dd_data; |
440 | rdata->ops = &fc_disc_rport_ops; | 454 | rdata->ops = &fc_disc_rport_ops; |
441 | rdata->rp_state = RPORT_ST_INIT; | 455 | rdata->rp_state = RPORT_ST_INIT; |
456 | list_add_tail(&rdata->peers, &disc->rogue_rports); | ||
442 | lport->tt.rport_login(rport); | 457 | lport->tt.rport_login(rport); |
443 | } | 458 | } |
444 | } | 459 | } |
@@ -461,21 +476,29 @@ static void fc_disc_del_target(struct fc_disc *disc, struct fc_rport *rport) | |||
461 | /** | 476 | /** |
462 | * fc_disc_done() - Discovery has been completed | 477 | * fc_disc_done() - Discovery has been completed |
463 | * @disc: FC discovery context | 478 | * @disc: FC discovery context |
479 | * Locking Note: This function expects that the disc mutex is locked before | ||
480 | * it is called. The discovery callback is then made with the lock released, | ||
481 | * and the lock is re-taken before returning from this function | ||
464 | */ | 482 | */ |
465 | static void fc_disc_done(struct fc_disc *disc) | 483 | static void fc_disc_done(struct fc_disc *disc) |
466 | { | 484 | { |
467 | struct fc_lport *lport = disc->lport; | 485 | struct fc_lport *lport = disc->lport; |
486 | enum fc_disc_event event; | ||
468 | 487 | ||
469 | FC_DEBUG_DISC("Discovery complete for port (%6x)\n", | 488 | FC_DEBUG_DISC("Discovery complete for port (%6x)\n", |
470 | fc_host_port_id(lport->host)); | 489 | fc_host_port_id(lport->host)); |
471 | 490 | ||
472 | disc->disc_callback(lport, disc->event); | 491 | event = disc->event; |
473 | disc->event = DISC_EV_NONE; | 492 | disc->event = DISC_EV_NONE; |
474 | 493 | ||
475 | if (disc->requested) | 494 | if (disc->requested) |
476 | fc_disc_gpn_ft_req(disc); | 495 | fc_disc_gpn_ft_req(disc); |
477 | else | 496 | else |
478 | disc->pending = 0; | 497 | disc->pending = 0; |
498 | |||
499 | mutex_unlock(&disc->disc_mutex); | ||
500 | disc->disc_callback(lport, event); | ||
501 | mutex_lock(&disc->disc_mutex); | ||
479 | } | 502 | } |
480 | 503 | ||
481 | /** | 504 | /** |
@@ -622,6 +645,8 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len) | |||
622 | rdata = rport->dd_data; | 645 | rdata = rport->dd_data; |
623 | rdata->ops = &fc_disc_rport_ops; | 646 | rdata->ops = &fc_disc_rport_ops; |
624 | rdata->local_port = lport; | 647 | rdata->local_port = lport; |
648 | list_add_tail(&rdata->peers, | ||
649 | &disc->rogue_rports); | ||
625 | lport->tt.rport_login(rport); | 650 | lport->tt.rport_login(rport); |
626 | } else | 651 | } else |
627 | FC_DBG("Failed to allocate memory for " | 652 | FC_DBG("Failed to allocate memory for " |
@@ -681,8 +706,8 @@ static void fc_disc_timeout(struct work_struct *work) | |||
681 | * @fp: response frame | 706 | * @fp: response frame |
682 | * @lp_arg: Fibre Channel host port instance | 707 | * @lp_arg: Fibre Channel host port instance |
683 | * | 708 | * |
684 | * Locking Note: This function expects that the disc_mutex is locked | 709 | * Locking Note: This function is called without disc mutex held, and |
685 | * before it is called. | 710 | * should do all its processing with the mutex held |
686 | */ | 711 | */ |
687 | static void fc_disc_gpn_ft_resp(struct fc_seq *sp, struct fc_frame *fp, | 712 | static void fc_disc_gpn_ft_resp(struct fc_seq *sp, struct fc_frame *fp, |
688 | void *disc_arg) | 713 | void *disc_arg) |
@@ -695,11 +720,13 @@ static void fc_disc_gpn_ft_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
695 | unsigned int len; | 720 | unsigned int len; |
696 | int error; | 721 | int error; |
697 | 722 | ||
723 | mutex_lock(&disc->disc_mutex); | ||
698 | FC_DEBUG_DISC("Received a GPN_FT response on port (%6x)\n", | 724 | FC_DEBUG_DISC("Received a GPN_FT response on port (%6x)\n", |
699 | fc_host_port_id(disc->lport->host)); | 725 | fc_host_port_id(disc->lport->host)); |
700 | 726 | ||
701 | if (IS_ERR(fp)) { | 727 | if (IS_ERR(fp)) { |
702 | fc_disc_error(disc, fp); | 728 | fc_disc_error(disc, fp); |
729 | mutex_unlock(&disc->disc_mutex); | ||
703 | return; | 730 | return; |
704 | } | 731 | } |
705 | 732 | ||
@@ -744,6 +771,8 @@ static void fc_disc_gpn_ft_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
744 | disc->seq_count++; | 771 | disc->seq_count++; |
745 | } | 772 | } |
746 | fc_frame_free(fp); | 773 | fc_frame_free(fp); |
774 | |||
775 | mutex_unlock(&disc->disc_mutex); | ||
747 | } | 776 | } |
748 | 777 | ||
749 | /** | 778 | /** |
@@ -757,7 +786,6 @@ static void fc_disc_gpn_ft_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
757 | static void fc_disc_single(struct fc_disc *disc, struct fc_disc_port *dp) | 786 | static void fc_disc_single(struct fc_disc *disc, struct fc_disc_port *dp) |
758 | { | 787 | { |
759 | struct fc_lport *lport; | 788 | struct fc_lport *lport; |
760 | struct fc_rport *rport; | ||
761 | struct fc_rport *new_rport; | 789 | struct fc_rport *new_rport; |
762 | struct fc_rport_libfc_priv *rdata; | 790 | struct fc_rport_libfc_priv *rdata; |
763 | 791 | ||
@@ -766,15 +794,12 @@ static void fc_disc_single(struct fc_disc *disc, struct fc_disc_port *dp) | |||
766 | if (dp->ids.port_id == fc_host_port_id(lport->host)) | 794 | if (dp->ids.port_id == fc_host_port_id(lport->host)) |
767 | goto out; | 795 | goto out; |
768 | 796 | ||
769 | rport = lport->tt.rport_lookup(lport, dp->ids.port_id); | ||
770 | if (rport) | ||
771 | fc_disc_del_target(disc, rport); | ||
772 | |||
773 | new_rport = lport->tt.rport_create(dp); | 797 | new_rport = lport->tt.rport_create(dp); |
774 | if (new_rport) { | 798 | if (new_rport) { |
775 | rdata = new_rport->dd_data; | 799 | rdata = new_rport->dd_data; |
776 | rdata->ops = &fc_disc_rport_ops; | 800 | rdata->ops = &fc_disc_rport_ops; |
777 | kfree(dp); | 801 | kfree(dp); |
802 | list_add_tail(&rdata->peers, &disc->rogue_rports); | ||
778 | lport->tt.rport_login(new_rport); | 803 | lport->tt.rport_login(new_rport); |
779 | } | 804 | } |
780 | return; | 805 | return; |
@@ -836,6 +861,7 @@ int fc_disc_init(struct fc_lport *lport) | |||
836 | INIT_DELAYED_WORK(&disc->disc_work, fc_disc_timeout); | 861 | INIT_DELAYED_WORK(&disc->disc_work, fc_disc_timeout); |
837 | mutex_init(&disc->disc_mutex); | 862 | mutex_init(&disc->disc_mutex); |
838 | INIT_LIST_HEAD(&disc->rports); | 863 | INIT_LIST_HEAD(&disc->rports); |
864 | INIT_LIST_HEAD(&disc->rogue_rports); | ||
839 | 865 | ||
840 | disc->lport = lport; | 866 | disc->lport = lport; |
841 | disc->delay = FC_DISC_DELAY; | 867 | disc->delay = FC_DISC_DELAY; |
diff --git a/drivers/scsi/libfc/fc_elsct.c b/drivers/scsi/libfc/fc_elsct.c index dd47fe619d1e..5878b34bff18 100644 --- a/drivers/scsi/libfc/fc_elsct.c +++ b/drivers/scsi/libfc/fc_elsct.c | |||
@@ -41,7 +41,7 @@ static struct fc_seq *fc_elsct_send(struct fc_lport *lport, | |||
41 | void *arg, u32 timer_msec) | 41 | void *arg, u32 timer_msec) |
42 | { | 42 | { |
43 | enum fc_rctl r_ctl; | 43 | enum fc_rctl r_ctl; |
44 | u32 did; | 44 | u32 did = FC_FID_NONE; |
45 | enum fc_fh_type fh_type; | 45 | enum fc_fh_type fh_type; |
46 | int rc; | 46 | int rc; |
47 | 47 | ||
diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c index f555ae99ad40..521f996f9b13 100644 --- a/drivers/scsi/libfc/fc_fcp.c +++ b/drivers/scsi/libfc/fc_fcp.c | |||
@@ -713,7 +713,7 @@ done: | |||
713 | static void fc_fcp_recv(struct fc_seq *seq, struct fc_frame *fp, void *arg) | 713 | static void fc_fcp_recv(struct fc_seq *seq, struct fc_frame *fp, void *arg) |
714 | { | 714 | { |
715 | struct fc_fcp_pkt *fsp = (struct fc_fcp_pkt *)arg; | 715 | struct fc_fcp_pkt *fsp = (struct fc_fcp_pkt *)arg; |
716 | struct fc_lport *lp; | 716 | struct fc_lport *lport = fsp->lp; |
717 | struct fc_frame_header *fh; | 717 | struct fc_frame_header *fh; |
718 | struct fcp_txrdy *dd; | 718 | struct fcp_txrdy *dd; |
719 | u8 r_ctl; | 719 | u8 r_ctl; |
@@ -724,9 +724,8 @@ static void fc_fcp_recv(struct fc_seq *seq, struct fc_frame *fp, void *arg) | |||
724 | 724 | ||
725 | fh = fc_frame_header_get(fp); | 725 | fh = fc_frame_header_get(fp); |
726 | r_ctl = fh->fh_r_ctl; | 726 | r_ctl = fh->fh_r_ctl; |
727 | lp = fsp->lp; | ||
728 | 727 | ||
729 | if (!(lp->state & LPORT_ST_READY)) | 728 | if (!(lport->state & LPORT_ST_READY)) |
730 | goto out; | 729 | goto out; |
731 | if (fc_fcp_lock_pkt(fsp)) | 730 | if (fc_fcp_lock_pkt(fsp)) |
732 | goto out; | 731 | goto out; |
@@ -779,7 +778,7 @@ errout: | |||
779 | if (IS_ERR(fp)) | 778 | if (IS_ERR(fp)) |
780 | fc_fcp_error(fsp, fp); | 779 | fc_fcp_error(fsp, fp); |
781 | else if (rc == -ENOMEM) | 780 | else if (rc == -ENOMEM) |
782 | fc_fcp_reduce_can_queue(lp); | 781 | fc_fcp_reduce_can_queue(lport); |
783 | } | 782 | } |
784 | 783 | ||
785 | static void fc_fcp_resp(struct fc_fcp_pkt *fsp, struct fc_frame *fp) | 784 | static void fc_fcp_resp(struct fc_fcp_pkt *fsp, struct fc_frame *fp) |
diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c index b8178ef398d7..e0c247724d2b 100644 --- a/drivers/scsi/libfc/fc_lport.c +++ b/drivers/scsi/libfc/fc_lport.c | |||
@@ -618,6 +618,11 @@ int fc_fabric_logoff(struct fc_lport *lport) | |||
618 | { | 618 | { |
619 | lport->tt.disc_stop_final(lport); | 619 | lport->tt.disc_stop_final(lport); |
620 | mutex_lock(&lport->lp_mutex); | 620 | mutex_lock(&lport->lp_mutex); |
621 | if (lport->dns_rp) | ||
622 | lport->tt.rport_logoff(lport->dns_rp); | ||
623 | mutex_unlock(&lport->lp_mutex); | ||
624 | lport->tt.rport_flush_queue(); | ||
625 | mutex_lock(&lport->lp_mutex); | ||
621 | fc_lport_enter_logo(lport); | 626 | fc_lport_enter_logo(lport); |
622 | mutex_unlock(&lport->lp_mutex); | 627 | mutex_unlock(&lport->lp_mutex); |
623 | cancel_delayed_work_sync(&lport->retry_work); | 628 | cancel_delayed_work_sync(&lport->retry_work); |
@@ -639,7 +644,12 @@ EXPORT_SYMBOL(fc_fabric_logoff); | |||
639 | */ | 644 | */ |
640 | int fc_lport_destroy(struct fc_lport *lport) | 645 | int fc_lport_destroy(struct fc_lport *lport) |
641 | { | 646 | { |
647 | mutex_lock(&lport->lp_mutex); | ||
648 | lport->state = LPORT_ST_NONE; | ||
649 | lport->link_up = 0; | ||
642 | lport->tt.frame_send = fc_frame_drop; | 650 | lport->tt.frame_send = fc_frame_drop; |
651 | mutex_unlock(&lport->lp_mutex); | ||
652 | |||
643 | lport->tt.fcp_abort_io(lport); | 653 | lport->tt.fcp_abort_io(lport); |
644 | lport->tt.exch_mgr_reset(lport, 0, 0); | 654 | lport->tt.exch_mgr_reset(lport, 0, 0); |
645 | return 0; | 655 | return 0; |
@@ -1032,17 +1042,19 @@ static void fc_lport_rft_id_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
1032 | 1042 | ||
1033 | FC_DEBUG_LPORT("Received a RFT_ID response\n"); | 1043 | FC_DEBUG_LPORT("Received a RFT_ID response\n"); |
1034 | 1044 | ||
1035 | if (IS_ERR(fp)) { | ||
1036 | fc_lport_error(lport, fp); | ||
1037 | goto err; | ||
1038 | } | ||
1039 | |||
1040 | if (lport->state != LPORT_ST_RFT_ID) { | 1045 | if (lport->state != LPORT_ST_RFT_ID) { |
1041 | FC_DBG("Received a RFT_ID response, but in state %s\n", | 1046 | FC_DBG("Received a RFT_ID response, but in state %s\n", |
1042 | fc_lport_state(lport)); | 1047 | fc_lport_state(lport)); |
1048 | if (IS_ERR(fp)) | ||
1049 | goto err; | ||
1043 | goto out; | 1050 | goto out; |
1044 | } | 1051 | } |
1045 | 1052 | ||
1053 | if (IS_ERR(fp)) { | ||
1054 | fc_lport_error(lport, fp); | ||
1055 | goto err; | ||
1056 | } | ||
1057 | |||
1046 | fh = fc_frame_header_get(fp); | 1058 | fh = fc_frame_header_get(fp); |
1047 | ct = fc_frame_payload_get(fp, sizeof(*ct)); | 1059 | ct = fc_frame_payload_get(fp, sizeof(*ct)); |
1048 | 1060 | ||
@@ -1084,17 +1096,19 @@ static void fc_lport_rpn_id_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
1084 | 1096 | ||
1085 | FC_DEBUG_LPORT("Received a RPN_ID response\n"); | 1097 | FC_DEBUG_LPORT("Received a RPN_ID response\n"); |
1086 | 1098 | ||
1087 | if (IS_ERR(fp)) { | ||
1088 | fc_lport_error(lport, fp); | ||
1089 | goto err; | ||
1090 | } | ||
1091 | |||
1092 | if (lport->state != LPORT_ST_RPN_ID) { | 1099 | if (lport->state != LPORT_ST_RPN_ID) { |
1093 | FC_DBG("Received a RPN_ID response, but in state %s\n", | 1100 | FC_DBG("Received a RPN_ID response, but in state %s\n", |
1094 | fc_lport_state(lport)); | 1101 | fc_lport_state(lport)); |
1102 | if (IS_ERR(fp)) | ||
1103 | goto err; | ||
1095 | goto out; | 1104 | goto out; |
1096 | } | 1105 | } |
1097 | 1106 | ||
1107 | if (IS_ERR(fp)) { | ||
1108 | fc_lport_error(lport, fp); | ||
1109 | goto err; | ||
1110 | } | ||
1111 | |||
1098 | fh = fc_frame_header_get(fp); | 1112 | fh = fc_frame_header_get(fp); |
1099 | ct = fc_frame_payload_get(fp, sizeof(*ct)); | 1113 | ct = fc_frame_payload_get(fp, sizeof(*ct)); |
1100 | if (fh && ct && fh->fh_type == FC_TYPE_CT && | 1114 | if (fh && ct && fh->fh_type == FC_TYPE_CT && |
@@ -1134,17 +1148,19 @@ static void fc_lport_scr_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
1134 | 1148 | ||
1135 | FC_DEBUG_LPORT("Received a SCR response\n"); | 1149 | FC_DEBUG_LPORT("Received a SCR response\n"); |
1136 | 1150 | ||
1137 | if (IS_ERR(fp)) { | ||
1138 | fc_lport_error(lport, fp); | ||
1139 | goto err; | ||
1140 | } | ||
1141 | |||
1142 | if (lport->state != LPORT_ST_SCR) { | 1151 | if (lport->state != LPORT_ST_SCR) { |
1143 | FC_DBG("Received a SCR response, but in state %s\n", | 1152 | FC_DBG("Received a SCR response, but in state %s\n", |
1144 | fc_lport_state(lport)); | 1153 | fc_lport_state(lport)); |
1154 | if (IS_ERR(fp)) | ||
1155 | goto err; | ||
1145 | goto out; | 1156 | goto out; |
1146 | } | 1157 | } |
1147 | 1158 | ||
1159 | if (IS_ERR(fp)) { | ||
1160 | fc_lport_error(lport, fp); | ||
1161 | goto err; | ||
1162 | } | ||
1163 | |||
1148 | op = fc_frame_payload_op(fp); | 1164 | op = fc_frame_payload_op(fp); |
1149 | if (op == ELS_LS_ACC) | 1165 | if (op == ELS_LS_ACC) |
1150 | fc_lport_enter_ready(lport); | 1166 | fc_lport_enter_ready(lport); |
@@ -1360,17 +1376,19 @@ static void fc_lport_logo_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
1360 | 1376 | ||
1361 | FC_DEBUG_LPORT("Received a LOGO response\n"); | 1377 | FC_DEBUG_LPORT("Received a LOGO response\n"); |
1362 | 1378 | ||
1363 | if (IS_ERR(fp)) { | ||
1364 | fc_lport_error(lport, fp); | ||
1365 | goto err; | ||
1366 | } | ||
1367 | |||
1368 | if (lport->state != LPORT_ST_LOGO) { | 1379 | if (lport->state != LPORT_ST_LOGO) { |
1369 | FC_DBG("Received a LOGO response, but in state %s\n", | 1380 | FC_DBG("Received a LOGO response, but in state %s\n", |
1370 | fc_lport_state(lport)); | 1381 | fc_lport_state(lport)); |
1382 | if (IS_ERR(fp)) | ||
1383 | goto err; | ||
1371 | goto out; | 1384 | goto out; |
1372 | } | 1385 | } |
1373 | 1386 | ||
1387 | if (IS_ERR(fp)) { | ||
1388 | fc_lport_error(lport, fp); | ||
1389 | goto err; | ||
1390 | } | ||
1391 | |||
1374 | op = fc_frame_payload_op(fp); | 1392 | op = fc_frame_payload_op(fp); |
1375 | if (op == ELS_LS_ACC) | 1393 | if (op == ELS_LS_ACC) |
1376 | fc_lport_enter_reset(lport); | 1394 | fc_lport_enter_reset(lport); |
@@ -1400,10 +1418,6 @@ static void fc_lport_enter_logo(struct fc_lport *lport) | |||
1400 | 1418 | ||
1401 | fc_lport_state_enter(lport, LPORT_ST_LOGO); | 1419 | fc_lport_state_enter(lport, LPORT_ST_LOGO); |
1402 | 1420 | ||
1403 | /* DNS session should be closed so we can release it here */ | ||
1404 | if (lport->dns_rp) | ||
1405 | lport->tt.rport_logoff(lport->dns_rp); | ||
1406 | |||
1407 | fp = fc_frame_alloc(lport, sizeof(*logo)); | 1421 | fp = fc_frame_alloc(lport, sizeof(*logo)); |
1408 | if (!fp) { | 1422 | if (!fp) { |
1409 | fc_lport_error(lport, fp); | 1423 | fc_lport_error(lport, fp); |
@@ -1444,17 +1458,19 @@ static void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
1444 | 1458 | ||
1445 | FC_DEBUG_LPORT("Received a FLOGI response\n"); | 1459 | FC_DEBUG_LPORT("Received a FLOGI response\n"); |
1446 | 1460 | ||
1447 | if (IS_ERR(fp)) { | ||
1448 | fc_lport_error(lport, fp); | ||
1449 | goto err; | ||
1450 | } | ||
1451 | |||
1452 | if (lport->state != LPORT_ST_FLOGI) { | 1461 | if (lport->state != LPORT_ST_FLOGI) { |
1453 | FC_DBG("Received a FLOGI response, but in state %s\n", | 1462 | FC_DBG("Received a FLOGI response, but in state %s\n", |
1454 | fc_lport_state(lport)); | 1463 | fc_lport_state(lport)); |
1464 | if (IS_ERR(fp)) | ||
1465 | goto err; | ||
1455 | goto out; | 1466 | goto out; |
1456 | } | 1467 | } |
1457 | 1468 | ||
1469 | if (IS_ERR(fp)) { | ||
1470 | fc_lport_error(lport, fp); | ||
1471 | goto err; | ||
1472 | } | ||
1473 | |||
1458 | fh = fc_frame_header_get(fp); | 1474 | fh = fc_frame_header_get(fp); |
1459 | did = ntoh24(fh->fh_d_id); | 1475 | did = ntoh24(fh->fh_d_id); |
1460 | if (fc_frame_payload_op(fp) == ELS_LS_ACC && did != 0) { | 1476 | if (fc_frame_payload_op(fp) == ELS_LS_ACC && did != 0) { |
diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c index 0472bb73221e..747d73c5c8af 100644 --- a/drivers/scsi/libfc/fc_rport.c +++ b/drivers/scsi/libfc/fc_rport.c | |||
@@ -267,6 +267,10 @@ static void fc_rport_work(struct work_struct *work) | |||
267 | "(%6x).\n", ids.port_id); | 267 | "(%6x).\n", ids.port_id); |
268 | event = RPORT_EV_FAILED; | 268 | event = RPORT_EV_FAILED; |
269 | } | 269 | } |
270 | if (rport->port_id != FC_FID_DIR_SERV) | ||
271 | if (rport_ops->event_callback) | ||
272 | rport_ops->event_callback(lport, rport, | ||
273 | RPORT_EV_FAILED); | ||
270 | put_device(&rport->dev); | 274 | put_device(&rport->dev); |
271 | rport = new_rport; | 275 | rport = new_rport; |
272 | rdata = new_rport->dd_data; | 276 | rdata = new_rport->dd_data; |
@@ -325,11 +329,20 @@ int fc_rport_login(struct fc_rport *rport) | |||
325 | int fc_rport_logoff(struct fc_rport *rport) | 329 | int fc_rport_logoff(struct fc_rport *rport) |
326 | { | 330 | { |
327 | struct fc_rport_libfc_priv *rdata = rport->dd_data; | 331 | struct fc_rport_libfc_priv *rdata = rport->dd_data; |
332 | struct fc_lport *lport = rdata->local_port; | ||
328 | 333 | ||
329 | mutex_lock(&rdata->rp_mutex); | 334 | mutex_lock(&rdata->rp_mutex); |
330 | 335 | ||
331 | FC_DEBUG_RPORT("Remove port (%6x)\n", rport->port_id); | 336 | FC_DEBUG_RPORT("Remove port (%6x)\n", rport->port_id); |
332 | 337 | ||
338 | if (rdata->rp_state == RPORT_ST_NONE) { | ||
339 | FC_DEBUG_RPORT("(%6x): Port (%6x) in NONE state," | ||
340 | " not removing", fc_host_port_id(lport->host), | ||
341 | rport->port_id); | ||
342 | mutex_unlock(&rdata->rp_mutex); | ||
343 | goto out; | ||
344 | } | ||
345 | |||
333 | fc_rport_enter_logo(rport); | 346 | fc_rport_enter_logo(rport); |
334 | 347 | ||
335 | /* | 348 | /* |
@@ -349,6 +362,7 @@ int fc_rport_logoff(struct fc_rport *rport) | |||
349 | 362 | ||
350 | mutex_unlock(&rdata->rp_mutex); | 363 | mutex_unlock(&rdata->rp_mutex); |
351 | 364 | ||
365 | out: | ||
352 | return 0; | 366 | return 0; |
353 | } | 367 | } |
354 | 368 | ||
@@ -430,6 +444,7 @@ static void fc_rport_error(struct fc_rport *rport, struct fc_frame *fp) | |||
430 | case RPORT_ST_PRLI: | 444 | case RPORT_ST_PRLI: |
431 | case RPORT_ST_LOGO: | 445 | case RPORT_ST_LOGO: |
432 | rdata->event = RPORT_EV_FAILED; | 446 | rdata->event = RPORT_EV_FAILED; |
447 | fc_rport_state_enter(rport, RPORT_ST_NONE); | ||
433 | queue_work(rport_event_queue, | 448 | queue_work(rport_event_queue, |
434 | &rdata->event_work); | 449 | &rdata->event_work); |
435 | break; | 450 | break; |
@@ -494,7 +509,7 @@ static void fc_rport_plogi_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
494 | struct fc_rport *rport = rp_arg; | 509 | struct fc_rport *rport = rp_arg; |
495 | struct fc_rport_libfc_priv *rdata = rport->dd_data; | 510 | struct fc_rport_libfc_priv *rdata = rport->dd_data; |
496 | struct fc_lport *lport = rdata->local_port; | 511 | struct fc_lport *lport = rdata->local_port; |
497 | struct fc_els_flogi *plp; | 512 | struct fc_els_flogi *plp = NULL; |
498 | unsigned int tov; | 513 | unsigned int tov; |
499 | u16 csp_seq; | 514 | u16 csp_seq; |
500 | u16 cssp_seq; | 515 | u16 cssp_seq; |
@@ -505,17 +520,19 @@ static void fc_rport_plogi_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
505 | FC_DEBUG_RPORT("Received a PLOGI response from port (%6x)\n", | 520 | FC_DEBUG_RPORT("Received a PLOGI response from port (%6x)\n", |
506 | rport->port_id); | 521 | rport->port_id); |
507 | 522 | ||
508 | if (IS_ERR(fp)) { | ||
509 | fc_rport_error_retry(rport, fp); | ||
510 | goto err; | ||
511 | } | ||
512 | |||
513 | if (rdata->rp_state != RPORT_ST_PLOGI) { | 523 | if (rdata->rp_state != RPORT_ST_PLOGI) { |
514 | FC_DBG("Received a PLOGI response, but in state %s\n", | 524 | FC_DBG("Received a PLOGI response, but in state %s\n", |
515 | fc_rport_state(rport)); | 525 | fc_rport_state(rport)); |
526 | if (IS_ERR(fp)) | ||
527 | goto err; | ||
516 | goto out; | 528 | goto out; |
517 | } | 529 | } |
518 | 530 | ||
531 | if (IS_ERR(fp)) { | ||
532 | fc_rport_error_retry(rport, fp); | ||
533 | goto err; | ||
534 | } | ||
535 | |||
519 | op = fc_frame_payload_op(fp); | 536 | op = fc_frame_payload_op(fp); |
520 | if (op == ELS_LS_ACC && | 537 | if (op == ELS_LS_ACC && |
521 | (plp = fc_frame_payload_get(fp, sizeof(*plp))) != NULL) { | 538 | (plp = fc_frame_payload_get(fp, sizeof(*plp))) != NULL) { |
@@ -614,17 +631,19 @@ static void fc_rport_prli_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
614 | FC_DEBUG_RPORT("Received a PRLI response from port (%6x)\n", | 631 | FC_DEBUG_RPORT("Received a PRLI response from port (%6x)\n", |
615 | rport->port_id); | 632 | rport->port_id); |
616 | 633 | ||
617 | if (IS_ERR(fp)) { | ||
618 | fc_rport_error_retry(rport, fp); | ||
619 | goto err; | ||
620 | } | ||
621 | |||
622 | if (rdata->rp_state != RPORT_ST_PRLI) { | 634 | if (rdata->rp_state != RPORT_ST_PRLI) { |
623 | FC_DBG("Received a PRLI response, but in state %s\n", | 635 | FC_DBG("Received a PRLI response, but in state %s\n", |
624 | fc_rport_state(rport)); | 636 | fc_rport_state(rport)); |
637 | if (IS_ERR(fp)) | ||
638 | goto err; | ||
625 | goto out; | 639 | goto out; |
626 | } | 640 | } |
627 | 641 | ||
642 | if (IS_ERR(fp)) { | ||
643 | fc_rport_error_retry(rport, fp); | ||
644 | goto err; | ||
645 | } | ||
646 | |||
628 | op = fc_frame_payload_op(fp); | 647 | op = fc_frame_payload_op(fp); |
629 | if (op == ELS_LS_ACC) { | 648 | if (op == ELS_LS_ACC) { |
630 | pp = fc_frame_payload_get(fp, sizeof(*pp)); | 649 | pp = fc_frame_payload_get(fp, sizeof(*pp)); |
@@ -646,6 +665,7 @@ static void fc_rport_prli_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
646 | } else { | 665 | } else { |
647 | FC_DBG("Bad ELS response\n"); | 666 | FC_DBG("Bad ELS response\n"); |
648 | rdata->event = RPORT_EV_FAILED; | 667 | rdata->event = RPORT_EV_FAILED; |
668 | fc_rport_state_enter(rport, RPORT_ST_NONE); | ||
649 | queue_work(rport_event_queue, &rdata->event_work); | 669 | queue_work(rport_event_queue, &rdata->event_work); |
650 | } | 670 | } |
651 | 671 | ||
@@ -678,23 +698,26 @@ static void fc_rport_logo_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
678 | FC_DEBUG_RPORT("Received a LOGO response from port (%6x)\n", | 698 | FC_DEBUG_RPORT("Received a LOGO response from port (%6x)\n", |
679 | rport->port_id); | 699 | rport->port_id); |
680 | 700 | ||
681 | if (IS_ERR(fp)) { | ||
682 | fc_rport_error_retry(rport, fp); | ||
683 | goto err; | ||
684 | } | ||
685 | |||
686 | if (rdata->rp_state != RPORT_ST_LOGO) { | 701 | if (rdata->rp_state != RPORT_ST_LOGO) { |
687 | FC_DEBUG_RPORT("Received a LOGO response, but in state %s\n", | 702 | FC_DEBUG_RPORT("Received a LOGO response, but in state %s\n", |
688 | fc_rport_state(rport)); | 703 | fc_rport_state(rport)); |
704 | if (IS_ERR(fp)) | ||
705 | goto err; | ||
689 | goto out; | 706 | goto out; |
690 | } | 707 | } |
691 | 708 | ||
709 | if (IS_ERR(fp)) { | ||
710 | fc_rport_error_retry(rport, fp); | ||
711 | goto err; | ||
712 | } | ||
713 | |||
692 | op = fc_frame_payload_op(fp); | 714 | op = fc_frame_payload_op(fp); |
693 | if (op == ELS_LS_ACC) { | 715 | if (op == ELS_LS_ACC) { |
694 | fc_rport_enter_rtv(rport); | 716 | fc_rport_enter_rtv(rport); |
695 | } else { | 717 | } else { |
696 | FC_DBG("Bad ELS response\n"); | 718 | FC_DBG("Bad ELS response\n"); |
697 | rdata->event = RPORT_EV_LOGO; | 719 | rdata->event = RPORT_EV_LOGO; |
720 | fc_rport_state_enter(rport, RPORT_ST_NONE); | ||
698 | queue_work(rport_event_queue, &rdata->event_work); | 721 | queue_work(rport_event_queue, &rdata->event_work); |
699 | } | 722 | } |
700 | 723 | ||
@@ -764,17 +787,19 @@ static void fc_rport_rtv_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
764 | FC_DEBUG_RPORT("Received a RTV response from port (%6x)\n", | 787 | FC_DEBUG_RPORT("Received a RTV response from port (%6x)\n", |
765 | rport->port_id); | 788 | rport->port_id); |
766 | 789 | ||
767 | if (IS_ERR(fp)) { | ||
768 | fc_rport_error(rport, fp); | ||
769 | goto err; | ||
770 | } | ||
771 | |||
772 | if (rdata->rp_state != RPORT_ST_RTV) { | 790 | if (rdata->rp_state != RPORT_ST_RTV) { |
773 | FC_DBG("Received a RTV response, but in state %s\n", | 791 | FC_DBG("Received a RTV response, but in state %s\n", |
774 | fc_rport_state(rport)); | 792 | fc_rport_state(rport)); |
793 | if (IS_ERR(fp)) | ||
794 | goto err; | ||
775 | goto out; | 795 | goto out; |
776 | } | 796 | } |
777 | 797 | ||
798 | if (IS_ERR(fp)) { | ||
799 | fc_rport_error(rport, fp); | ||
800 | goto err; | ||
801 | } | ||
802 | |||
778 | op = fc_frame_payload_op(fp); | 803 | op = fc_frame_payload_op(fp); |
779 | if (op == ELS_LS_ACC) { | 804 | if (op == ELS_LS_ACC) { |
780 | struct fc_els_rtv_acc *rtv; | 805 | struct fc_els_rtv_acc *rtv; |
@@ -1007,6 +1032,8 @@ static void fc_rport_recv_plogi_req(struct fc_rport *rport, | |||
1007 | default: | 1032 | default: |
1008 | FC_DEBUG_RPORT("incoming PLOGI from %x in unexpected " | 1033 | FC_DEBUG_RPORT("incoming PLOGI from %x in unexpected " |
1009 | "state %d\n", sid, rdata->rp_state); | 1034 | "state %d\n", sid, rdata->rp_state); |
1035 | fc_frame_free(fp); | ||
1036 | return; | ||
1010 | break; | 1037 | break; |
1011 | } | 1038 | } |
1012 | 1039 | ||
@@ -1098,6 +1125,8 @@ static void fc_rport_recv_prli_req(struct fc_rport *rport, | |||
1098 | reason = ELS_RJT_NONE; | 1125 | reason = ELS_RJT_NONE; |
1099 | break; | 1126 | break; |
1100 | default: | 1127 | default: |
1128 | fc_frame_free(rx_fp); | ||
1129 | return; | ||
1101 | break; | 1130 | break; |
1102 | } | 1131 | } |
1103 | len = fr_len(rx_fp) - sizeof(*fh); | 1132 | len = fr_len(rx_fp) - sizeof(*fh); |
@@ -1227,6 +1256,11 @@ static void fc_rport_recv_prlo_req(struct fc_rport *rport, struct fc_seq *sp, | |||
1227 | "while in state %s\n", ntoh24(fh->fh_s_id), | 1256 | "while in state %s\n", ntoh24(fh->fh_s_id), |
1228 | fc_rport_state(rport)); | 1257 | fc_rport_state(rport)); |
1229 | 1258 | ||
1259 | if (rdata->rp_state == RPORT_ST_NONE) { | ||
1260 | fc_frame_free(fp); | ||
1261 | return; | ||
1262 | } | ||
1263 | |||
1230 | rjt_data.fp = NULL; | 1264 | rjt_data.fp = NULL; |
1231 | rjt_data.reason = ELS_RJT_UNAB; | 1265 | rjt_data.reason = ELS_RJT_UNAB; |
1232 | rjt_data.explan = ELS_EXPL_NONE; | 1266 | rjt_data.explan = ELS_EXPL_NONE; |
@@ -1256,7 +1290,13 @@ static void fc_rport_recv_logo_req(struct fc_rport *rport, struct fc_seq *sp, | |||
1256 | "while in state %s\n", ntoh24(fh->fh_s_id), | 1290 | "while in state %s\n", ntoh24(fh->fh_s_id), |
1257 | fc_rport_state(rport)); | 1291 | fc_rport_state(rport)); |
1258 | 1292 | ||
1293 | if (rdata->rp_state == RPORT_ST_NONE) { | ||
1294 | fc_frame_free(fp); | ||
1295 | return; | ||
1296 | } | ||
1297 | |||
1259 | rdata->event = RPORT_EV_LOGO; | 1298 | rdata->event = RPORT_EV_LOGO; |
1299 | fc_rport_state_enter(rport, RPORT_ST_NONE); | ||
1260 | queue_work(rport_event_queue, &rdata->event_work); | 1300 | queue_work(rport_event_queue, &rdata->event_work); |
1261 | 1301 | ||
1262 | lport->tt.seq_els_rsp_send(sp, ELS_LS_ACC, NULL); | 1302 | lport->tt.seq_els_rsp_send(sp, ELS_LS_ACC, NULL); |