nvmf: factor out namespace change helper function
Change-Id: Iaeaf308bc2135cf94a3e1fd94c3c5d56f8a2f86e Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-on: https://review.gerrithub.io/405130 Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
parent
763ab88884
commit
0f15edee2d
@ -810,11 +810,20 @@ spdk_nvmf_listener_get_trid(struct spdk_nvmf_listener *listener)
|
|||||||
return &listener->trid;
|
return &listener->trid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
spdk_nvmf_subsystem_ns_changed(struct spdk_nvmf_subsystem *subsystem, uint32_t nsid)
|
||||||
|
{
|
||||||
|
struct spdk_nvmf_ctrlr *ctrlr;
|
||||||
|
|
||||||
|
TAILQ_FOREACH(ctrlr, &subsystem->ctrlrs, link) {
|
||||||
|
spdk_nvmf_ctrlr_async_event_ns_notice(ctrlr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
spdk_nvmf_subsystem_remove_ns(struct spdk_nvmf_subsystem *subsystem, uint32_t nsid)
|
spdk_nvmf_subsystem_remove_ns(struct spdk_nvmf_subsystem *subsystem, uint32_t nsid)
|
||||||
{
|
{
|
||||||
struct spdk_nvmf_ns *ns;
|
struct spdk_nvmf_ns *ns;
|
||||||
struct spdk_nvmf_ctrlr *ctrlr, *ctrlr_tmp;
|
|
||||||
|
|
||||||
assert(subsystem->state == SPDK_NVMF_SUBSYSTEM_PAUSED ||
|
assert(subsystem->state == SPDK_NVMF_SUBSYSTEM_PAUSED ||
|
||||||
subsystem->state == SPDK_NVMF_SUBSYSTEM_INACTIVE);
|
subsystem->state == SPDK_NVMF_SUBSYSTEM_INACTIVE);
|
||||||
@ -839,9 +848,7 @@ spdk_nvmf_subsystem_remove_ns(struct spdk_nvmf_subsystem *subsystem, uint32_t ns
|
|||||||
free(ns);
|
free(ns);
|
||||||
subsystem->num_allocated_nsid--;
|
subsystem->num_allocated_nsid--;
|
||||||
|
|
||||||
TAILQ_FOREACH_SAFE(ctrlr, &subsystem->ctrlrs, link, ctrlr_tmp) {
|
spdk_nvmf_subsystem_ns_changed(subsystem, nsid);
|
||||||
spdk_nvmf_ctrlr_async_event_ns_notice(ctrlr);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -882,7 +889,6 @@ spdk_nvmf_subsystem_add_ns(struct spdk_nvmf_subsystem *subsystem, struct spdk_bd
|
|||||||
{
|
{
|
||||||
struct spdk_nvmf_ns_opts opts;
|
struct spdk_nvmf_ns_opts opts;
|
||||||
struct spdk_nvmf_ns *ns;
|
struct spdk_nvmf_ns *ns;
|
||||||
struct spdk_nvmf_ctrlr *ctrlr, *ctrlr_tmp;
|
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
@ -971,10 +977,6 @@ spdk_nvmf_subsystem_add_ns(struct spdk_nvmf_subsystem *subsystem, struct spdk_bd
|
|||||||
}
|
}
|
||||||
subsystem->ns[opts.nsid - 1] = ns;
|
subsystem->ns[opts.nsid - 1] = ns;
|
||||||
|
|
||||||
TAILQ_FOREACH_SAFE(ctrlr, &subsystem->ctrlrs, link, ctrlr_tmp) {
|
|
||||||
spdk_nvmf_ctrlr_async_event_ns_notice(ctrlr);
|
|
||||||
}
|
|
||||||
|
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_NVMF, "Subsystem %s: bdev %s assigned nsid %" PRIu32 "\n",
|
SPDK_DEBUGLOG(SPDK_LOG_NVMF, "Subsystem %s: bdev %s assigned nsid %" PRIu32 "\n",
|
||||||
spdk_nvmf_subsystem_get_nqn(subsystem),
|
spdk_nvmf_subsystem_get_nqn(subsystem),
|
||||||
spdk_bdev_get_name(bdev),
|
spdk_bdev_get_name(bdev),
|
||||||
@ -983,6 +985,8 @@ spdk_nvmf_subsystem_add_ns(struct spdk_nvmf_subsystem *subsystem, struct spdk_bd
|
|||||||
subsystem->max_nsid = spdk_max(subsystem->max_nsid, opts.nsid);
|
subsystem->max_nsid = spdk_max(subsystem->max_nsid, opts.nsid);
|
||||||
subsystem->num_allocated_nsid++;
|
subsystem->num_allocated_nsid++;
|
||||||
|
|
||||||
|
spdk_nvmf_subsystem_ns_changed(subsystem, opts.nsid);
|
||||||
|
|
||||||
return opts.nsid;
|
return opts.nsid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user