aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVasu Dev <vasu.dev@intel.com>2011-08-25 15:40:52 -0400
committerJames Bottomley <JBottomley@Parallels.com>2011-08-28 22:39:37 -0400
commit77a2b73a7805a3c6a473b6741aa514ef40295d26 (patch)
treec9cc39a2451733c77bad8ce627d336becb78b882
parent848e7d5b46b9b0ee613a106bc460acf6a09a8546 (diff)
[SCSI] libfc: fix fc_eh_host_reset
Current fc_eh_host_reset leaves lport offline permanently due to FLOGI response getting handled by LOGO response from last reset as both had same exchange id. So fix this by having end to end exches clean-up using exchange abort along exches reset done from fc_eh_host_reset. This would avoid exchanges collision between the sessions across the reset. In this case implicit login should have done that but no aborting support for FIP frames, so just wait till lport->r_a_tov before restarting next flogi to ensure all exchanges are good to use again for next session. Below is the trace of LOGO from older session coming ahead of FLOGI response with same exche id 0x203:- 617 86.435165 4e.00.0b -> ff.ff.fc FC ELS LOGO 0x203 618 86.435195 4e.00.0b -> b6.02.00 FC ELS LOGO 0x213 619 86.435220 4e.00.0b -> 18.03.00 FC ELS LOGO 0x223 620 86.435244 4e.00.0b -> 18.02.00 FC ELS LOGO 0x233 621 86.435267 4e.00.0b -> 18.01.00 FC ELS LOGO 0x243 622 86.435349 00.00.00 -> ff.ff.fe FC ELS FLOGI 0x203 623 86.435549 ff.ff.fc -> 4e.00.0b FC ELS ACC (LOGO) 0x203 624 86.438721 ff.ff.fe -> 4e.00.0b FC ELS ACC (FLOGI) 0x203 625 86.442059 18.03.00 -> 4e.00.0b FC ELS ACC (LOGO) 0x223 626 86.443683 b6.02.00 -> 4e.00.0b FC ELS ACC (LOGO) 0x213 627 86.447693 18.01.00 -> 4e.00.0b FC ELS ACC (LOGO) 0x243 628 86.453499 18.02.00 -> 4e.00.0b FC ELS ACC (LOGO) 0x233 Signed-off-by: Vasu Dev <vasu.dev@intel.com> Tested-by: Ross Brattain <ross.b.brattain@intel.com> Reviewed-by: Yi Zou <yi.zou@intel.com> Signed-off-by: Robert Love <robert.w.love@intel.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r--drivers/scsi/libfc/fc_exch.c51
-rw-r--r--drivers/scsi/libfc/fc_lport.c11
2 files changed, 45 insertions, 17 deletions
diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
index 01ff082dc34..744fefe8134 100644
--- a/drivers/scsi/libfc/fc_exch.c
+++ b/drivers/scsi/libfc/fc_exch.c
@@ -494,6 +494,9 @@ static int fc_seq_send(struct fc_lport *lport, struct fc_seq *sp,
494 */ 494 */
495 error = lport->tt.frame_send(lport, fp); 495 error = lport->tt.frame_send(lport, fp);
496 496
497 if (fh->fh_type == FC_TYPE_BLS)
498 return error;
499
497 /* 500 /*
498 * Update the exchange and sequence flags, 501 * Update the exchange and sequence flags,
499 * assuming all frames for the sequence have been sent. 502 * assuming all frames for the sequence have been sent.
@@ -575,42 +578,35 @@ static void fc_seq_set_resp(struct fc_seq *sp,
575} 578}
576 579
577/** 580/**
578 * fc_seq_exch_abort() - Abort an exchange and sequence 581 * fc_exch_abort_locked() - Abort an exchange
579 * @req_sp: The sequence to be aborted 582 * @ep: The exchange to be aborted
580 * @timer_msec: The period of time to wait before aborting 583 * @timer_msec: The period of time to wait before aborting
581 * 584 *
582 * Generally called because of a timeout or an abort from the upper layer. 585 * Locking notes: Called with exch lock held
586 *
587 * Return value: 0 on success else error code
583 */ 588 */
584static int fc_seq_exch_abort(const struct fc_seq *req_sp, 589static int fc_exch_abort_locked(struct fc_exch *ep,
585 unsigned int timer_msec) 590 unsigned int timer_msec)
586{ 591{
587 struct fc_seq *sp; 592 struct fc_seq *sp;
588 struct fc_exch *ep;
589 struct fc_frame *fp; 593 struct fc_frame *fp;
590 int error; 594 int error;
591 595
592 ep = fc_seq_exch(req_sp);
593
594 spin_lock_bh(&ep->ex_lock);
595 if (ep->esb_stat & (ESB_ST_COMPLETE | ESB_ST_ABNORMAL) || 596 if (ep->esb_stat & (ESB_ST_COMPLETE | ESB_ST_ABNORMAL) ||
596 ep->state & (FC_EX_DONE | FC_EX_RST_CLEANUP)) { 597 ep->state & (FC_EX_DONE | FC_EX_RST_CLEANUP))
597 spin_unlock_bh(&ep->ex_lock);
598 return -ENXIO; 598 return -ENXIO;
599 }
600 599
601 /* 600 /*
602 * Send the abort on a new sequence if possible. 601 * Send the abort on a new sequence if possible.
603 */ 602 */
604 sp = fc_seq_start_next_locked(&ep->seq); 603 sp = fc_seq_start_next_locked(&ep->seq);
605 if (!sp) { 604 if (!sp)
606 spin_unlock_bh(&ep->ex_lock);
607 return -ENOMEM; 605 return -ENOMEM;
608 }
609 606
610 ep->esb_stat |= ESB_ST_SEQ_INIT | ESB_ST_ABNORMAL; 607 ep->esb_stat |= ESB_ST_SEQ_INIT | ESB_ST_ABNORMAL;
611 if (timer_msec) 608 if (timer_msec)
612 fc_exch_timer_set_locked(ep, timer_msec); 609 fc_exch_timer_set_locked(ep, timer_msec);
613 spin_unlock_bh(&ep->ex_lock);
614 610
615 /* 611 /*
616 * If not logged into the fabric, don't send ABTS but leave 612 * If not logged into the fabric, don't send ABTS but leave
@@ -633,6 +629,28 @@ static int fc_seq_exch_abort(const struct fc_seq *req_sp,
633} 629}
634 630
635/** 631/**
632 * fc_seq_exch_abort() - Abort an exchange and sequence
633 * @req_sp: The sequence to be aborted
634 * @timer_msec: The period of time to wait before aborting
635 *
636 * Generally called because of a timeout or an abort from the upper layer.
637 *
638 * Return value: 0 on success else error code
639 */
640static int fc_seq_exch_abort(const struct fc_seq *req_sp,
641 unsigned int timer_msec)
642{
643 struct fc_exch *ep;
644 int error;
645
646 ep = fc_seq_exch(req_sp);
647 spin_lock_bh(&ep->ex_lock);
648 error = fc_exch_abort_locked(ep, timer_msec);
649 spin_unlock_bh(&ep->ex_lock);
650 return error;
651}
652
653/**
636 * fc_exch_timeout() - Handle exchange timer expiration 654 * fc_exch_timeout() - Handle exchange timer expiration
637 * @work: The work_struct identifying the exchange that timed out 655 * @work: The work_struct identifying the exchange that timed out
638 */ 656 */
@@ -1715,6 +1733,7 @@ static void fc_exch_reset(struct fc_exch *ep)
1715 int rc = 1; 1733 int rc = 1;
1716 1734
1717 spin_lock_bh(&ep->ex_lock); 1735 spin_lock_bh(&ep->ex_lock);
1736 fc_exch_abort_locked(ep, 0);
1718 ep->state |= FC_EX_RST_CLEANUP; 1737 ep->state |= FC_EX_RST_CLEANUP;
1719 if (cancel_delayed_work(&ep->timeout_work)) 1738 if (cancel_delayed_work(&ep->timeout_work))
1720 atomic_dec(&ep->ex_refcnt); /* drop hold for timer */ 1739 atomic_dec(&ep->ex_refcnt); /* drop hold for timer */
diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c
index e55ed9cf23f..628f347404f 100644
--- a/drivers/scsi/libfc/fc_lport.c
+++ b/drivers/scsi/libfc/fc_lport.c
@@ -88,6 +88,7 @@
88 */ 88 */
89 89
90#include <linux/timer.h> 90#include <linux/timer.h>
91#include <linux/delay.h>
91#include <linux/slab.h> 92#include <linux/slab.h>
92#include <asm/unaligned.h> 93#include <asm/unaligned.h>
93 94
@@ -1029,8 +1030,16 @@ static void fc_lport_enter_reset(struct fc_lport *lport)
1029 FCH_EVT_LIPRESET, 0); 1030 FCH_EVT_LIPRESET, 0);
1030 fc_vports_linkchange(lport); 1031 fc_vports_linkchange(lport);
1031 fc_lport_reset_locked(lport); 1032 fc_lport_reset_locked(lport);
1032 if (lport->link_up) 1033 if (lport->link_up) {
1034 /*
1035 * Wait upto resource allocation time out before
1036 * doing re-login since incomplete FIP exchanged
1037 * from last session may collide with exchanges
1038 * in new session.
1039 */
1040 msleep(lport->r_a_tov);
1033 fc_lport_enter_flogi(lport); 1041 fc_lport_enter_flogi(lport);
1042 }
1034} 1043}
1035 1044
1036/** 1045/**