qla2xxx target fixes
Subsystems (2)
cover qla2xxx target fixes
From: Roland Dreier <[email protected]>
Hi everyone, a couple of qla2xxx target fixes that we've been shipping for a while at Pure and that I've finally got around to cleaning up and merging to the latest kernel tree...
Roland Dreier (2):
tcm_qla2xxx: Format VPD page 83h SCSI name string according to SPC
qla2xxx: Update target lookup session tables when a target session
changes
drivers/scsi/qla2xxx/qla_target.c | 22 +++++------ drivers/scsi/qla2xxx/qla_target.h | 1 + drivers/scsi/qla2xxx/tcm_qla2xxx.c | 77 +++++++++++++++++++++++++++++++++++- drivers/scsi/qla2xxx/tcm_qla2xxx.h | 2 + 4 files changed, 89 insertions(+), 13 deletions(-)
Signature · 1 line
1.7.10.4
PATCH 1/2 tcm_qla2xxx: Format VPD page 83h SCSI name string according to SPC
From: Roland Dreier <[email protected]>
My draft of SPC-4 says the following about the SCSI name string in inquiry VPD page 83h:
The SCSI NAME STRING field starts with either:
a) the four UTF-8 characters 'eui.' concatenated with 16, 24, or 32 hexadecimal digits (i.e., the UTF-8 characters 0 through 9 and A through F) for an EUI-64 based identifier (see 7.8.6.5). The first hexadecimal digit shall be the most significant four bits of the first byte (i.e., most significant byte) of the EUI-64 based identifier;
b) the four UTF-8 characters 'naa.' concatenated with 16 or 32 hexadecimal digits for an NAA identifier (see 7.8.6.6). The first hexadecimal digit shall be the most significant four bits of the first byte (i.e., most significant byte) of the NAA identifier; or
c) the four UTF-8 characters 'iqn.' concatenated with an iSCSI Name for an iSCSI-name based identifier (see iSCSI).
However, the .tpg_get_wwn method for tcm_qla2xxx formats the WWN so the SCSI name string looks like "52:4a:93:7d:24:5f:b2:12,t,0x0001". This patch corrects the code so that VPD 83h gives a SPC-compliant SCSI name string like "naa.524a937d245fb212,t,0x0001" while leavig other uses alone (so configfs will still work with ':' separated WWNs).
--- drivers/scsi/qla2xxx/tcm_qla2xxx.c | 4 +++- drivers/scsi/qla2xxx/tcm_qla2xxx.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/scsi/qla2xxx/tcm_qla2xxx.c +3 -1
@@ -237,7 +237,7 @@ static char *tcm_qla2xxx_get_fabric_wwn(struct se_portal_group *se_tpg) struct tcm_qla2xxx_tpg, se_tpg);struct tcm_qla2xxx_lport *lport = tpg->lport; -return &lport->lport_name[0 ]; +return lport->lport_naa_name; }static char *tcm_qla2xxx_npiv_get_fabric_wwn (struct se_portal_group *se_tpg)
@@ -1534,6 +1534,7 @@ static struct se_wwn *tcm_qla2xxx_make_lport( lport->lport_wwpn = wwpn;tcm_qla2xxx_format_wwn (&lport->lport_name[0 ],TCM_QLA2XXX_NAMELEN , wwpn); +sprintf (lport->lport_naa_name,"naa.%016llx" , (unsigned long long ) wwpn); ret =tcm_qla2xxx_init_lport (lport);if (ret !=0 )
@@ -1601,6 +1602,7 @@ static struct se_wwn *tcm_qla2xxx_npiv_make_lport( lport->lport_npiv_wwnn = npiv_wwnn;tcm_qla2xxx_npiv_format_wwn (&lport->lport_npiv_name[0 ],TCM_QLA2XXX_NAMELEN , npiv_wwpn, npiv_wwnn); +sprintf (lport->lport_naa_name,"naa.%016llx" , (unsigned long long ) npiv_wwpn);/* FIXME: tcm_qla2xxx_npiv_make_lport */ ret = -ENOSYS ;
drivers/scsi/qla2xxx/tcm_qla2xxx.h +2 -0
@@ -61,6 +61,8 @@ struct tcm_qla2xxx_lport {u64 lport_npiv_wwnn;/* ASCII formatted WWPN for FC Target Lport */ char lport_name[TCM_QLA2XXX_NAMELEN ]; +/* ASCII formatted naa WWPN for VPD page 83 etc */ +char lport_naa_name[TCM_QLA2XXX_NAMELEN ];/* ASCII formatted WWPN+WWNN for NPIV FC Target Lport */ char lport_npiv_name[TCM_QLA2XXX_NPIV_NAMELEN ];/* map for fc_port pointers in 24-bit FC Port ID space */
Signature · 1 line
1.7.10.4
Nicholas A. Bellinger
AppliedRe: [PATCH 1/2] tcm_qla2xxx: Format VPD page 83h SCSI name string according to SPC
Quoted 21 lines · Roland Dreier
From: Roland Dreier <[email protected]>
My draft of SPC-4 says the following about the SCSI name string in inquiry VPD page 83h:
The SCSI NAME STRING field starts with either:
a) the four UTF-8 characters 'eui.' concatenated with 16, 24, or 32 hexadecimal digits (i.e., the UTF-8 characters 0 through 9 and A through F) for an EUI-64 based identifier (see 7.8.6.5). The first hexadecimal digit shall be the most significant four bits of the first byte (i.e., most significant byte) of the EUI-64 based identifier;
b) the four UTF-8 characters 'naa.' concatenated with 16 or 32 hexadecimal digits for an NAA identifier (see 7.8.6.6). The first hexadecimal digit shall be the most significant four bits of the first byte (i.e., most significant byte) of the NAA identifier; or
c) the four UTF-8 characters 'iqn.' concatenated with an iSCSI Name for an iSCSI-name based identifier (see iSCSI).
Quoted 8 lines
However, the .tpg_get_wwn method for
tcm_qla2xxxformats the WWN so the SCSI name string looks like "52:4a:93:7d:24:5f:b2:12,t,0x0001". This patch corrects the code so that VPD 83h gives a SPC-compliant SCSI name string like "naa.524a937d245fb212,t,0x0001" while leavig other uses alone (so configfs will still work with ':' separated WWNs).Signed-off-by Roland Dreier <[email protected]>---
Hi Roland,
Apologies for the delayed response on this patch.
Applied to target-pending/master and queued for v3.7-rc fixes
Thanks!
PATCH 2/2 qla2xxx: Update target lookup session tables when a target session changes
In reply to Roland DreierFrom: Roland Dreier <[email protected]>
It is possible for the target code to change the loop_id or s_id of a target session in reaction to an FC fabric change. However, the session structures are stored in tables that are indexed by these two keys, and if we just change the session structure but leave the pointers to it in the old places in the table, havoc can ensue. For example, a new session might come along that should go in the old slot in the table and overwrite the old session pointer.
To handle this, add a new tgt_ops->update_sess() method that also updates the "by loop_id" and "by s_id" lookup tables when a session changes, so that the keys where a session pointer is stored in these tables always matches the keys in the session structure itself.
--- drivers/scsi/qla2xxx/qla_target.c | 22 +++++------ drivers/scsi/qla2xxx/qla_target.h | 1 + drivers/scsi/qla2xxx/tcm_qla2xxx.c | 73 ++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 12 deletions(-)
drivers/scsi/qla2xxx/qla_target.c +10 -12
@@ -557,6 +557,7 @@ static bool qlt_check_fcport_exist(struct scsi_qla_host *vha,int pmap_len;fc_port_t *fcport;int global_resets; +unsigned long flags; retry: global_resets =atomic_read (&ha->tgt.qla_tgt->tgt_global_resets_count);
@@ -625,10 +626,10 @@ retry: sess->s_id.b.area, sess->loop_id, fcport->d_id.b.domain, fcport->d_id.b.al_pa, fcport->d_id.b.area, fcport->loop_id); - sess->s_id = fcport->d_id; - sess->loop_id = fcport->loop_id; - sess->conf_compl_supported = !!(fcport->flags & -FCF_CONF_COMP_SUPPORTED ); +spin_lock_irqsave (&ha->hardware_lock, flags); + ha->tgt.tgt_ops->update_sess (sess, fcport->d_id, fcport->loop_id, + !!(fcport->flags &FCF_CONF_COMP_SUPPORTED )); +spin_unlock_irqrestore (&ha->hardware_lock, flags); res = true;
@@ -740,10 +741,9 @@ static struct qla_tgt_sess *qlt_create_sess(qlt_undelete_sess (sess);kref_get (&sess->se_sess->sess_kref); - sess->s_id = fcport->d_id; - sess->loop_id = fcport->loop_id; - sess->conf_compl_supported = !!(fcport->flags & -FCF_CONF_COMP_SUPPORTED ); + ha->tgt.tgt_ops->update_sess (sess, fcport->d_id, fcport->loop_id, + !!(fcport->flags &FCF_CONF_COMP_SUPPORTED )); +if (sess->local && !local) sess->local =0 ;spin_unlock_irqrestore (&ha->hardware_lock, flags);
@@ -869,10 +869,8 @@ void qlt_fc_port_added(struct scsi_qla_host *vha, fc_port_t *fcport)ql_dbg (ql_dbg_tgt_mgt, vha,0xf007 ,"Reappeared sess %p\n" , sess); } - sess->s_id = fcport->d_id; - sess->loop_id = fcport->loop_id; - sess->conf_compl_supported = !!(fcport->flags & -FCF_CONF_COMP_SUPPORTED ); + ha->tgt.tgt_ops->update_sess (sess, fcport->d_id, fcport->loop_id, + !!(fcport->flags &FCF_CONF_COMP_SUPPORTED )); }if (sess && sess->local) {
drivers/scsi/qla2xxx/qla_target.h +1 -0
@@ -648,6 +648,7 @@ struct qla_tgt_func_tmpl {int (*check_initiator_node_acl)(struct scsi_qla_host *,unsigned char *,void *,uint8_t *,uint16_t ); +void (*update_sess)(struct qla_tgt_sess *,port_id_t ,uint16_t ,bool );struct qla_tgt_sess *(*find_sess_by_loop_id)(struct scsi_qla_host *,const uint16_t ); struct qla_tgt_sess *(*find_sess_by_s_id)(struct scsi_qla_host *,
drivers/scsi/qla2xxx/tcm_qla2xxx.c +73 -0
85 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Nicholas A. Bellinger
AppliedRe: [PATCH 2/2] qla2xxx: Update target lookup session tables when a target session changes
Quoted 10 lines · Roland Dreier
From: Roland Dreier <[email protected]>
It is possible for the target code to change the
loop_idors_idof a target session in reaction to an FC fabric change. However, the session structures are stored in tables that are indexed by these two keys, and if we just change the session structure but leave the pointers to it in the old places in the table, havoc can ensue. For example, a new session might come along that should go in the old slot in the table and overwrite the old session pointer.
Quoted 7 lines
To handle this, add a new
tgt_ops->update_sess()method that also updates the "byloop_id" and "bys_id" lookup tables when a session changes, so that the keys where a session pointer is stored in these tables always matches the keys in the session structure itself.Signed-off-by Roland Dreier <[email protected]>---
Nice work tracking down this long standing bug with fc_port_t handling !
Queued for v3.7-rc fixes with a CC' to stable.
One extra bit below..
Quoted 20 lines
drivers/scsi/qla2xxx/qla_target.c | 22 +++++------ drivers/scsi/qla2xxx/qla_target.h | 1 + drivers/scsi/qla2xxx/tcm_qla2xxx.c | 73 ++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 12 deletions(-)drivers/scsi/qla2xxx/qla_target.c +1
-0@@ -557,6 +557,7 @@ static bool qlt_check_fcport_exist(struct scsi_qla_host *vha,int pmap_len;fc_port_t *fcport;int global_resets; +unsigned long flags; retry: global_resets =atomic_read (&ha->tgt.qla_tgt->tgt_global_resets_count);@@ -625,10 +626,10 @@ retry: sess->s_id.b.area, sess->loop_id, fcport->d_id.b.domain, fcport->d_id.b.al_pa, fcport->d_id.b.area, fcport->loop_id);
drivers/scsi/qla2xxx/qla_target.c retry: · line 633
Quoted 10 lines
drivers/scsi/qla2xxx/qla_target.c +4
-4- sess->s_id = fcport->d_id; - sess->loop_id = fcport->loop_id; - sess->conf_compl_supported = !!(fcport->flags & -FCF_CONF_COMP_SUPPORTED ); +spin_lock_irqsave (&ha->hardware_lock, flags); + ha->tgt.tgt_ops->update_sess (sess, fcport->d_id, fcport->loop_id, + !!(fcport->flags &FCF_CONF_COMP_SUPPORTED )); +spin_unlock_irqrestore (&ha->hardware_lock, flags);
Dropping the extra unnecessary '!!' double inversion check here around FCF_CONF_COMP_SUPPORTED usage, and folding into the original patch.
drivers/scsi/qla2xxx/qla_target.c static struct qla_tgt_sess *qlt_create_sess( · line 746
Quoted 13 lines
drivers/scsi/qla2xxx/qla_target.c +3
-4res = true;@@ -740,10 +741,9 @@ static struct qla_tgt_sess *qlt_create_sess(qlt_undelete_sess (sess);kref_get (&sess->se_sess->sess_kref); - sess->s_id = fcport->d_id; - sess->loop_id = fcport->loop_id; - sess->conf_compl_supported = !!(fcport->flags & -FCF_CONF_COMP_SUPPORTED ); + ha->tgt.tgt_ops->update_sess (sess, fcport->d_id, fcport->loop_id, + !!(fcport->flags &FCF_CONF_COMP_SUPPORTED )); +
Ditto
Quoted 5 lines
drivers/scsi/qla2xxx/qla_target.c +0
-0if (sess->local && !local) sess->local =0 ;spin_unlock_irqrestore (&ha->hardware_lock, flags);@@ -869,10 +869,8 @@ void qlt_fc_port_added(struct scsi_qla_host *vha, fc_port_t *fcport) ql_dbg(ql_dbg_tgt_mgt, vha, 0xf007,
drivers/scsi/qla2xxx/qla_target.c void qlt_fc_port_added(struct scsi_qla_host *vha, fc_port_t *fcport) · line 875
Quoted 10 lines
drivers/scsi/qla2xxx/qla_target.c +2
-4"Reappeared sess %p\n", sess); } - sess->s_id = fcport->d_id; - sess->loop_id = fcport->loop_id; - sess->conf_compl_supported = !!(fcport->flags & -FCF_CONF_COMP_SUPPORTED ); + ha->tgt.tgt_ops->update_sess (sess, fcport->d_id, fcport->loop_id, + !!(fcport->flags &FCF_CONF_COMP_SUPPORTED )); }
And here too..
Thanks Roland!