nvmf: Add a pointer to the target to the subsystem
This eliminates a couple of references to g_nvmf_tgt and sets the stage for eliminating that global entirely in the future. Change-Id: I068d0874cc8ba122be780e8dbd55bb1efabe10b7 Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.gerrithub.io/374876 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
d868cd0895
commit
02b640bfdf
@ -59,7 +59,10 @@ spdk_nvmf_ctrlr_create(struct spdk_nvmf_subsystem *subsystem,
|
||||
struct spdk_nvmf_fabric_connect_cmd *connect_cmd,
|
||||
struct spdk_nvmf_fabric_connect_data *connect_data)
|
||||
{
|
||||
struct spdk_nvmf_ctrlr *ctrlr;
|
||||
struct spdk_nvmf_ctrlr *ctrlr;
|
||||
struct spdk_nvmf_tgt *tgt;
|
||||
|
||||
tgt = subsystem->tgt;
|
||||
|
||||
ctrlr = calloc(1, sizeof(*ctrlr));
|
||||
if (ctrlr == NULL) {
|
||||
@ -88,7 +91,7 @@ spdk_nvmf_ctrlr_create(struct spdk_nvmf_subsystem *subsystem,
|
||||
ctrlr->async_event_config.raw = 0;
|
||||
ctrlr->num_qpairs = 0;
|
||||
ctrlr->subsys = subsystem;
|
||||
ctrlr->max_qpairs_allowed = g_nvmf_tgt.opts.max_qpairs_per_ctrlr;
|
||||
ctrlr->max_qpairs_allowed = tgt->opts.max_qpairs_per_ctrlr;
|
||||
|
||||
memcpy(ctrlr->hostid, connect_data->hostid, sizeof(ctrlr->hostid));
|
||||
|
||||
@ -100,7 +103,7 @@ spdk_nvmf_ctrlr_create(struct spdk_nvmf_subsystem *subsystem,
|
||||
|
||||
ctrlr->vcprop.cap.raw = 0;
|
||||
ctrlr->vcprop.cap.bits.cqr = 1; /* NVMe-oF specification required */
|
||||
ctrlr->vcprop.cap.bits.mqes = g_nvmf_tgt.opts.max_queue_depth - 1; /* max queue depth */
|
||||
ctrlr->vcprop.cap.bits.mqes = tgt->opts.max_queue_depth - 1; /* max queue depth */
|
||||
ctrlr->vcprop.cap.bits.ams = 0; /* optional arb mechanisms */
|
||||
ctrlr->vcprop.cap.bits.to = 1; /* ready timeout - 500 msec units */
|
||||
ctrlr->vcprop.cap.bits.dstrd = 0; /* fixed to 0 for NVMe-oF */
|
||||
@ -235,9 +238,9 @@ spdk_nvmf_ctrlr_connect(struct spdk_nvmf_qpair *qpair,
|
||||
* SQSIZE is a 0-based value, so it must be at least 1 (minimum queue depth is 2) and
|
||||
* strictly less than max_queue_depth.
|
||||
*/
|
||||
if (cmd->sqsize == 0 || cmd->sqsize >= g_nvmf_tgt.opts.max_queue_depth) {
|
||||
if (cmd->sqsize == 0 || cmd->sqsize >= subsystem->tgt->opts.max_queue_depth) {
|
||||
SPDK_ERRLOG("Invalid SQSIZE %u (min 1, max %u)\n",
|
||||
cmd->sqsize, g_nvmf_tgt.opts.max_queue_depth - 1);
|
||||
cmd->sqsize, subsystem->tgt->opts.max_queue_depth - 1);
|
||||
INVALID_CONNECT_CMD(sqsize);
|
||||
return;
|
||||
}
|
||||
|
@ -86,6 +86,8 @@ struct spdk_nvmf_subsystem {
|
||||
enum spdk_nvmf_subtype subtype;
|
||||
bool is_removed;
|
||||
|
||||
struct spdk_nvmf_tgt *tgt;
|
||||
|
||||
char sn[MAX_SN_LEN + 1];
|
||||
|
||||
struct spdk_nvmf_ns ns[MAX_VIRTUAL_NAMESPACE];
|
||||
|
@ -165,9 +165,11 @@ spdk_nvmf_create_subsystem(const char *nqn,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
g_nvmf_tgt.current_subsystem_id++;
|
||||
subsystem->tgt = &g_nvmf_tgt;
|
||||
|
||||
subsystem->id = g_nvmf_tgt.current_subsystem_id;
|
||||
subsystem->tgt->current_subsystem_id++;
|
||||
|
||||
subsystem->id = subsystem->tgt->current_subsystem_id;
|
||||
subsystem->subtype = type;
|
||||
subsystem->cb_ctx = cb_ctx;
|
||||
subsystem->connect_cb = connect_cb;
|
||||
@ -177,8 +179,8 @@ spdk_nvmf_create_subsystem(const char *nqn,
|
||||
TAILQ_INIT(&subsystem->hosts);
|
||||
TAILQ_INIT(&subsystem->ctrlrs);
|
||||
|
||||
TAILQ_INSERT_TAIL(&g_nvmf_tgt.subsystems, subsystem, entries);
|
||||
g_nvmf_tgt.discovery_genctr++;
|
||||
TAILQ_INSERT_TAIL(&subsystem->tgt->subsystems, subsystem, entries);
|
||||
subsystem->tgt->discovery_genctr++;
|
||||
|
||||
return subsystem;
|
||||
}
|
||||
@ -213,8 +215,8 @@ spdk_nvmf_delete_subsystem(struct spdk_nvmf_subsystem *subsystem)
|
||||
|
||||
spdk_nvmf_subsystem_bdev_detach(subsystem);
|
||||
|
||||
TAILQ_REMOVE(&g_nvmf_tgt.subsystems, subsystem, entries);
|
||||
g_nvmf_tgt.discovery_genctr++;
|
||||
TAILQ_REMOVE(&subsystem->tgt->subsystems, subsystem, entries);
|
||||
subsystem->tgt->discovery_genctr++;
|
||||
|
||||
free(subsystem);
|
||||
}
|
||||
@ -240,7 +242,7 @@ spdk_nvmf_subsystem_add_host(struct spdk_nvmf_subsystem *subsystem, const char *
|
||||
}
|
||||
|
||||
TAILQ_INSERT_HEAD(&subsystem->hosts, host, link);
|
||||
g_nvmf_tgt.discovery_genctr++;
|
||||
subsystem->tgt->discovery_genctr++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user