aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc/lpfc_scsi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_scsi.c')
-rw-r--r--drivers/scsi/lpfc/lpfc_scsi.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index 70255c11d3ad..0910a9ab76a5 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -169,6 +169,9 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
169 for(i = 0; i <= phba->max_vpi && vports[i] != NULL; i++) { 169 for(i = 0; i <= phba->max_vpi && vports[i] != NULL; i++) {
170 shost = lpfc_shost_from_vport(vports[i]); 170 shost = lpfc_shost_from_vport(vports[i]);
171 shost_for_each_device(sdev, shost) { 171 shost_for_each_device(sdev, shost) {
172 if (vports[i]->cfg_lun_queue_depth <=
173 sdev->queue_depth)
174 continue;
172 if (sdev->ordered_tags) 175 if (sdev->ordered_tags)
173 scsi_adjust_queue_depth(sdev, 176 scsi_adjust_queue_depth(sdev,
174 MSG_ORDERED_TAG, 177 MSG_ORDERED_TAG,
@@ -578,14 +581,14 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
578 lpfc_cmd->result == IOERR_NO_RESOURCES || 581 lpfc_cmd->result == IOERR_NO_RESOURCES ||
579 lpfc_cmd->result == RJT_LOGIN_REQUIRED) { 582 lpfc_cmd->result == RJT_LOGIN_REQUIRED) {
580 cmd->result = ScsiResult(DID_REQUEUE, 0); 583 cmd->result = ScsiResult(DID_REQUEUE, 0);
581 break; 584 break;
582 } /* else: fall through */ 585 } /* else: fall through */
583 default: 586 default:
584 cmd->result = ScsiResult(DID_ERROR, 0); 587 cmd->result = ScsiResult(DID_ERROR, 0);
585 break; 588 break;
586 } 589 }
587 590
588 if ((pnode == NULL ) 591 if (!pnode || !NLP_CHK_NODE_ACT(pnode)
589 || (pnode->nlp_state != NLP_STE_MAPPED_NODE)) 592 || (pnode->nlp_state != NLP_STE_MAPPED_NODE))
590 cmd->result = ScsiResult(DID_BUS_BUSY, SAM_STAT_BUSY); 593 cmd->result = ScsiResult(DID_BUS_BUSY, SAM_STAT_BUSY);
591 } else { 594 } else {
@@ -606,6 +609,9 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
606 result = cmd->result; 609 result = cmd->result;
607 sdev = cmd->device; 610 sdev = cmd->device;
608 lpfc_scsi_unprep_dma_buf(phba, lpfc_cmd); 611 lpfc_scsi_unprep_dma_buf(phba, lpfc_cmd);
612 spin_lock_irqsave(sdev->host->host_lock, flags);
613 lpfc_cmd->pCmd = NULL; /* This must be done before scsi_done */
614 spin_unlock_irqrestore(sdev->host->host_lock, flags);
609 cmd->scsi_done(cmd); 615 cmd->scsi_done(cmd);
610 616
611 if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) { 617 if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) {
@@ -614,7 +620,6 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
614 * wake up the thread. 620 * wake up the thread.
615 */ 621 */
616 spin_lock_irqsave(sdev->host->host_lock, flags); 622 spin_lock_irqsave(sdev->host->host_lock, flags);
617 lpfc_cmd->pCmd = NULL;
618 if (lpfc_cmd->waitq) 623 if (lpfc_cmd->waitq)
619 wake_up(lpfc_cmd->waitq); 624 wake_up(lpfc_cmd->waitq);
620 spin_unlock_irqrestore(sdev->host->host_lock, flags); 625 spin_unlock_irqrestore(sdev->host->host_lock, flags);
@@ -626,7 +631,7 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
626 if (!result) 631 if (!result)
627 lpfc_rampup_queue_depth(vport, sdev); 632 lpfc_rampup_queue_depth(vport, sdev);
628 633
629 if (!result && pnode != NULL && 634 if (!result && pnode && NLP_CHK_NODE_ACT(pnode) &&
630 ((jiffies - pnode->last_ramp_up_time) > 635 ((jiffies - pnode->last_ramp_up_time) >
631 LPFC_Q_RAMP_UP_INTERVAL * HZ) && 636 LPFC_Q_RAMP_UP_INTERVAL * HZ) &&
632 ((jiffies - pnode->last_q_full_time) > 637 ((jiffies - pnode->last_q_full_time) >
@@ -654,7 +659,8 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
654 * Check for queue full. If the lun is reporting queue full, then 659 * Check for queue full. If the lun is reporting queue full, then
655 * back off the lun queue depth to prevent target overloads. 660 * back off the lun queue depth to prevent target overloads.
656 */ 661 */
657 if (result == SAM_STAT_TASK_SET_FULL && pnode != NULL) { 662 if (result == SAM_STAT_TASK_SET_FULL && pnode &&
663 NLP_CHK_NODE_ACT(pnode)) {
658 pnode->last_q_full_time = jiffies; 664 pnode->last_q_full_time = jiffies;
659 665
660 shost_for_each_device(tmp_sdev, sdev->host) { 666 shost_for_each_device(tmp_sdev, sdev->host) {
@@ -684,7 +690,6 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
684 * wake up the thread. 690 * wake up the thread.
685 */ 691 */
686 spin_lock_irqsave(sdev->host->host_lock, flags); 692 spin_lock_irqsave(sdev->host->host_lock, flags);
687 lpfc_cmd->pCmd = NULL;
688 if (lpfc_cmd->waitq) 693 if (lpfc_cmd->waitq)
689 wake_up(lpfc_cmd->waitq); 694 wake_up(lpfc_cmd->waitq);
690 spin_unlock_irqrestore(sdev->host->host_lock, flags); 695 spin_unlock_irqrestore(sdev->host->host_lock, flags);
@@ -704,6 +709,9 @@ lpfc_scsi_prep_cmnd(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd,
704 int datadir = scsi_cmnd->sc_data_direction; 709 int datadir = scsi_cmnd->sc_data_direction;
705 char tag[2]; 710 char tag[2];
706 711
712 if (!pnode || !NLP_CHK_NODE_ACT(pnode))
713 return;
714
707 lpfc_cmd->fcp_rsp->rspSnsLen = 0; 715 lpfc_cmd->fcp_rsp->rspSnsLen = 0;
708 /* clear task management bits */ 716 /* clear task management bits */
709 lpfc_cmd->fcp_cmnd->fcpCntl2 = 0; 717 lpfc_cmd->fcp_cmnd->fcpCntl2 = 0;
@@ -785,9 +793,9 @@ lpfc_scsi_prep_task_mgmt_cmd(struct lpfc_vport *vport,
785 struct lpfc_rport_data *rdata = lpfc_cmd->rdata; 793 struct lpfc_rport_data *rdata = lpfc_cmd->rdata;
786 struct lpfc_nodelist *ndlp = rdata->pnode; 794 struct lpfc_nodelist *ndlp = rdata->pnode;
787 795
788 if ((ndlp == NULL) || (ndlp->nlp_state != NLP_STE_MAPPED_NODE)) { 796 if (!ndlp || !NLP_CHK_NODE_ACT(ndlp) ||
797 ndlp->nlp_state != NLP_STE_MAPPED_NODE)
789 return 0; 798 return 0;
790 }
791 799
792 piocbq = &(lpfc_cmd->cur_iocbq); 800 piocbq = &(lpfc_cmd->cur_iocbq);
793 piocbq->vport = vport; 801 piocbq->vport = vport;
@@ -842,7 +850,7 @@ lpfc_scsi_tgt_reset(struct lpfc_scsi_buf *lpfc_cmd, struct lpfc_vport *vport,
842 struct lpfc_iocbq *iocbqrsp; 850 struct lpfc_iocbq *iocbqrsp;
843 int ret; 851 int ret;
844 852
845 if (!rdata->pnode) 853 if (!rdata->pnode || !NLP_CHK_NODE_ACT(rdata->pnode))
846 return FAILED; 854 return FAILED;
847 855
848 lpfc_cmd->rdata = rdata; 856 lpfc_cmd->rdata = rdata;
@@ -959,7 +967,7 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
959 * Catch race where our node has transitioned, but the 967 * Catch race where our node has transitioned, but the
960 * transport is still transitioning. 968 * transport is still transitioning.
961 */ 969 */
962 if (!ndlp) { 970 if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) {
963 cmnd->result = ScsiResult(DID_BUS_BUSY, 0); 971 cmnd->result = ScsiResult(DID_BUS_BUSY, 0);
964 goto out_fail_command; 972 goto out_fail_command;
965 } 973 }
@@ -1146,7 +1154,7 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd)
1146 * target is rediscovered or devloss timeout expires. 1154 * target is rediscovered or devloss timeout expires.
1147 */ 1155 */
1148 while (1) { 1156 while (1) {
1149 if (!pnode) 1157 if (!pnode || !NLP_CHK_NODE_ACT(pnode))
1150 goto out; 1158 goto out;
1151 1159
1152 if (pnode->nlp_state != NLP_STE_MAPPED_NODE) { 1160 if (pnode->nlp_state != NLP_STE_MAPPED_NODE) {
@@ -1162,7 +1170,7 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd)
1162 goto out; 1170 goto out;
1163 } 1171 }
1164 pnode = rdata->pnode; 1172 pnode = rdata->pnode;
1165 if (!pnode) 1173 if (!pnode || !NLP_CHK_NODE_ACT(pnode))
1166 goto out; 1174 goto out;
1167 } 1175 }
1168 if (pnode->nlp_state == NLP_STE_MAPPED_NODE) 1176 if (pnode->nlp_state == NLP_STE_MAPPED_NODE)