lib/iscsi: Reduce critical region during target node shutdown
iSCSI mutex had guarded both unregister operation and destruct operation in a single critical region in spdk_iscsi_shutdown_tgt_nodes and spdk_iscsi_shutdown_tgt_node_by_name. Subsequent patches will separate unregister operation and destruct operation, and so this patch separates critical region of unregister operation and destruct operation. Change-Id: I847915f8277c4475c034ca64fd07ccdd47659590 Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450583 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
907ef2555f
commit
da98b92b92
@ -635,7 +635,10 @@ iscsi_tgt_node_destruct(struct spdk_iscsi_tgt_node *target)
|
||||
|
||||
free(target->name);
|
||||
free(target->alias);
|
||||
|
||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
||||
iscsi_tgt_node_delete_all_pg_maps(target);
|
||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
||||
|
||||
pthread_mutex_destroy(&target->mutex);
|
||||
free(target);
|
||||
@ -1228,12 +1231,18 @@ int spdk_iscsi_parse_tgt_nodes(void)
|
||||
void
|
||||
spdk_iscsi_shutdown_tgt_nodes(void)
|
||||
{
|
||||
struct spdk_iscsi_tgt_node *target, *tmp;
|
||||
struct spdk_iscsi_tgt_node *target;
|
||||
|
||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
||||
TAILQ_FOREACH_SAFE(target, &g_spdk_iscsi.target_head, tailq, tmp) {
|
||||
while (!TAILQ_EMPTY(&g_spdk_iscsi.target_head)) {
|
||||
target = TAILQ_FIRST(&g_spdk_iscsi.target_head);
|
||||
TAILQ_REMOVE(&g_spdk_iscsi.target_head, target, tailq);
|
||||
|
||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
||||
|
||||
iscsi_tgt_node_destruct(target);
|
||||
|
||||
pthread_mutex_lock(&g_spdk_iscsi.mutex);
|
||||
}
|
||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
||||
}
|
||||
@ -1247,9 +1256,10 @@ spdk_iscsi_shutdown_tgt_node_by_name(const char *target_name)
|
||||
target = spdk_iscsi_find_tgt_node(target_name);
|
||||
if (target != NULL) {
|
||||
iscsi_tgt_node_unregister(target);
|
||||
iscsi_tgt_node_destruct(target);
|
||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
||||
|
||||
iscsi_tgt_node_destruct(target);
|
||||
|
||||
return 0;
|
||||
}
|
||||
pthread_mutex_unlock(&g_spdk_iscsi.mutex);
|
||||
|
Loading…
Reference in New Issue
Block a user