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;
|
||||
}
|
||||
|
||||
subsystem->num_sessions++;
|
||||
TAILQ_INSERT_HEAD(&subsystem->sessions, session, entries);
|
||||
|
||||
TAILQ_INIT(&session->connections);
|
||||
session->num_connections = 0;
|
||||
session->subsys = subsystem;
|
||||
@ -193,20 +190,20 @@ nvmf_create_session(const char *subnqn)
|
||||
|
||||
nvmf_init_session_properties(session);
|
||||
|
||||
subsystem->session = session;
|
||||
|
||||
return session;
|
||||
}
|
||||
|
||||
static void
|
||||
nvmf_delete_session(struct nvmf_session *session)
|
||||
{
|
||||
session->subsys->num_sessions--;
|
||||
TAILQ_REMOVE(&session->subsys->sessions, session, entries);
|
||||
|
||||
session->subsys->session = NULL;
|
||||
free(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;
|
||||
|
||||
@ -215,7 +212,7 @@ nvmf_find_session_by_id(const char *subnqn, uint16_t cntl_id)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return TAILQ_FIRST(&subsystem->sessions);
|
||||
return subsystem->session;
|
||||
}
|
||||
|
||||
struct nvmf_session *
|
||||
@ -243,7 +240,7 @@ nvmf_connect(struct spdk_nvmf_conn *conn,
|
||||
}
|
||||
} else {
|
||||
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) {
|
||||
SPDK_ERRLOG("Unknown controller id %d\n", connect_data->cntlid);
|
||||
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->subtype = sub_type;
|
||||
snprintf(subsystem->subnqn, sizeof(subsystem->subnqn), "%s", name);
|
||||
TAILQ_INIT(&subsystem->sessions);
|
||||
|
||||
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
|
||||
nvmf_delete_subsystem(struct spdk_nvmf_subsystem *subsystem)
|
||||
{
|
||||
struct nvmf_session *sess, *tsess;
|
||||
|
||||
if (subsystem == NULL) {
|
||||
SPDK_TRACELOG(SPDK_TRACE_NVMF,
|
||||
"nvmf_delete_subsystem: there is no subsystem\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
TAILQ_FOREACH_SAFE(sess, &subsystem->sessions, entries, tsess) {
|
||||
subsystem->num_sessions--;
|
||||
TAILQ_REMOVE(&subsystem->sessions, sess, entries);
|
||||
free(sess);
|
||||
if (subsystem->session) {
|
||||
/* TODO: Call a session function that closes all connections */
|
||||
free(subsystem->session);
|
||||
}
|
||||
|
||||
TAILQ_REMOVE(&g_subsystems, subsystem, entries);
|
||||
|
@ -50,9 +50,8 @@ struct spdk_nvmf_conn;
|
||||
struct spdk_nvmf_subsystem {
|
||||
uint16_t num;
|
||||
char subnqn[MAX_NQN_SIZE];
|
||||
int num_sessions;
|
||||
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_qpair *io_qpair;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user