Skip to content

Commit 5f800d7

Browse files
Justin Teemartinkpetersen
authored andcommitted
scsi: lpfc: Introduce rrq_list_lock to protect active_rrq_list
Instead of using the generic object wide phba->hbalock, an explicit lock should be used to synchronize mutations to the phba->active_rrq_list. Update all accesses to the phba->active_rrq_list with a new phba->rrq_list_lock. Signed-off-by: Justin Tee <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
1 parent bf81e9c commit 5f800d7

File tree

5 files changed

+22
-8
lines changed

5 files changed

+22
-8
lines changed

drivers/scsi/lpfc/lpfc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,7 @@ struct lpfc_hba {
12841284
uint32_t total_scsi_bufs;
12851285
struct list_head lpfc_iocb_list;
12861286
uint32_t total_iocbq_bufs;
1287+
spinlock_t rrq_list_lock; /* lock for active_rrq_list */
12871288
struct list_head active_rrq_list;
12881289
spinlock_t hbalock;
12891290
struct work_struct unblock_request_work; /* SCSI layer unblock IOs */

drivers/scsi/lpfc/lpfc_init.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14812,6 +14812,7 @@ lpfc_pci_probe_one_s4(struct pci_dev *pdev, const struct pci_device_id *pid)
1481214812
goto out_unset_pci_mem_s4;
1481314813
}
1481414814

14815+
spin_lock_init(&phba->rrq_list_lock);
1481514816
INIT_LIST_HEAD(&phba->active_rrq_list);
1481614817
INIT_LIST_HEAD(&phba->fcf.fcf_pri_list);
1481714818

drivers/scsi/lpfc/lpfc_nvmet.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,7 +1811,9 @@ lpfc_sli4_nvmet_xri_aborted(struct lpfc_hba *phba,
18111811
ctxp->flag &= ~LPFC_NVME_XBUSY;
18121812
spin_unlock_irqrestore(&ctxp->ctxlock, iflag);
18131813

1814+
spin_lock_irqsave(&phba->rrq_list_lock, iflag);
18141815
rrq_empty = list_empty(&phba->active_rrq_list);
1816+
spin_unlock_irqrestore(&phba->rrq_list_lock, iflag);
18151817
ndlp = lpfc_findnode_did(phba->pport, ctxp->sid);
18161818
if (ndlp &&
18171819
(ndlp->nlp_state == NLP_STE_UNMAPPED_NODE ||

drivers/scsi/lpfc/lpfc_scsi.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,9 +474,11 @@ lpfc_sli4_io_xri_aborted(struct lpfc_hba *phba,
474474
ndlp = psb->rdata->pnode;
475475
else
476476
ndlp = NULL;
477+
spin_unlock_irqrestore(&phba->hbalock, iflag);
477478

479+
spin_lock_irqsave(&phba->rrq_list_lock, iflag);
478480
rrq_empty = list_empty(&phba->active_rrq_list);
479-
spin_unlock_irqrestore(&phba->hbalock, iflag);
481+
spin_unlock_irqrestore(&phba->rrq_list_lock, iflag);
480482
if (ndlp && !offline) {
481483
lpfc_set_rrq_active(phba, ndlp,
482484
psb->cur_iocbq.sli4_lxritag, rxid, 1);

drivers/scsi/lpfc/lpfc_sli.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,15 +1026,18 @@ lpfc_handle_rrq_active(struct lpfc_hba *phba)
10261026

10271027
spin_lock_irqsave(&phba->hbalock, iflags);
10281028
phba->hba_flag &= ~HBA_RRQ_ACTIVE;
1029+
spin_unlock_irqrestore(&phba->hbalock, iflags);
1030+
10291031
next_time = jiffies + msecs_to_jiffies(1000 * (phba->fc_ratov + 1));
1032+
spin_lock_irqsave(&phba->rrq_list_lock, iflags);
10301033
list_for_each_entry_safe(rrq, nextrrq,
10311034
&phba->active_rrq_list, list) {
10321035
if (time_after(jiffies, rrq->rrq_stop_time))
10331036
list_move(&rrq->list, &send_rrq);
10341037
else if (time_before(rrq->rrq_stop_time, next_time))
10351038
next_time = rrq->rrq_stop_time;
10361039
}
1037-
spin_unlock_irqrestore(&phba->hbalock, iflags);
1040+
spin_unlock_irqrestore(&phba->rrq_list_lock, iflags);
10381041
if ((!list_empty(&phba->active_rrq_list)) &&
10391042
(!test_bit(FC_UNLOADING, &phba->pport->load_flag)))
10401043
mod_timer(&phba->rrq_tmr, next_time);
@@ -1072,16 +1075,16 @@ lpfc_get_active_rrq(struct lpfc_vport *vport, uint16_t xri, uint32_t did)
10721075

10731076
if (phba->sli_rev != LPFC_SLI_REV4)
10741077
return NULL;
1075-
spin_lock_irqsave(&phba->hbalock, iflags);
1078+
spin_lock_irqsave(&phba->rrq_list_lock, iflags);
10761079
list_for_each_entry_safe(rrq, nextrrq, &phba->active_rrq_list, list) {
10771080
if (rrq->vport == vport && rrq->xritag == xri &&
10781081
rrq->nlp_DID == did){
10791082
list_del(&rrq->list);
1080-
spin_unlock_irqrestore(&phba->hbalock, iflags);
1083+
spin_unlock_irqrestore(&phba->rrq_list_lock, iflags);
10811084
return rrq;
10821085
}
10831086
}
1084-
spin_unlock_irqrestore(&phba->hbalock, iflags);
1087+
spin_unlock_irqrestore(&phba->rrq_list_lock, iflags);
10851088
return NULL;
10861089
}
10871090

@@ -1109,7 +1112,7 @@ lpfc_cleanup_vports_rrqs(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
11091112
lpfc_sli4_vport_delete_els_xri_aborted(vport);
11101113
lpfc_sli4_vport_delete_fcp_xri_aborted(vport);
11111114
}
1112-
spin_lock_irqsave(&phba->hbalock, iflags);
1115+
spin_lock_irqsave(&phba->rrq_list_lock, iflags);
11131116
list_for_each_entry_safe(rrq, nextrrq, &phba->active_rrq_list, list) {
11141117
if (rrq->vport != vport)
11151118
continue;
@@ -1118,7 +1121,7 @@ lpfc_cleanup_vports_rrqs(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
11181121
list_move(&rrq->list, &rrq_list);
11191122

11201123
}
1121-
spin_unlock_irqrestore(&phba->hbalock, iflags);
1124+
spin_unlock_irqrestore(&phba->rrq_list_lock, iflags);
11221125

11231126
list_for_each_entry_safe(rrq, nextrrq, &rrq_list, list) {
11241127
list_del(&rrq->list);
@@ -1213,11 +1216,16 @@ lpfc_set_rrq_active(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
12131216
rrq->nlp_DID = ndlp->nlp_DID;
12141217
rrq->vport = ndlp->vport;
12151218
rrq->rxid = rxid;
1216-
spin_lock_irqsave(&phba->hbalock, iflags);
1219+
1220+
spin_lock_irqsave(&phba->rrq_list_lock, iflags);
12171221
empty = list_empty(&phba->active_rrq_list);
12181222
list_add_tail(&rrq->list, &phba->active_rrq_list);
1223+
spin_unlock_irqrestore(&phba->rrq_list_lock, iflags);
1224+
1225+
spin_lock_irqsave(&phba->hbalock, iflags);
12191226
phba->hba_flag |= HBA_RRQ_ACTIVE;
12201227
spin_unlock_irqrestore(&phba->hbalock, iflags);
1228+
12211229
if (empty)
12221230
lpfc_worker_wake_up(phba);
12231231
return 0;

0 commit comments

Comments
 (0)