Skip to content

Commit db67bb3

Browse files
igawkeithbusch
authored andcommitted
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: Daniel Wagner <dwagner@suse.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Keith Busch <kbusch@kernel.org>
1 parent 95409e2 commit db67bb3

File tree

1 file changed

+10
-7
lines changed
  • drivers/nvme/target

1 file changed

+10
-7
lines changed

drivers/nvme/target/fc.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,16 +1115,21 @@ nvmet_fc_schedule_delete_assoc(struct nvmet_fc_tgt_assoc *assoc)
11151115
}
11161116

11171117
static bool
1118-
nvmet_fc_assoc_exits(struct nvmet_fc_tgtport *tgtport, u64 association_id)
1118+
nvmet_fc_assoc_exists(struct nvmet_fc_tgtport *tgtport, u64 association_id)
11191119
{
11201120
struct nvmet_fc_tgt_assoc *a;
1121+
bool found = false;
11211122

1123+
rcu_read_lock();
11221124
list_for_each_entry_rcu(a, &tgtport->assoc_list, a_list) {
1123-
if (association_id == a->association_id)
1124-
return true;
1125+
if (association_id == a->association_id) {
1126+
found = true;
1127+
break;
1128+
}
11251129
}
1130+
rcu_read_unlock();
11261131

1127-
return false;
1132+
return found;
11281133
}
11291134

11301135
static struct nvmet_fc_tgt_assoc *
@@ -1164,13 +1169,11 @@ nvmet_fc_alloc_target_assoc(struct nvmet_fc_tgtport *tgtport, void *hosthandle)
11641169
ran = ran << BYTES_FOR_QID_SHIFT;
11651170

11661171
spin_lock_irqsave(&tgtport->lock, flags);
1167-
rcu_read_lock();
1168-
if (!nvmet_fc_assoc_exits(tgtport, ran)) {
1172+
if (!nvmet_fc_assoc_exists(tgtport, ran)) {
11691173
assoc->association_id = ran;
11701174
list_add_tail_rcu(&assoc->a_list, &tgtport->assoc_list);
11711175
done = true;
11721176
}
1173-
rcu_read_unlock();
11741177
spin_unlock_irqrestore(&tgtport->lock, flags);
11751178
} while (!done);
11761179

0 commit comments

Comments
 (0)