nvmf: Eliminate two stage initialization of sessions
Everything can be done when the session is created. Change-Id: I7cb38c093b2b1b69460cabba465828eed0cec432 Signed-off-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
49441a5835
commit
d028fb6956
@ -302,14 +302,6 @@ void spdk_shutdown_nvmf_conns(void)
|
||||
rte_get_master_lcore(), spdk_nvmf_conn_check_shutdown, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
nvmf_init_conn_properites(struct spdk_nvmf_conn *conn,
|
||||
struct nvmf_session *session,
|
||||
struct spdk_nvmf_fabric_connect_rsp *response)
|
||||
{
|
||||
nvmf_init_session_properties(session);
|
||||
}
|
||||
|
||||
static void
|
||||
spdk_nvmf_conn_do_work(void *arg)
|
||||
{
|
||||
|
@ -79,11 +79,6 @@ void spdk_shutdown_nvmf_conns(void);
|
||||
struct spdk_nvmf_conn *
|
||||
spdk_nvmf_allocate_conn(void);
|
||||
|
||||
void
|
||||
nvmf_init_conn_properites(struct spdk_nvmf_conn *conn,
|
||||
struct nvmf_session *session,
|
||||
struct spdk_nvmf_fabric_connect_rsp *response);
|
||||
|
||||
int spdk_nvmf_startup_conn(struct spdk_nvmf_conn *conn);
|
||||
|
||||
#endif /* NVMF_CONN_H */
|
||||
|
@ -403,7 +403,6 @@ nvmf_process_connect(struct spdk_nvmf_request *req)
|
||||
struct spdk_nvmf_fabric_connect_data *connect_data;
|
||||
struct spdk_nvmf_fabric_connect_rsp *response;
|
||||
struct spdk_nvmf_conn *conn = req->conn;
|
||||
struct nvmf_session *session;
|
||||
|
||||
if (req->length < sizeof(struct spdk_nvmf_fabric_connect_data)) {
|
||||
SPDK_ERRLOG("Connect command data length 0x%x too small\n", req->length);
|
||||
@ -441,12 +440,11 @@ nvmf_process_connect(struct spdk_nvmf_request *req)
|
||||
conn->type = CONN_TYPE_AQ;
|
||||
}
|
||||
|
||||
session = nvmf_connect(conn, connect, connect_data, response);
|
||||
if (session != NULL) {
|
||||
conn->sess = session;
|
||||
if (conn->type == CONN_TYPE_AQ) {
|
||||
nvmf_init_conn_properites(conn, session, response);
|
||||
}
|
||||
conn->sess = nvmf_connect(conn, connect, connect_data, response);
|
||||
if (!conn->sess) {
|
||||
SPDK_ERRLOG("Unable to allocate session\n");
|
||||
req->rsp->nvme_cpl.status.sc = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Allocate RDMA reqs according to the queue depth and conn type*/
|
||||
|
@ -40,48 +40,6 @@
|
||||
#include "spdk/trace.h"
|
||||
#include "spdk/nvme_spec.h"
|
||||
|
||||
static struct nvmf_session *
|
||||
nvmf_create_session(const char *subnqn)
|
||||
{
|
||||
struct nvmf_session *session;
|
||||
struct spdk_nvmf_subsystem *subsystem;
|
||||
|
||||
SPDK_TRACELOG(SPDK_TRACE_NVMF, "nvmf_create_session:\n");
|
||||
|
||||
/* locate the previously provisioned subsystem */
|
||||
subsystem = nvmf_find_subsystem(subnqn);
|
||||
if (subsystem == NULL)
|
||||
return NULL;
|
||||
|
||||
session = calloc(1, sizeof(struct nvmf_session));
|
||||
if (session == NULL)
|
||||
goto exit;
|
||||
|
||||
subsystem->num_sessions++;
|
||||
session->cntlid = 0; /* Subsystems only have one controller by design, so cntlid is 0 */
|
||||
TAILQ_INSERT_HEAD(&subsystem->sessions, session, entries);
|
||||
|
||||
SPDK_TRACELOG(SPDK_TRACE_NVMF, "nvmf_create_session: allocated session cntlid %d\n",
|
||||
session->cntlid);
|
||||
TAILQ_INIT(&session->connections);
|
||||
session->num_connections = 0;
|
||||
session->is_valid = 1;
|
||||
session->subsys = subsystem;
|
||||
session->max_connections_allowed = g_nvmf_tgt.MaxConnectionsPerSession;
|
||||
|
||||
exit:
|
||||
return session;
|
||||
}
|
||||
|
||||
static void
|
||||
nvmf_delete_session(struct nvmf_session *session)
|
||||
{
|
||||
session->subsys->num_sessions--;
|
||||
TAILQ_REMOVE(&session->subsys->sessions, session, entries);
|
||||
|
||||
free(session);
|
||||
}
|
||||
|
||||
static void
|
||||
nvmf_init_discovery_session_properties(struct nvmf_session *session)
|
||||
{
|
||||
@ -202,7 +160,7 @@ nvmf_init_nvme_session_properties(struct nvmf_session *session)
|
||||
session->vcprop.csts.raw);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
nvmf_init_session_properties(struct nvmf_session *session)
|
||||
{
|
||||
if (session->subsys->subtype == SPDK_NVMF_SUB_NVME) {
|
||||
@ -212,6 +170,51 @@ nvmf_init_session_properties(struct nvmf_session *session)
|
||||
}
|
||||
}
|
||||
|
||||
static struct nvmf_session *
|
||||
nvmf_create_session(const char *subnqn)
|
||||
{
|
||||
struct nvmf_session *session;
|
||||
struct spdk_nvmf_subsystem *subsystem;
|
||||
|
||||
SPDK_TRACELOG(SPDK_TRACE_NVMF, "nvmf_create_session:\n");
|
||||
|
||||
/* locate the previously provisioned subsystem */
|
||||
subsystem = nvmf_find_subsystem(subnqn);
|
||||
if (subsystem == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
session = calloc(1, sizeof(struct nvmf_session));
|
||||
if (session == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
subsystem->num_sessions++;
|
||||
session->cntlid = 0; /* Subsystems only have one controller by design, so cntlid is 0 */
|
||||
TAILQ_INSERT_HEAD(&subsystem->sessions, session, entries);
|
||||
|
||||
SPDK_TRACELOG(SPDK_TRACE_NVMF, "nvmf_create_session: allocated session cntlid %d\n",
|
||||
session->cntlid);
|
||||
TAILQ_INIT(&session->connections);
|
||||
session->num_connections = 0;
|
||||
session->is_valid = 1;
|
||||
session->subsys = subsystem;
|
||||
session->max_connections_allowed = g_nvmf_tgt.MaxConnectionsPerSession;
|
||||
|
||||
nvmf_init_session_properties(session);
|
||||
|
||||
return session;
|
||||
}
|
||||
|
||||
static void
|
||||
nvmf_delete_session(struct nvmf_session *session)
|
||||
{
|
||||
session->subsys->num_sessions--;
|
||||
TAILQ_REMOVE(&session->subsys->sessions, session, entries);
|
||||
|
||||
free(session);
|
||||
}
|
||||
|
||||
static struct nvmf_session *
|
||||
nvmf_find_session_by_id(const char *subnqn, uint16_t cntl_id)
|
||||
{
|
||||
|
@ -83,9 +83,6 @@ nvmf_connect(struct spdk_nvmf_conn *conn,
|
||||
void
|
||||
nvmf_disconnect(struct nvmf_session *session, struct spdk_nvmf_conn *conn);
|
||||
|
||||
void
|
||||
nvmf_init_session_properties(struct nvmf_session *session);
|
||||
|
||||
void
|
||||
nvmf_property_get(struct nvmf_session *session,
|
||||
struct spdk_nvmf_fabric_prop_get_cmd *cmd,
|
||||
|
Loading…
Reference in New Issue
Block a user