public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Justin Tee <justintee8345@gmail.com>
To: linux-scsi@vger.kernel.org
Cc: jsmart2021@gmail.com, justin.tee@broadcom.com,
	Justin Tee <justintee8345@gmail.com>
Subject: [PATCH 06/10] lpfc: Correct used_rpi count when devloss tmo fires with no recovery
Date: Wed,  1 Mar 2023 15:16:22 -0800	[thread overview]
Message-ID: <20230301231626.9621-7-justintee8345@gmail.com> (raw)
In-Reply-To: <20230301231626.9621-1-justintee8345@gmail.com>

A fabric controller can sometimes send an RDP request right before a link
down event.  Because of this outstanding RDP request, the driver does not
remove the last reference count on its ndlp causing a potential leak of
RPI resources when devloss tmo fires.

In lpfc_cmpl_els_rsp, modify the NPIV clause to always allow the
lpfc_drop_node routine to execute when not registered with SCSI transport.

This relaxes the contraint that an NPIV ndlp must be in a specific state
in order to call lpfc_drop node.  Logic is revised such that the
lpfc_drop_node routine is always called to ensure the last ndlp decrement
occurs.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
---
 drivers/scsi/lpfc/lpfc_els.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 0342e8cdcc9e..9f50f6116627 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -5457,18 +5457,20 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
 	 * these conditions and release the RPI.
 	 */
 	if (phba->sli_rev == LPFC_SLI_REV4 &&
-	    (vport && vport->port_type == LPFC_NPIV_PORT) &&
-	    !(ndlp->fc4_xpt_flags & SCSI_XPT_REGD) &&
-	    ndlp->nlp_flag & NLP_RELEASE_RPI) {
-		if (ndlp->nlp_state !=  NLP_STE_PLOGI_ISSUE &&
-		    ndlp->nlp_state != NLP_STE_REG_LOGIN_ISSUE) {
-			lpfc_sli4_free_rpi(phba, ndlp->nlp_rpi);
-			spin_lock_irq(&ndlp->lock);
-			ndlp->nlp_rpi = LPFC_RPI_ALLOC_ERROR;
-			ndlp->nlp_flag &= ~NLP_RELEASE_RPI;
-			spin_unlock_irq(&ndlp->lock);
-			lpfc_drop_node(vport, ndlp);
+	    vport && vport->port_type == LPFC_NPIV_PORT &&
+	    !(ndlp->fc4_xpt_flags & SCSI_XPT_REGD)) {
+		if (ndlp->nlp_flag & NLP_RELEASE_RPI) {
+			if (ndlp->nlp_state != NLP_STE_PLOGI_ISSUE &&
+			    ndlp->nlp_state != NLP_STE_REG_LOGIN_ISSUE) {
+				lpfc_sli4_free_rpi(phba, ndlp->nlp_rpi);
+				spin_lock_irq(&ndlp->lock);
+				ndlp->nlp_rpi = LPFC_RPI_ALLOC_ERROR;
+				ndlp->nlp_flag &= ~NLP_RELEASE_RPI;
+				spin_unlock_irq(&ndlp->lock);
+			}
 		}
+
+		lpfc_drop_node(vport, ndlp);
 	}
 
 	/* Release the originating I/O reference. */
-- 
2.38.0


  parent reply	other threads:[~2023-03-01 23:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-01 23:16 [PATCH 00/10] lpfc: Update lpfc to revision 14.2.0.11 Justin Tee
2023-03-01 23:16 ` [PATCH 01/10] lpfc: Protect against potential lpfc_debugfs_lockstat_write buffer overflow Justin Tee
2023-03-01 23:16 ` [PATCH 02/10] lpfc: Reorder freeing of various dma buffers and their list removal Justin Tee
2023-03-01 23:16 ` [PATCH 03/10] lpfc: Fix lockdep warning for rx_monitor lock when unloading driver Justin Tee
2023-03-01 23:16 ` [PATCH 04/10] lpfc: Record LOGO state with discovery engine even if aborted Justin Tee
2023-03-01 23:16 ` [PATCH 05/10] lpfc: Defer issuing new PLOGI if received RSCN before completing REG_LOGIN Justin Tee
2023-03-01 23:16 ` Justin Tee [this message]
2023-03-01 23:16 ` [PATCH 07/10] lpfc: Skip waiting for register ready bits when in unrecoverable state Justin Tee
2023-03-01 23:16 ` [PATCH 08/10] lpfc: Revise lpfc_error_lost_link reason code evaluation logic Justin Tee
2023-03-01 23:16 ` [PATCH 09/10] lpfc: Update lpfc version to 14.2.0.11 Justin Tee
2023-03-01 23:16 ` [PATCH 10/10] lpfc: Copyright updates for 14.2.0.11 patches Justin Tee
2023-03-07  3:04 ` [PATCH 00/10] lpfc: Update lpfc to revision 14.2.0.11 Martin K. Petersen
2023-03-10  3:14 ` Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230301231626.9621-7-justintee8345@gmail.com \
    --to=justintee8345@gmail.com \
    --cc=jsmart2021@gmail.com \
    --cc=justin.tee@broadcom.com \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox