nvmf: spdk_nvmf_find_subsystem now takes a tgt parameter
The user can now specify which target they want to search for the subsystem. Also, change the name to spdk_nvmf_tgt_find_subsystem and put it in the correct compilation unit. Change-Id: I7c085959814c14d8400a0ba2572103b0814a4d0e Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.gerrithub.io/374879 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
4addb5c899
commit
70bc390c82
@ -191,7 +191,7 @@ nvmf_tgt_create_subsystem(const char *name, enum spdk_nvmf_subtype subtype,
|
||||
struct spdk_nvmf_subsystem *subsystem;
|
||||
struct nvmf_tgt_subsystem *app_subsys;
|
||||
|
||||
if (spdk_nvmf_find_subsystem(name)) {
|
||||
if (spdk_nvmf_tgt_find_subsystem(g_tgt, name)) {
|
||||
SPDK_ERRLOG("Subsystem already exist\n");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -105,6 +105,12 @@ struct spdk_nvmf_subsystem *spdk_nvmf_create_subsystem(struct spdk_nvmf_tgt *tgt
|
||||
spdk_nvmf_subsystem_connect_fn connect_cb,
|
||||
spdk_nvmf_subsystem_disconnect_fn disconnect_cb);
|
||||
|
||||
/**
|
||||
* Search the target for a subsystem with the given NQN
|
||||
*/
|
||||
struct spdk_nvmf_subsystem *spdk_nvmf_tgt_find_subsystem(struct spdk_nvmf_tgt *tgt,
|
||||
const char *subnqn);
|
||||
|
||||
/**
|
||||
* Initialize the subsystem on the thread that will be used to poll it.
|
||||
*
|
||||
@ -114,8 +120,6 @@ int spdk_nvmf_subsystem_start(struct spdk_nvmf_subsystem *subsystem);
|
||||
|
||||
void spdk_nvmf_delete_subsystem(struct spdk_nvmf_subsystem *subsystem);
|
||||
|
||||
struct spdk_nvmf_subsystem *spdk_nvmf_find_subsystem(const char *subnqn);
|
||||
|
||||
/**
|
||||
* Allow the given host NQN to connect to the given subsystem.
|
||||
*
|
||||
|
@ -205,6 +205,7 @@ spdk_nvmf_ctrlr_connect(struct spdk_nvmf_qpair *qpair,
|
||||
struct spdk_nvmf_fabric_connect_data *data,
|
||||
struct spdk_nvmf_fabric_connect_rsp *rsp)
|
||||
{
|
||||
struct spdk_nvmf_tgt *tgt;
|
||||
struct spdk_nvmf_ctrlr *ctrlr;
|
||||
struct spdk_nvmf_subsystem *subsystem;
|
||||
|
||||
@ -227,7 +228,9 @@ spdk_nvmf_ctrlr_connect(struct spdk_nvmf_qpair *qpair,
|
||||
SPDK_TRACELOG(SPDK_TRACE_NVMF, " subnqn: \"%s\"\n", data->subnqn);
|
||||
SPDK_TRACELOG(SPDK_TRACE_NVMF, " hostnqn: \"%s\"\n", data->hostnqn);
|
||||
|
||||
subsystem = spdk_nvmf_find_subsystem(data->subnqn);
|
||||
tgt = qpair->transport->tgt;
|
||||
|
||||
subsystem = spdk_nvmf_tgt_find_subsystem(tgt, data->subnqn);
|
||||
if (subsystem == NULL) {
|
||||
SPDK_ERRLOG("Could not find subsystem '%s'\n", data->subnqn);
|
||||
INVALID_CONNECT_DATA(subnqn);
|
||||
@ -238,9 +241,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 >= subsystem->tgt->opts.max_queue_depth) {
|
||||
if (cmd->sqsize == 0 || cmd->sqsize >= tgt->opts.max_queue_depth) {
|
||||
SPDK_ERRLOG("Invalid SQSIZE %u (min 1, max %u)\n",
|
||||
cmd->sqsize, subsystem->tgt->opts.max_queue_depth - 1);
|
||||
cmd->sqsize, tgt->opts.max_queue_depth - 1);
|
||||
INVALID_CONNECT_CMD(sqsize);
|
||||
return;
|
||||
}
|
||||
|
@ -112,6 +112,24 @@ spdk_nvmf_tgt_destroy(struct spdk_nvmf_tgt *tgt)
|
||||
}
|
||||
}
|
||||
|
||||
struct spdk_nvmf_subsystem *
|
||||
spdk_nvmf_tgt_find_subsystem(struct spdk_nvmf_tgt *tgt, const char *subnqn)
|
||||
{
|
||||
struct spdk_nvmf_subsystem *subsystem;
|
||||
|
||||
if (!subnqn) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TAILQ_FOREACH(subsystem, &tgt->subsystems, entries) {
|
||||
if (strcmp(subnqn, subsystem->subnqn) == 0) {
|
||||
return subsystem;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct spdk_nvmf_transport *
|
||||
spdk_nvmf_tgt_get_transport(struct spdk_nvmf_tgt *tgt, enum spdk_nvme_transport_type type)
|
||||
{
|
||||
|
@ -123,6 +123,7 @@ invalid_connect_response(struct spdk_nvmf_fabric_connect_rsp *rsp, uint8_t iattr
|
||||
static spdk_nvmf_request_exec_status
|
||||
nvmf_process_connect(struct spdk_nvmf_request *req)
|
||||
{
|
||||
struct spdk_nvmf_tgt *tgt;
|
||||
struct spdk_nvmf_subsystem *subsystem;
|
||||
struct spdk_nvmf_fabric_connect_data *data = (struct spdk_nvmf_fabric_connect_data *)
|
||||
req->data;
|
||||
@ -160,7 +161,9 @@ nvmf_process_connect(struct spdk_nvmf_request *req)
|
||||
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
|
||||
}
|
||||
|
||||
subsystem = spdk_nvmf_find_subsystem(data->subnqn);
|
||||
tgt = req->qpair->transport->tgt;
|
||||
|
||||
subsystem = spdk_nvmf_tgt_find_subsystem(tgt, data->subnqn);
|
||||
if (subsystem == NULL) {
|
||||
SPDK_ERRLOG("Could not find subsystem '%s'\n", data->subnqn);
|
||||
INVALID_CONNECT_DATA(subnqn);
|
||||
|
@ -46,24 +46,6 @@
|
||||
#include "spdk_internal/bdev.h"
|
||||
#include "spdk_internal/log.h"
|
||||
|
||||
struct spdk_nvmf_subsystem *
|
||||
spdk_nvmf_find_subsystem(const char *subnqn)
|
||||
{
|
||||
struct spdk_nvmf_subsystem *subsystem;
|
||||
|
||||
if (!subnqn) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TAILQ_FOREACH(subsystem, &g_nvmf_tgt.subsystems, entries) {
|
||||
if (strcmp(subnqn, subsystem->subnqn) == 0) {
|
||||
return subsystem;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct spdk_nvmf_subsystem *
|
||||
spdk_nvmf_find_subsystem_with_cntlid(uint16_t cntlid)
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ spdk_nvmf_find_subsystem_with_cntlid(uint16_t cntlid)
|
||||
}
|
||||
|
||||
struct spdk_nvmf_subsystem *
|
||||
spdk_nvmf_find_subsystem(const char *subnqn)
|
||||
spdk_nvmf_tgt_find_subsystem(struct spdk_nvmf_tgt *tgt, const char *subnqn)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ spdk_nvmf_get_discovery_log_page(void *buffer, uint64_t offset, uint32_t length)
|
||||
}
|
||||
|
||||
struct spdk_nvmf_subsystem *
|
||||
spdk_nvmf_find_subsystem(const char *subnqn)
|
||||
spdk_nvmf_tgt_find_subsystem(struct spdk_nvmf_tgt *tgt, const char *subnqn)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
@ -273,13 +273,6 @@ nvmf_test_create_subsystem(void)
|
||||
CU_ASSERT(subsystem == NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
nvmf_test_find_subsystem(void)
|
||||
{
|
||||
CU_ASSERT_PTR_NULL(spdk_nvmf_find_subsystem(NULL));
|
||||
CU_ASSERT_PTR_NULL(spdk_nvmf_find_subsystem("fake"));
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
CU_pSuite suite = NULL;
|
||||
@ -298,8 +291,7 @@ int main(int argc, char **argv)
|
||||
if (
|
||||
CU_add_test(suite, "create_subsystem", nvmf_test_create_subsystem) == NULL ||
|
||||
CU_add_test(suite, "nvmf_tgt_listen", test_spdk_nvmf_tgt_listen) == NULL ||
|
||||
CU_add_test(suite, "nvmf_subsystem_add_ns", test_spdk_nvmf_subsystem_add_ns) == NULL ||
|
||||
CU_add_test(suite, "find_subsystem", nvmf_test_find_subsystem) == NULL) {
|
||||
CU_add_test(suite, "nvmf_subsystem_add_ns", test_spdk_nvmf_subsystem_add_ns) == NULL) {
|
||||
CU_cleanup_registry();
|
||||
return CU_get_error();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user