Commit 4adc041b authored by Dick Kennedy's avatar Dick Kennedy Committed by Martin K. Petersen

scsi: lpfc: Fix duplicate NVME rport entries and namespaces.

After lip, the driver sometimes would have two rports for the same
device, allowing the namespaces to be duplicated by nvme.

In lpfc_plogi_confirm_nport() the driver was not swapping the nrport
maintained by the ndlp's undergoing address swapping. This allowed the
2nd rport to sneak in as it was considered a separate device.

This patch adds the fixes to Swap the nrport in each ndlp and take care
of the reference counts on the ndlps similar to FCP rports.
Signed-off-by: default avatarDick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: default avatarJames Smart <james.smart@broadcom.com>
Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 8db1c2b3
...@@ -1527,6 +1527,7 @@ lpfc_plogi_confirm_nport(struct lpfc_hba *phba, uint32_t *prsp, ...@@ -1527,6 +1527,7 @@ lpfc_plogi_confirm_nport(struct lpfc_hba *phba, uint32_t *prsp,
uint8_t name[sizeof(struct lpfc_name)]; uint8_t name[sizeof(struct lpfc_name)];
uint32_t rc, keepDID = 0, keep_nlp_flag = 0; uint32_t rc, keepDID = 0, keep_nlp_flag = 0;
uint16_t keep_nlp_state; uint16_t keep_nlp_state;
struct lpfc_nvme_rport *keep_nrport = NULL;
int put_node; int put_node;
int put_rport; int put_rport;
unsigned long *active_rrqs_xri_bitmap = NULL; unsigned long *active_rrqs_xri_bitmap = NULL;
...@@ -1624,6 +1625,10 @@ lpfc_plogi_confirm_nport(struct lpfc_hba *phba, uint32_t *prsp, ...@@ -1624,6 +1625,10 @@ lpfc_plogi_confirm_nport(struct lpfc_hba *phba, uint32_t *prsp,
keep_nlp_state = new_ndlp->nlp_state; keep_nlp_state = new_ndlp->nlp_state;
lpfc_nlp_set_state(vport, new_ndlp, ndlp->nlp_state); lpfc_nlp_set_state(vport, new_ndlp, ndlp->nlp_state);
/* interchange the nvme remoteport structs */
keep_nrport = new_ndlp->nrport;
new_ndlp->nrport = ndlp->nrport;
/* Move this back to NPR state */ /* Move this back to NPR state */
if (memcmp(&ndlp->nlp_portname, name, sizeof(struct lpfc_name)) == 0) { if (memcmp(&ndlp->nlp_portname, name, sizeof(struct lpfc_name)) == 0) {
/* The new_ndlp is replacing ndlp totally, so we need /* The new_ndlp is replacing ndlp totally, so we need
...@@ -1646,6 +1651,13 @@ lpfc_plogi_confirm_nport(struct lpfc_hba *phba, uint32_t *prsp, ...@@ -1646,6 +1651,13 @@ lpfc_plogi_confirm_nport(struct lpfc_hba *phba, uint32_t *prsp,
} }
new_ndlp->nlp_type = ndlp->nlp_type; new_ndlp->nlp_type = ndlp->nlp_type;
} }
/* Fix up the nvme rport */
if (ndlp->nrport) {
ndlp->nrport = NULL;
lpfc_nlp_put(ndlp);
}
/* We shall actually free the ndlp with both nlp_DID and /* We shall actually free the ndlp with both nlp_DID and
* nlp_portname fields equals 0 to avoid any ndlp on the * nlp_portname fields equals 0 to avoid any ndlp on the
* nodelist never to be used. * nodelist never to be used.
...@@ -1690,6 +1702,14 @@ lpfc_plogi_confirm_nport(struct lpfc_hba *phba, uint32_t *prsp, ...@@ -1690,6 +1702,14 @@ lpfc_plogi_confirm_nport(struct lpfc_hba *phba, uint32_t *prsp,
keep_nlp_state = NLP_STE_NPR_NODE; keep_nlp_state = NLP_STE_NPR_NODE;
lpfc_nlp_set_state(vport, ndlp, keep_nlp_state); lpfc_nlp_set_state(vport, ndlp, keep_nlp_state);
/* Previous ndlp no longer active with nvme host transport.
* Remove reference from earlier registration unless the
* nvme host took care of it.
*/
if (ndlp->nrport)
lpfc_nlp_put(ndlp);
ndlp->nrport = keep_nrport;
/* Fix up the rport accordingly */ /* Fix up the rport accordingly */
rport = ndlp->rport; rport = ndlp->rport;
if (rport) { if (rport) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment