Commit bdbe24de authored by Quinn Tran's avatar Quinn Tran Committed by Martin K. Petersen

scsi: qla2xxx: Cleanup NPIV host in target mode during config teardown

When we tear down the NPIV host configuration in target mode, the
qla_tgt struct was left dangling on the global list. This patch cleans
up link list and frees memory.
Signed-off-by: default avatarQuinn Tran <quinn.tran@cavium.com>
Signed-off-by: default avatarHimanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 1f4c7c38
...@@ -1528,6 +1528,7 @@ static void qlt_release(struct qla_tgt *tgt) ...@@ -1528,6 +1528,7 @@ static void qlt_release(struct qla_tgt *tgt)
u64 key = 0; u64 key = 0;
u16 i; u16 i;
struct qla_qpair_hint *h; struct qla_qpair_hint *h;
struct qla_hw_data *ha = vha->hw;
if ((vha->vha_tgt.qla_tgt != NULL) && !tgt->tgt_stop && if ((vha->vha_tgt.qla_tgt != NULL) && !tgt->tgt_stop &&
!tgt->tgt_stopped) !tgt->tgt_stopped)
...@@ -1548,12 +1549,18 @@ static void qlt_release(struct qla_tgt *tgt) ...@@ -1548,12 +1549,18 @@ static void qlt_release(struct qla_tgt *tgt)
} }
} }
kfree(tgt->qphints); kfree(tgt->qphints);
mutex_lock(&qla_tgt_mutex);
list_del(&vha->vha_tgt.qla_tgt->tgt_list_entry);
mutex_unlock(&qla_tgt_mutex);
btree_for_each_safe64(&tgt->lun_qpair_map, key, node) btree_for_each_safe64(&tgt->lun_qpair_map, key, node)
btree_remove64(&tgt->lun_qpair_map, key); btree_remove64(&tgt->lun_qpair_map, key);
btree_destroy64(&tgt->lun_qpair_map); btree_destroy64(&tgt->lun_qpair_map);
if (ha->tgt.tgt_ops && ha->tgt.tgt_ops->remove_target)
ha->tgt.tgt_ops->remove_target(vha);
vha->vha_tgt.qla_tgt = NULL; vha->vha_tgt.qla_tgt = NULL;
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf00d, ql_dbg(ql_dbg_tgt_mgt, vha, 0xf00d,
...@@ -6175,10 +6182,6 @@ int qlt_remove_target(struct qla_hw_data *ha, struct scsi_qla_host *vha) ...@@ -6175,10 +6182,6 @@ int qlt_remove_target(struct qla_hw_data *ha, struct scsi_qla_host *vha)
/* free left over qfull cmds */ /* free left over qfull cmds */
qlt_init_term_exchange(vha); qlt_init_term_exchange(vha);
mutex_lock(&qla_tgt_mutex);
list_del(&vha->vha_tgt.qla_tgt->tgt_list_entry);
mutex_unlock(&qla_tgt_mutex);
ql_dbg(ql_dbg_tgt, vha, 0xe03c, "Unregistering target for host %ld(%p)", ql_dbg(ql_dbg_tgt, vha, 0xe03c, "Unregistering target for host %ld(%p)",
vha->host_no, ha); vha->host_no, ha);
qlt_release(vha->vha_tgt.qla_tgt); qlt_release(vha->vha_tgt.qla_tgt);
......
...@@ -705,6 +705,7 @@ struct qla_tgt_func_tmpl { ...@@ -705,6 +705,7 @@ struct qla_tgt_func_tmpl {
int (*get_dif_tags)(struct qla_tgt_cmd *cmd, uint16_t *pfw_prot_opts); int (*get_dif_tags)(struct qla_tgt_cmd *cmd, uint16_t *pfw_prot_opts);
int (*chk_dif_tags)(uint32_t tag); int (*chk_dif_tags)(uint32_t tag);
void (*add_target)(struct scsi_qla_host *); void (*add_target)(struct scsi_qla_host *);
void (*remove_target)(struct scsi_qla_host *);
}; };
int qla2x00_wait_for_hba_online(struct scsi_qla_host *); int qla2x00_wait_for_hba_online(struct scsi_qla_host *);
......
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