iscsi: add a cleanup utility function
Added a utility function for the cleanup related operations. Change-Id: I4e49dd9c2da899a5bda289bc36778b636af9c5df Signed-off-by: GangCao <gang.cao@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456599 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
0668025839
commit
9a73633190
@ -114,6 +114,22 @@ find_iscsi_connection_by_id(int cid)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_iscsi_conns_cleanup(void)
|
||||
{
|
||||
if (g_conns_array != MAP_FAILED) {
|
||||
munmap(g_conns_array, sizeof(struct spdk_iscsi_conn) *
|
||||
MAX_ISCSI_CONNECTIONS);
|
||||
g_conns_array = MAP_FAILED;
|
||||
}
|
||||
|
||||
if (g_conns_array_fd >= 0) {
|
||||
close(g_conns_array_fd);
|
||||
g_conns_array_fd = -1;
|
||||
shm_unlink(g_shm_name);
|
||||
}
|
||||
}
|
||||
|
||||
int spdk_initialize_iscsi_conns(void)
|
||||
{
|
||||
size_t conns_size = sizeof(struct spdk_iscsi_conn) * MAX_ISCSI_CONNECTIONS;
|
||||
@ -149,16 +165,7 @@ int spdk_initialize_iscsi_conns(void)
|
||||
return 0;
|
||||
|
||||
err:
|
||||
if (g_conns_array != MAP_FAILED) {
|
||||
munmap(g_conns_array, conns_size);
|
||||
g_conns_array = MAP_FAILED;
|
||||
}
|
||||
|
||||
if (g_conns_array_fd >= 0) {
|
||||
close(g_conns_array_fd);
|
||||
g_conns_array_fd = -1;
|
||||
shm_unlink(g_shm_name);
|
||||
}
|
||||
_iscsi_conns_cleanup();
|
||||
|
||||
return -1;
|
||||
}
|
||||
@ -552,23 +559,10 @@ spdk_iscsi_get_active_conns(struct spdk_iscsi_tgt_node *target)
|
||||
return num;
|
||||
}
|
||||
|
||||
static void
|
||||
iscsi_conns_cleanup(void)
|
||||
{
|
||||
munmap(g_conns_array, sizeof(struct spdk_iscsi_conn) *
|
||||
MAX_ISCSI_CONNECTIONS);
|
||||
g_conns_array = MAP_FAILED;
|
||||
shm_unlink(g_shm_name);
|
||||
if (g_conns_array_fd >= 0) {
|
||||
close(g_conns_array_fd);
|
||||
g_conns_array_fd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
iscsi_conn_check_shutdown_cb(void *arg1)
|
||||
{
|
||||
iscsi_conns_cleanup();
|
||||
_iscsi_conns_cleanup();
|
||||
spdk_shutdown_iscsi_conns_done();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user