nvmf: Add subsystem iterators

Add functions to iterate the list of subsystems for a given
target.

Change-Id: Id3831f656033092224168b353788ae87238bf800
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/388294
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Ben Walker 2017-11-20 11:16:06 -07:00
parent 8b79ef3372
commit 33376dd136
2 changed files with 47 additions and 0 deletions

View File

@ -148,6 +148,16 @@ struct spdk_nvmf_subsystem *spdk_nvmf_create_subsystem(struct spdk_nvmf_tgt *tgt
struct spdk_nvmf_subsystem *spdk_nvmf_tgt_find_subsystem(struct spdk_nvmf_tgt *tgt,
const char *subnqn);
/**
* Begin iterating over all known subsystems. If no subsystems are present, return NULL.
*/
struct spdk_nvmf_subsystem *spdk_nvmf_subsystem_get_first(struct spdk_nvmf_tgt *tgt);
/**
* Continue iterating over all known subsystems. If no additional subsystems, return NULL.
*/
struct spdk_nvmf_subsystem *spdk_nvmf_subsystem_get_next(struct spdk_nvmf_subsystem *subsystem);
void spdk_nvmf_delete_subsystem(struct spdk_nvmf_subsystem *subsystem);
/**

View File

@ -242,6 +242,43 @@ spdk_nvmf_delete_subsystem(struct spdk_nvmf_subsystem *subsystem)
spdk_nvmf_subsystem_delete_done);
}
struct spdk_nvmf_subsystem *
spdk_nvmf_subsystem_get_first(struct spdk_nvmf_tgt *tgt)
{
struct spdk_nvmf_subsystem *subsystem;
uint32_t sid;
for (sid = 0; sid < tgt->max_sid; sid++) {
subsystem = tgt->subsystems[sid];
if (subsystem) {
return subsystem;
}
}
return NULL;
}
struct spdk_nvmf_subsystem *
spdk_nvmf_subsystem_get_next(struct spdk_nvmf_subsystem *subsystem)
{
uint32_t sid;
struct spdk_nvmf_tgt *tgt;
if (!subsystem) {
return NULL;
}
tgt = subsystem->tgt;
for (sid = subsystem->id + 1; sid < tgt->max_sid; sid++) {
subsystem = tgt->subsystems[sid];
if (subsystem) {
return subsystem;
}
}
return NULL;
}
int
spdk_nvmf_subsystem_add_host(struct spdk_nvmf_subsystem *subsystem, const char *hostnqn)