iscsi: Allocate connections array from regular memory

No longer required to allocate from shared memory. No tools
use this anymore.

This removes the final call to the event library from iscsi,
so we also drop that dependency.

Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Change-Id: I41a6877b782cb927d9ac7d206ccd36a8195efc42
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4346
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
Ben Walker 2020-09-23 10:37:48 -07:00 committed by Tomasz Zawadzki
parent ed1b78529d
commit 5ebc93507b
4 changed files with 6 additions and 44 deletions

View File

@ -36,7 +36,6 @@
#include "spdk/endian.h"
#include "spdk/env.h"
#include "spdk/event.h"
#include "spdk/likely.h"
#include "spdk/thread.h"
#include "spdk/queue.h"
@ -62,9 +61,7 @@
memset(&(conn)->portal, 0, sizeof(*(conn)) - \
offsetof(struct spdk_iscsi_conn, portal));
struct spdk_iscsi_conn *g_conns_array = MAP_FAILED;
static int g_conns_array_fd = -1;
static char g_shm_name[64];
static struct spdk_iscsi_conn *g_conns_array = NULL;
static TAILQ_HEAD(, spdk_iscsi_conn) g_free_conns = TAILQ_HEAD_INITIALIZER(g_free_conns);
static TAILQ_HEAD(, spdk_iscsi_conn) g_active_conns = TAILQ_HEAD_INITIALIZER(g_active_conns);
@ -119,58 +116,26 @@ free_conn(struct spdk_iscsi_conn *conn)
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);
}
free(g_conns_array);
}
int initialize_iscsi_conns(void)
{
size_t conns_size = sizeof(struct spdk_iscsi_conn) * MAX_ISCSI_CONNECTIONS;
uint32_t i;
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "spdk_iscsi_init\n");
snprintf(g_shm_name, sizeof(g_shm_name), "/spdk_iscsi_conns.%d", spdk_app_get_shm_id());
g_conns_array_fd = shm_open(g_shm_name, O_RDWR | O_CREAT, 0600);
if (g_conns_array_fd < 0) {
SPDK_ERRLOG("could not shm_open %s\n", g_shm_name);
goto err;
g_conns_array = calloc(MAX_ISCSI_CONNECTIONS, sizeof(struct spdk_iscsi_conn));
if (g_conns_array == NULL) {
return -ENOMEM;
}
if (ftruncate(g_conns_array_fd, conns_size) != 0) {
SPDK_ERRLOG("could not ftruncate\n");
goto err;
}
g_conns_array = mmap(0, conns_size, PROT_READ | PROT_WRITE, MAP_SHARED,
g_conns_array_fd, 0);
if (g_conns_array == MAP_FAILED) {
SPDK_ERRLOG("could not mmap cons array file %s (%d)\n", g_shm_name, errno);
goto err;
}
memset(g_conns_array, 0, conns_size);
for (i = 0; i < MAX_ISCSI_CONNECTIONS; i++) {
g_conns_array[i].id = i;
TAILQ_INSERT_TAIL(&g_free_conns, &g_conns_array[i], conn_link);
}
return 0;
err:
_iscsi_conns_cleanup();
return -1;
}
static void

View File

@ -199,8 +199,6 @@ struct spdk_iscsi_conn {
TAILQ_ENTRY(spdk_iscsi_conn) conn_link;
};
extern struct spdk_iscsi_conn *g_conns_array;
void iscsi_task_cpl(struct spdk_scsi_task *scsi_task);
void iscsi_task_mgmt_cpl(struct spdk_scsi_task *scsi_task);

View File

@ -45,7 +45,6 @@
#include "iscsi/task.h"
#include "iscsi/tgt_node.h"
#include "spdk_internal/event.h"
#include "spdk_internal/log.h"
struct spdk_iscsi_opts *g_spdk_iscsi_opts = NULL;

View File

@ -86,7 +86,7 @@ DEPDIRS-nvmf += rdma
endif
DEPDIRS-scsi := log util thread $(JSON_LIBS) trace bdev
DEPDIRS-iscsi := log sock util conf thread $(JSON_LIBS) trace event scsi
DEPDIRS-iscsi := log sock util conf thread $(JSON_LIBS) trace scsi
DEPDIRS-vhost = log util conf thread $(JSON_LIBS) bdev scsi
ifeq ($(CONFIG_VHOST_INTERNAL_LIB),y)
DEPDIRS-vhost += rte_vhost