Skip to content

Commit

Permalink
bdev/nvme: rename ctrlr trid parameter to connected_trid
Browse files Browse the repository at this point in the history
This patch paves the way for introducing a tailq containing
multiple alternative paths to the same controller.

Change-Id: I13d30c12b8e0ce38eae687f9e76740be1d11e4d1
Signed-off-by: Seth Howell <[email protected]>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3259
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <[email protected]>
Reviewed-by: Jim Harris <[email protected]>
Reviewed-by: Paul Luse <[email protected]>
Reviewed-by: Aleksey Marchuk <[email protected]>
Reviewed-by: Shuhei Matsumoto <[email protected]>
Reviewed-by: Ben Walker <[email protected]>
  • Loading branch information
Seth5141 authored and jimharris committed Aug 7, 2020
1 parent a4b5041 commit d88915f
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 28 deletions.
42 changes: 21 additions & 21 deletions module/bdev/nvme/bdev_nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -852,13 +852,13 @@ bdev_nvme_dump_info_json(void *ctx, struct spdk_json_write_ctx *w)

spdk_json_write_named_object_begin(w, "nvme");

if (nvme_bdev_ctrlr->trid->trtype == SPDK_NVME_TRANSPORT_PCIE) {
spdk_json_write_named_string(w, "pci_address", nvme_bdev_ctrlr->trid->traddr);
if (nvme_bdev_ctrlr->connected_trid->trtype == SPDK_NVME_TRANSPORT_PCIE) {
spdk_json_write_named_string(w, "pci_address", nvme_bdev_ctrlr->connected_trid->traddr);
}

spdk_json_write_named_object_begin(w, "trid");

nvme_bdev_dump_trid_json(nvme_bdev_ctrlr->trid, w);
nvme_bdev_dump_trid_json(nvme_bdev_ctrlr->connected_trid, w);

spdk_json_write_object_end(w);

Expand Down Expand Up @@ -1370,8 +1370,8 @@ create_ctrlr(struct spdk_nvme_ctrlr *ctrlr,
return -ENOMEM;
}

nvme_bdev_ctrlr->trid = calloc(1, sizeof(*nvme_bdev_ctrlr->trid));
if (nvme_bdev_ctrlr->trid == NULL) {
nvme_bdev_ctrlr->connected_trid = calloc(1, sizeof(*nvme_bdev_ctrlr->connected_trid));
if (nvme_bdev_ctrlr->connected_trid == NULL) {
SPDK_ERRLOG("Failed to allocate device trid struct\n");
free(nvme_bdev_ctrlr);
return -ENOMEM;
Expand All @@ -1381,7 +1381,7 @@ create_ctrlr(struct spdk_nvme_ctrlr *ctrlr,
nvme_bdev_ctrlr->namespaces = calloc(nvme_bdev_ctrlr->num_ns, sizeof(struct nvme_bdev_ns *));
if (!nvme_bdev_ctrlr->namespaces) {
SPDK_ERRLOG("Failed to allocate block namespaces pointer\n");
free(nvme_bdev_ctrlr->trid);
free(nvme_bdev_ctrlr->connected_trid);
free(nvme_bdev_ctrlr);
return -ENOMEM;
}
Expand All @@ -1394,7 +1394,7 @@ create_ctrlr(struct spdk_nvme_ctrlr *ctrlr,
free(nvme_bdev_ctrlr->namespaces[i - 1]);
}
free(nvme_bdev_ctrlr->namespaces);
free(nvme_bdev_ctrlr->trid);
free(nvme_bdev_ctrlr->connected_trid);
free(nvme_bdev_ctrlr);
return -ENOMEM;
}
Expand All @@ -1404,11 +1404,11 @@ create_ctrlr(struct spdk_nvme_ctrlr *ctrlr,
nvme_bdev_ctrlr->adminq_timer_poller = NULL;
nvme_bdev_ctrlr->ctrlr = ctrlr;
nvme_bdev_ctrlr->ref = 0;
*nvme_bdev_ctrlr->trid = *trid;
*nvme_bdev_ctrlr->connected_trid = *trid;
nvme_bdev_ctrlr->name = strdup(name);
if (nvme_bdev_ctrlr->name == NULL) {
free(nvme_bdev_ctrlr->namespaces);
free(nvme_bdev_ctrlr->trid);
free(nvme_bdev_ctrlr->connected_trid);
free(nvme_bdev_ctrlr);
return -ENOMEM;
}
Expand All @@ -1419,7 +1419,7 @@ create_ctrlr(struct spdk_nvme_ctrlr *ctrlr,
SPDK_ERRLOG("Unable to initialize OCSSD controller\n");
free(nvme_bdev_ctrlr->name);
free(nvme_bdev_ctrlr->namespaces);
free(nvme_bdev_ctrlr->trid);
free(nvme_bdev_ctrlr->connected_trid);
free(nvme_bdev_ctrlr);
return rc;
}
Expand Down Expand Up @@ -1810,12 +1810,12 @@ bdev_nvme_delete(const char *name)
return -ENODEV;
}

if (nvme_bdev_ctrlr->trid->trtype == SPDK_NVME_TRANSPORT_PCIE) {
if (nvme_bdev_ctrlr->connected_trid->trtype == SPDK_NVME_TRANSPORT_PCIE) {
entry = calloc(1, sizeof(*entry));
if (!entry) {
return -ENOMEM;
}
entry->trid = *nvme_bdev_ctrlr->trid;
entry->trid = *nvme_bdev_ctrlr->connected_trid;
TAILQ_INSERT_TAIL(&g_skipped_nvme_ctrlrs, entry, tailq);
}

Expand Down Expand Up @@ -2735,31 +2735,31 @@ bdev_nvme_get_spdk_running_config(FILE *fp)
const char *trtype;
const char *prchk_flags;

trtype = spdk_nvme_transport_id_trtype_str(nvme_bdev_ctrlr->trid->trtype);
trtype = spdk_nvme_transport_id_trtype_str(nvme_bdev_ctrlr->connected_trid->trtype);
if (!trtype) {
continue;
}

if (nvme_bdev_ctrlr->trid->trtype == SPDK_NVME_TRANSPORT_PCIE) {
if (nvme_bdev_ctrlr->connected_trid->trtype == SPDK_NVME_TRANSPORT_PCIE) {
fprintf(fp, "TransportID \"trtype:%s traddr:%s\" %s\n",
trtype,
nvme_bdev_ctrlr->trid->traddr, nvme_bdev_ctrlr->name);
nvme_bdev_ctrlr->connected_trid->traddr, nvme_bdev_ctrlr->name);
} else {
const char *adrfam;

adrfam = spdk_nvme_transport_id_adrfam_str(nvme_bdev_ctrlr->trid->adrfam);
adrfam = spdk_nvme_transport_id_adrfam_str(nvme_bdev_ctrlr->connected_trid->adrfam);
prchk_flags = spdk_nvme_prchk_flags_str(nvme_bdev_ctrlr->prchk_flags);

if (adrfam) {
fprintf(fp, "TransportID \"trtype:%s adrfam:%s traddr:%s trsvcid:%s subnqn:%s\" %s",
trtype, adrfam,
nvme_bdev_ctrlr->trid->traddr, nvme_bdev_ctrlr->trid->trsvcid,
nvme_bdev_ctrlr->trid->subnqn, nvme_bdev_ctrlr->name);
nvme_bdev_ctrlr->connected_trid->traddr, nvme_bdev_ctrlr->connected_trid->trsvcid,
nvme_bdev_ctrlr->connected_trid->subnqn, nvme_bdev_ctrlr->name);
} else {
fprintf(fp, "TransportID \"trtype:%s traddr:%s trsvcid:%s subnqn:%s\" %s",
trtype,
nvme_bdev_ctrlr->trid->traddr, nvme_bdev_ctrlr->trid->trsvcid,
nvme_bdev_ctrlr->trid->subnqn, nvme_bdev_ctrlr->name);
nvme_bdev_ctrlr->connected_trid->traddr, nvme_bdev_ctrlr->connected_trid->trsvcid,
nvme_bdev_ctrlr->connected_trid->subnqn, nvme_bdev_ctrlr->name);
}

if (prchk_flags) {
Expand Down Expand Up @@ -2867,7 +2867,7 @@ bdev_nvme_config_json(struct spdk_json_write_ctx *w)

pthread_mutex_lock(&g_bdev_nvme_mutex);
TAILQ_FOREACH(nvme_bdev_ctrlr, &g_nvme_bdev_ctrlrs, tailq) {
trid = nvme_bdev_ctrlr->trid;
trid = nvme_bdev_ctrlr->connected_trid;

spdk_json_write_object_begin(w);

Expand Down
2 changes: 1 addition & 1 deletion module/bdev/nvme/bdev_nvme_rpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ rpc_dump_nvme_controller_info(struct spdk_json_write_ctx *w,
{
struct spdk_nvme_transport_id *trid;

trid = nvme_bdev_ctrlr->trid;
trid = nvme_bdev_ctrlr->connected_trid;

spdk_json_write_object_begin(w);
spdk_json_write_named_string(w, "name", nvme_bdev_ctrlr->name);
Expand Down
4 changes: 2 additions & 2 deletions module/bdev/nvme/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ nvme_bdev_ctrlr_get(const struct spdk_nvme_transport_id *trid)
struct nvme_bdev_ctrlr *nvme_bdev_ctrlr;

TAILQ_FOREACH(nvme_bdev_ctrlr, &g_nvme_bdev_ctrlrs, tailq) {
if (spdk_nvme_transport_id_compare(trid, nvme_bdev_ctrlr->trid) == 0) {
if (spdk_nvme_transport_id_compare(trid, nvme_bdev_ctrlr->connected_trid) == 0) {
return nvme_bdev_ctrlr;
}
}
Expand Down Expand Up @@ -128,7 +128,7 @@ nvme_bdev_unregister_cb(void *io_device)
free(nvme_bdev_ctrlr->namespaces[i]);
}
free(nvme_bdev_ctrlr->namespaces);
free(nvme_bdev_ctrlr->trid);
free(nvme_bdev_ctrlr->connected_trid);
free(nvme_bdev_ctrlr);

pthread_mutex_lock(&g_bdev_nvme_mutex);
Expand Down
2 changes: 1 addition & 1 deletion module/bdev/nvme/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct nvme_bdev_ctrlr {
* target for CONTROLLER IDENTIFY command during initialization
*/
struct spdk_nvme_ctrlr *ctrlr;
struct spdk_nvme_transport_id *trid;
struct spdk_nvme_transport_id *connected_trid;
char *name;
int ref;
bool resetting;
Expand Down
6 changes: 3 additions & 3 deletions test/unit/lib/bdev/bdev_ocssd.c/bdev_ocssd_ut.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,13 @@ create_nvme_bdev_controller(const struct spdk_nvme_transport_id *trid, const cha
nvme_bdev_ctrlr->namespaces = calloc(ctrlr->ns_count, sizeof(struct nvme_bdev_ns *));
SPDK_CU_ASSERT_FATAL(nvme_bdev_ctrlr->namespaces != NULL);

nvme_bdev_ctrlr->trid = calloc(1, sizeof(struct spdk_nvme_transport_id));
SPDK_CU_ASSERT_FATAL(nvme_bdev_ctrlr->trid != NULL);
nvme_bdev_ctrlr->connected_trid = calloc(1, sizeof(struct spdk_nvme_transport_id));
SPDK_CU_ASSERT_FATAL(nvme_bdev_ctrlr->connected_trid != NULL);

nvme_bdev_ctrlr->ctrlr = ctrlr;
nvme_bdev_ctrlr->num_ns = ctrlr->ns_count;
nvme_bdev_ctrlr->ref = 0;
*nvme_bdev_ctrlr->trid = *trid;
*nvme_bdev_ctrlr->connected_trid = *trid;
nvme_bdev_ctrlr->name = strdup(name);

for (nsid = 0; nsid < ctrlr->ns_count; ++nsid) {
Expand Down

0 comments on commit d88915f

Please sign in to comment.