nvmf: Subsystem now has a pointer to the session
There is only one controller per subsystem, so therefore there can be 0 or 1 sessions. Change the list of sessions to a pointer that can be NULL if no session exists. Change-Id: I2c0d042d9cecacae93da3e806093faf0155ddd6e Signed-off-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
40b0248602
commit
1fc4a182bd
@ -183,9 +183,6 @@ nvmf_create_session(const char *subnqn)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
subsystem->num_sessions++;
|
|
||||||
TAILQ_INSERT_HEAD(&subsystem->sessions, session, entries);
|
|
||||||
|
|
||||||
TAILQ_INIT(&session->connections);
|
TAILQ_INIT(&session->connections);
|
||||||
session->num_connections = 0;
|
session->num_connections = 0;
|
||||||
session->subsys = subsystem;
|
session->subsys = subsystem;
|
||||||
@ -193,20 +190,20 @@ nvmf_create_session(const char *subnqn)
|
|||||||
|
|
||||||
nvmf_init_session_properties(session);
|
nvmf_init_session_properties(session);
|
||||||
|
|
||||||
|
subsystem->session = session;
|
||||||
|
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nvmf_delete_session(struct nvmf_session *session)
|
nvmf_delete_session(struct nvmf_session *session)
|
||||||
{
|
{
|
||||||
session->subsys->num_sessions--;
|
session->subsys->session = NULL;
|
||||||
TAILQ_REMOVE(&session->subsys->sessions, session, entries);
|
|
||||||
|
|
||||||
free(session);
|
free(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct nvmf_session *
|
static struct nvmf_session *
|
||||||
nvmf_find_session_by_id(const char *subnqn, uint16_t cntl_id)
|
nvmf_find_session(const char *subnqn)
|
||||||
{
|
{
|
||||||
struct spdk_nvmf_subsystem *subsystem;
|
struct spdk_nvmf_subsystem *subsystem;
|
||||||
|
|
||||||
@ -215,7 +212,7 @@ nvmf_find_session_by_id(const char *subnqn, uint16_t cntl_id)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TAILQ_FIRST(&subsystem->sessions);
|
return subsystem->session;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct nvmf_session *
|
struct nvmf_session *
|
||||||
@ -243,7 +240,7 @@ nvmf_connect(struct spdk_nvmf_conn *conn,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SPDK_TRACELOG(SPDK_TRACE_NVMF, "CONNECT I/O Queue for controller id %d\n", connect_data->cntlid);
|
SPDK_TRACELOG(SPDK_TRACE_NVMF, "CONNECT I/O Queue for controller id %d\n", connect_data->cntlid);
|
||||||
session = nvmf_find_session_by_id(connect_data->subnqn, connect_data->cntlid);
|
session = nvmf_find_session(connect_data->subnqn);
|
||||||
if (session == NULL) {
|
if (session == NULL) {
|
||||||
SPDK_ERRLOG("Unknown controller id %d\n", connect_data->cntlid);
|
SPDK_ERRLOG("Unknown controller id %d\n", connect_data->cntlid);
|
||||||
response->status.sc = SPDK_NVMF_FABRIC_SC_RESTART_DISCOVERY;
|
response->status.sc = SPDK_NVMF_FABRIC_SC_RESTART_DISCOVERY;
|
||||||
|
@ -85,7 +85,6 @@ nvmf_create_subsystem(int num, char *name, enum spdk_nvmf_subsystem_types sub_ty
|
|||||||
subsystem->num = num;
|
subsystem->num = num;
|
||||||
subsystem->subtype = sub_type;
|
subsystem->subtype = sub_type;
|
||||||
snprintf(subsystem->subnqn, sizeof(subsystem->subnqn), "%s", name);
|
snprintf(subsystem->subnqn, sizeof(subsystem->subnqn), "%s", name);
|
||||||
TAILQ_INIT(&subsystem->sessions);
|
|
||||||
|
|
||||||
TAILQ_INSERT_HEAD(&g_subsystems, subsystem, entries);
|
TAILQ_INSERT_HEAD(&g_subsystems, subsystem, entries);
|
||||||
|
|
||||||
@ -95,18 +94,15 @@ nvmf_create_subsystem(int num, char *name, enum spdk_nvmf_subsystem_types sub_ty
|
|||||||
int
|
int
|
||||||
nvmf_delete_subsystem(struct spdk_nvmf_subsystem *subsystem)
|
nvmf_delete_subsystem(struct spdk_nvmf_subsystem *subsystem)
|
||||||
{
|
{
|
||||||
struct nvmf_session *sess, *tsess;
|
|
||||||
|
|
||||||
if (subsystem == NULL) {
|
if (subsystem == NULL) {
|
||||||
SPDK_TRACELOG(SPDK_TRACE_NVMF,
|
SPDK_TRACELOG(SPDK_TRACE_NVMF,
|
||||||
"nvmf_delete_subsystem: there is no subsystem\n");
|
"nvmf_delete_subsystem: there is no subsystem\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TAILQ_FOREACH_SAFE(sess, &subsystem->sessions, entries, tsess) {
|
if (subsystem->session) {
|
||||||
subsystem->num_sessions--;
|
/* TODO: Call a session function that closes all connections */
|
||||||
TAILQ_REMOVE(&subsystem->sessions, sess, entries);
|
free(subsystem->session);
|
||||||
free(sess);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TAILQ_REMOVE(&g_subsystems, subsystem, entries);
|
TAILQ_REMOVE(&g_subsystems, subsystem, entries);
|
||||||
|
@ -50,9 +50,8 @@ struct spdk_nvmf_conn;
|
|||||||
struct spdk_nvmf_subsystem {
|
struct spdk_nvmf_subsystem {
|
||||||
uint16_t num;
|
uint16_t num;
|
||||||
char subnqn[MAX_NQN_SIZE];
|
char subnqn[MAX_NQN_SIZE];
|
||||||
int num_sessions;
|
|
||||||
enum spdk_nvmf_subsystem_types subtype;
|
enum spdk_nvmf_subsystem_types subtype;
|
||||||
TAILQ_HEAD(session_q, nvmf_session) sessions;
|
struct nvmf_session *session;
|
||||||
struct spdk_nvme_ctrlr *ctrlr;
|
struct spdk_nvme_ctrlr *ctrlr;
|
||||||
struct spdk_nvme_qpair *io_qpair;
|
struct spdk_nvme_qpair *io_qpair;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user