Skip to content

Commit f5187b7

Browse files
Quinn Tranmartinkpetersen
authored andcommitted
scsi: qla2xxx: Optimize NPIV tear down process
In the case of NPIV port is being torn down, this patch will set a flag to indicate VPORT_DELETE. This would prevent relogin to be triggered. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Quinn Tran <[email protected]> Signed-off-by: Himanshu Madhani <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent fd5564b commit f5187b7

File tree

6 files changed

+34
-12
lines changed

6 files changed

+34
-12
lines changed

drivers/scsi/qla2xxx/qla_attr.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2920,6 +2920,8 @@ qla24xx_vport_delete(struct fc_vport *fc_vport)
29202920
struct qla_hw_data *ha = vha->hw;
29212921
uint16_t id = vha->vp_idx;
29222922

2923+
set_bit(VPORT_DELETE, &vha->dpc_flags);
2924+
29232925
while (test_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags) ||
29242926
test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags))
29252927
msleep(1000);

drivers/scsi/qla2xxx/qla_def.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4394,6 +4394,7 @@ typedef struct scsi_qla_host {
43944394
#define IOCB_WORK_ACTIVE 31
43954395
#define SET_ZIO_THRESHOLD_NEEDED 32
43964396
#define ISP_ABORT_TO_ROM 33
4397+
#define VPORT_DELETE 34
43974398

43984399
unsigned long pci_flags;
43994400
#define PFLG_DISCONNECTED 0 /* PCI device removed */

drivers/scsi/qla2xxx/qla_gs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3102,7 +3102,8 @@ int qla24xx_post_gpnid_work(struct scsi_qla_host *vha, port_id_t *id)
31023102
{
31033103
struct qla_work_evt *e;
31043104

3105-
if (test_bit(UNLOADING, &vha->dpc_flags))
3105+
if (test_bit(UNLOADING, &vha->dpc_flags) ||
3106+
(vha->vp_idx && test_bit(VPORT_DELETE, &vha->dpc_flags)))
31063107
return 0;
31073108

31083109
e = qla2x00_alloc_work(vha, QLA_EVT_GPNID);

drivers/scsi/qla2xxx/qla_mid.c

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ qla24xx_deallocate_vp_id(scsi_qla_host_t *vha)
6666
uint16_t vp_id;
6767
struct qla_hw_data *ha = vha->hw;
6868
unsigned long flags = 0;
69+
u8 i;
6970

7071
mutex_lock(&ha->vport_lock);
7172
/*
@@ -75,8 +76,9 @@ qla24xx_deallocate_vp_id(scsi_qla_host_t *vha)
7576
* ensures no active vp_list traversal while the vport is removed
7677
* from the queue)
7778
*/
78-
wait_event_timeout(vha->vref_waitq, !atomic_read(&vha->vref_count),
79-
10*HZ);
79+
for (i = 0; i < 10 && atomic_read(&vha->vref_count); i++)
80+
wait_event_timeout(vha->vref_waitq,
81+
atomic_read(&vha->vref_count), HZ);
8082

8183
spin_lock_irqsave(&ha->vport_slock, flags);
8284
if (atomic_read(&vha->vref_count)) {
@@ -262,6 +264,9 @@ qla2x00_alert_all_vps(struct rsp_que *rsp, uint16_t *mb)
262264
spin_lock_irqsave(&ha->vport_slock, flags);
263265
list_for_each_entry(vha, &ha->vp_list, list) {
264266
if (vha->vp_idx) {
267+
if (test_bit(VPORT_DELETE, &vha->dpc_flags))
268+
continue;
269+
265270
atomic_inc(&vha->vref_count);
266271
spin_unlock_irqrestore(&ha->vport_slock, flags);
267272

@@ -300,6 +305,20 @@ qla2x00_alert_all_vps(struct rsp_que *rsp, uint16_t *mb)
300305
int
301306
qla2x00_vp_abort_isp(scsi_qla_host_t *vha)
302307
{
308+
fc_port_t *fcport;
309+
310+
/*
311+
* To exclusively reset vport, we need to log it out first.
312+
* Note: This control_vp can fail if ISP reset is already
313+
* issued, this is expected, as the vp would be already
314+
* logged out due to ISP reset.
315+
*/
316+
if (!test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) {
317+
qla24xx_control_vp(vha, VCE_COMMAND_DISABLE_VPS_LOGO_ALL);
318+
list_for_each_entry(fcport, &vha->vp_fcports, list)
319+
fcport->logout_on_delete = 0;
320+
}
321+
303322
/*
304323
* Physical port will do most of the abort and recovery work. We can
305324
* just treat it as a loop down
@@ -312,16 +331,9 @@ qla2x00_vp_abort_isp(scsi_qla_host_t *vha)
312331
atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME);
313332
}
314333

315-
/*
316-
* To exclusively reset vport, we need to log it out first. Note: this
317-
* control_vp can fail if ISP reset is already issued, this is
318-
* expected, as the vp would be already logged out due to ISP reset.
319-
*/
320-
if (!test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))
321-
qla24xx_control_vp(vha, VCE_COMMAND_DISABLE_VPS_LOGO_ALL);
322-
323334
ql_dbg(ql_dbg_taskm, vha, 0x801d,
324335
"Scheduling enable of Vport %d.\n", vha->vp_idx);
336+
325337
return qla24xx_enable_vp(vha);
326338
}
327339

drivers/scsi/qla2xxx/qla_os.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,9 +1115,14 @@ static inline int test_fcport_count(scsi_qla_host_t *vha)
11151115
void
11161116
qla2x00_wait_for_sess_deletion(scsi_qla_host_t *vha)
11171117
{
1118+
u8 i;
1119+
11181120
qla2x00_mark_all_devices_lost(vha, 0);
11191121

1120-
wait_event_timeout(vha->fcport_waitQ, test_fcport_count(vha), 10*HZ);
1122+
for (i = 0; i < 10; i++)
1123+
wait_event_timeout(vha->fcport_waitQ, test_fcport_count(vha),
1124+
HZ);
1125+
11211126
flush_workqueue(vha->hw->wq);
11221127
}
11231128

drivers/scsi/qla2xxx/qla_target.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,7 @@ void qlt_free_session_done(struct work_struct *work)
11151115
wake_up_all(&tgt->waitQ);
11161116

11171117
if (!test_bit(PFLG_DRIVER_REMOVING, &base_vha->pci_flags) &&
1118+
!(vha->vp_idx && test_bit(VPORT_DELETE, &vha->dpc_flags)) &&
11181119
(!tgt || !tgt->tgt_stop) && !LOOP_TRANSITION(vha)) {
11191120
switch (vha->host->active_mode) {
11201121
case MODE_INITIATOR:

0 commit comments

Comments
 (0)