Commit db67bb39 authored by Daniel Wagner's avatar Daniel Wagner Committed by Keith Busch

nvmet-fc: move RCU read lock to nvmet_fc_assoc_exists

The RCU lock is only needed for the lookup loop and not for
list_ad_tail_rcu call. Thus move it down the call chain into
nvmet_fc_assoc_exists.

While at it also fix the name typo of the function.
Signed-off-by: default avatarDaniel Wagner <dwagner@suse.de>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarKeith Busch <kbusch@kernel.org>
parent 95409e27
...@@ -1115,16 +1115,21 @@ nvmet_fc_schedule_delete_assoc(struct nvmet_fc_tgt_assoc *assoc) ...@@ -1115,16 +1115,21 @@ nvmet_fc_schedule_delete_assoc(struct nvmet_fc_tgt_assoc *assoc)
} }
static bool static bool
nvmet_fc_assoc_exits(struct nvmet_fc_tgtport *tgtport, u64 association_id) nvmet_fc_assoc_exists(struct nvmet_fc_tgtport *tgtport, u64 association_id)
{ {
struct nvmet_fc_tgt_assoc *a; struct nvmet_fc_tgt_assoc *a;
bool found = false;
rcu_read_lock();
list_for_each_entry_rcu(a, &tgtport->assoc_list, a_list) { list_for_each_entry_rcu(a, &tgtport->assoc_list, a_list) {
if (association_id == a->association_id) if (association_id == a->association_id) {
return true; found = true;
break;
}
} }
rcu_read_unlock();
return false; return found;
} }
static struct nvmet_fc_tgt_assoc * static struct nvmet_fc_tgt_assoc *
...@@ -1164,13 +1169,11 @@ nvmet_fc_alloc_target_assoc(struct nvmet_fc_tgtport *tgtport, void *hosthandle) ...@@ -1164,13 +1169,11 @@ nvmet_fc_alloc_target_assoc(struct nvmet_fc_tgtport *tgtport, void *hosthandle)
ran = ran << BYTES_FOR_QID_SHIFT; ran = ran << BYTES_FOR_QID_SHIFT;
spin_lock_irqsave(&tgtport->lock, flags); spin_lock_irqsave(&tgtport->lock, flags);
rcu_read_lock(); if (!nvmet_fc_assoc_exists(tgtport, ran)) {
if (!nvmet_fc_assoc_exits(tgtport, ran)) {
assoc->association_id = ran; assoc->association_id = ran;
list_add_tail_rcu(&assoc->a_list, &tgtport->assoc_list); list_add_tail_rcu(&assoc->a_list, &tgtport->assoc_list);
done = true; done = true;
} }
rcu_read_unlock();
spin_unlock_irqrestore(&tgtport->lock, flags); spin_unlock_irqrestore(&tgtport->lock, flags);
} while (!done); } while (!done);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment