[PATCH v4 12/12] nvmet-fc: use RCU list iterator for assoc_list
From: Daniel Wagner
Date: Tue Jan 30 2024 - 04:54:57 EST
The assoc_list is a RCU protected list, thus use the RCU flavor of list
functions.
Signed-off-by: Daniel Wagner <dwagner@xxxxxxx>
---
drivers/nvme/target/fc.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c
index 671d096745a5..b8d3e30f2ddb 100644
--- a/drivers/nvme/target/fc.c
+++ b/drivers/nvme/target/fc.c
@@ -1151,7 +1151,9 @@ nvmet_fc_alloc_target_assoc(struct nvmet_fc_tgtport *tgtport, void *hosthandle)
spin_lock_irqsave(&tgtport->lock, flags);
needrandom = false;
- list_for_each_entry(tmpassoc, &tgtport->assoc_list, a_list) {
+ rcu_read_lock();
+ list_for_each_entry_rcu(tmpassoc, &tgtport->assoc_list, a_list) {
+
if (ran == tmpassoc->association_id) {
needrandom = true;
break;
@@ -1161,6 +1163,7 @@ nvmet_fc_alloc_target_assoc(struct nvmet_fc_tgtport *tgtport, void *hosthandle)
assoc->association_id = ran;
list_add_tail_rcu(&assoc->a_list, &tgtport->assoc_list);
}
+ rcu_read_unlock();
spin_unlock_irqrestore(&tgtport->lock, flags);
}
--
2.43.0