[PATCH v4 12/12] nvmet-fc: use RCU list iterator for assoc_list
Daniel Wagner
dwagner at suse.de
Tue Jan 30 01:49:38 PST 2024
The assoc_list is a RCU protected list, thus use the RCU flavor of list
functions.
Signed-off-by: Daniel Wagner <dwagner at suse.de>
---
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
More information about the Linux-nvme
mailing list