diff mbox series

[02/13] qla2xxx: Fix disk failure to rediscover

Message ID 20220308082048.9774-3-njavali@marvell.com (mailing list archive)
State Superseded
Headers show
Series qla2xxx driver fixes | expand

Commit Message

Nilesh Javali March 8, 2022, 8:20 a.m. UTC
From: Quinn Tran <qutran@marvell.com>

User experience some of the LUN failed to rediscovered after
long cable pull test. The issue is triggered by a race
condition between driver setting session online state vs upper layer/UL
starting the LUN scan process at the same time. Current code
set the online state after notifying upper layer the session is
available. In this case, UL was faster on the trigger to start
the LUN scan process before driver could set the session in
online state. LUN scan ends up with failure due to the session
online check was failing.

Set the online state before reporting to UL
of the availability of the session.

Cc: stable@vger.kernel.org
Fixes: aecf043443d3 ("scsi: qla2xxx: Fix Remote port registration")
Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
---
 drivers/scsi/qla2xxx/qla_init.c | 5 +++--
 drivers/scsi/qla2xxx/qla_nvme.c | 5 +++++
 2 files changed, 8 insertions(+), 2 deletions(-)

Comments

Himanshu Madhani March 9, 2022, 6:38 p.m. UTC | #1
> On Mar 8, 2022, at 12:20 AM, Nilesh Javali <njavali@marvell.com> wrote:
> 
> From: Quinn Tran <qutran@marvell.com>
> 
> User experience some of the LUN failed to rediscovered after
> long cable pull test. The issue is triggered by a race
> condition between driver setting session online state vs upper layer/UL
							   ^^^^^^^^^^^^^ 
I would just remove “upper layer” in above statement. 

> starting the LUN scan process at the same time. Current code
> set the online state after notifying upper layer the session is
> available. In this case, UL was faster on the trigger to start
> the LUN scan process before driver could set the session in
> online state. LUN scan ends up with failure due to the session
> online check was failing.
> 
> Set the online state before reporting to UL
> of the availability of the session.
> 

The above 2 lines are redundant with the first paragraph. 

> Cc: stable@vger.kernel.org
> Fixes: aecf043443d3 ("scsi: qla2xxx: Fix Remote port registration")
> Signed-off-by: Quinn Tran <qutran@marvell.com>
> Signed-off-by: Nilesh Javali <njavali@marvell.com>
> ---
> drivers/scsi/qla2xxx/qla_init.c | 5 +++--
> drivers/scsi/qla2xxx/qla_nvme.c | 5 +++++
> 2 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
> index 835ed4179887..6ffe44b805b6 100644
> --- a/drivers/scsi/qla2xxx/qla_init.c
> +++ b/drivers/scsi/qla2xxx/qla_init.c
> @@ -5758,6 +5758,8 @@ qla2x00_reg_remote_port(scsi_qla_host_t *vha, fc_port_t *fcport)
> 	if (atomic_read(&fcport->state) == FCS_ONLINE)
> 		return;
> 
> +	qla2x00_set_fcport_state(fcport, FCS_ONLINE);
> +
> 	rport_ids.node_name = wwn_to_u64(fcport->node_name);
> 	rport_ids.port_name = wwn_to_u64(fcport->port_name);
> 	rport_ids.port_id = fcport->d_id.b.domain << 16 |
> @@ -5858,6 +5860,7 @@ qla2x00_update_fcport(scsi_qla_host_t *vha, fc_port_t *fcport)
> 		qla2x00_reg_remote_port(vha, fcport);
> 		break;
> 	case MODE_TARGET:
> +		qla2x00_set_fcport_state(fcport, FCS_ONLINE);
> 		if (!vha->vha_tgt.qla_tgt->tgt_stop &&
> 			!vha->vha_tgt.qla_tgt->tgt_stopped)
> 			qlt_fc_port_added(vha, fcport);
> @@ -5875,8 +5878,6 @@ qla2x00_update_fcport(scsi_qla_host_t *vha, fc_port_t *fcport)
> 	if (NVME_TARGET(vha->hw, fcport))
> 		qla_nvme_register_remote(vha, fcport);
> 
> -	qla2x00_set_fcport_state(fcport, FCS_ONLINE);
> -
> 	if (IS_IIDMA_CAPABLE(vha->hw) && vha->hw->flags.gpsc_supported) {
> 		if (fcport->id_changed) {
> 			fcport->id_changed = 0;
> diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
> index 718c761ff5f8..5723082d94d6 100644
> --- a/drivers/scsi/qla2xxx/qla_nvme.c
> +++ b/drivers/scsi/qla2xxx/qla_nvme.c
> @@ -37,6 +37,11 @@ int qla_nvme_register_remote(struct scsi_qla_host *vha, struct fc_port *fcport)
> 		(fcport->nvme_flag & NVME_FLAG_REGISTERED))
> 		return 0;
> 
> +	if (atomic_read(&fcport->state) == FCS_ONLINE)
> +		return 0;
> +
> +	qla2x00_set_fcport_state(fcport, FCS_ONLINE);
> +
> 	fcport->nvme_flag &= ~NVME_FLAG_RESETTING;
> 
> 	memset(&req, 0, sizeof(struct nvme_fc_port_info));
> -- 
> 2.19.0.rc0
> 

Patch itself looks good. After fixing commit message you can add 

Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>

--
Himanshu Madhani	 Oracle Linux Engineering
diff mbox series

Patch

diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 835ed4179887..6ffe44b805b6 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -5758,6 +5758,8 @@  qla2x00_reg_remote_port(scsi_qla_host_t *vha, fc_port_t *fcport)
 	if (atomic_read(&fcport->state) == FCS_ONLINE)
 		return;
 
+	qla2x00_set_fcport_state(fcport, FCS_ONLINE);
+
 	rport_ids.node_name = wwn_to_u64(fcport->node_name);
 	rport_ids.port_name = wwn_to_u64(fcport->port_name);
 	rport_ids.port_id = fcport->d_id.b.domain << 16 |
@@ -5858,6 +5860,7 @@  qla2x00_update_fcport(scsi_qla_host_t *vha, fc_port_t *fcport)
 		qla2x00_reg_remote_port(vha, fcport);
 		break;
 	case MODE_TARGET:
+		qla2x00_set_fcport_state(fcport, FCS_ONLINE);
 		if (!vha->vha_tgt.qla_tgt->tgt_stop &&
 			!vha->vha_tgt.qla_tgt->tgt_stopped)
 			qlt_fc_port_added(vha, fcport);
@@ -5875,8 +5878,6 @@  qla2x00_update_fcport(scsi_qla_host_t *vha, fc_port_t *fcport)
 	if (NVME_TARGET(vha->hw, fcport))
 		qla_nvme_register_remote(vha, fcport);
 
-	qla2x00_set_fcport_state(fcport, FCS_ONLINE);
-
 	if (IS_IIDMA_CAPABLE(vha->hw) && vha->hw->flags.gpsc_supported) {
 		if (fcport->id_changed) {
 			fcport->id_changed = 0;
diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
index 718c761ff5f8..5723082d94d6 100644
--- a/drivers/scsi/qla2xxx/qla_nvme.c
+++ b/drivers/scsi/qla2xxx/qla_nvme.c
@@ -37,6 +37,11 @@  int qla_nvme_register_remote(struct scsi_qla_host *vha, struct fc_port *fcport)
 		(fcport->nvme_flag & NVME_FLAG_REGISTERED))
 		return 0;
 
+	if (atomic_read(&fcport->state) == FCS_ONLINE)
+		return 0;
+
+	qla2x00_set_fcport_state(fcport, FCS_ONLINE);
+
 	fcport->nvme_flag &= ~NVME_FLAG_RESETTING;
 
 	memset(&req, 0, sizeof(struct nvme_fc_port_info));