OSDN Git Service

scsi: lpfc: Update fc_prli_sent outstanding only after guaranteed IOCB submit
authorJames Smart <jsmart2021@gmail.com>
Tue, 12 Apr 2022 22:19:52 +0000 (15:19 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 19 Apr 2022 02:48:45 +0000 (22:48 -0400)
If lpfc_sli_issue_iocb() fails, then the fc_prli_sent is never decremented.

Move the fc_prli_sent++ to after a guaranteed IOCB submit.

Link: https://lore.kernel.org/r/20220412222008.126521-11-jsmart2021@gmail.com
Co-developed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/lpfc/lpfc_els.c

index 44ef873..8155c63 100644 (file)
@@ -2571,16 +2571,6 @@ lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
 
        phba->fc_stat.elsXmitPRLI++;
        elsiocb->cmd_cmpl = lpfc_cmpl_els_prli;
-       spin_lock_irq(&ndlp->lock);
-       ndlp->nlp_flag |= NLP_PRLI_SND;
-
-       /* The vport counters are used for lpfc_scan_finished, but
-        * the ndlp is used to track outstanding PRLIs for different
-        * FC4 types.
-        */
-       vport->fc_prli_sent++;
-       ndlp->fc4_prli_sent++;
-       spin_unlock_irq(&ndlp->lock);
 
        lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
                              "Issue PRLI:  did:x%x refcnt %d",
@@ -2588,16 +2578,25 @@ lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
        elsiocb->context1 = lpfc_nlp_get(ndlp);
        if (!elsiocb->context1) {
                lpfc_els_free_iocb(phba, elsiocb);
-               goto err;
+               return 1;
        }
 
        rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0);
        if (rc == IOCB_ERROR) {
                lpfc_els_free_iocb(phba, elsiocb);
                lpfc_nlp_put(ndlp);
-               goto err;
+               return 1;
        }
 
+       /* The vport counters are used for lpfc_scan_finished, but
+        * the ndlp is used to track outstanding PRLIs for different
+        * FC4 types.
+        */
+       spin_lock_irq(&ndlp->lock);
+       ndlp->nlp_flag |= NLP_PRLI_SND;
+       vport->fc_prli_sent++;
+       ndlp->fc4_prli_sent++;
+       spin_unlock_irq(&ndlp->lock);
 
        /* The driver supports 2 FC4 types.  Make sure
         * a PRLI is issued for all types before exiting.
@@ -2607,12 +2606,6 @@ lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
                goto send_next_prli;
        else
                return 0;
-
-err:
-       spin_lock_irq(&ndlp->lock);
-       ndlp->nlp_flag &= ~NLP_PRLI_SND;
-       spin_unlock_irq(&ndlp->lock);
-       return 1;
 }
 
 /**