bdev/nvme: connected_trid is now an nvme_ctrlr_trid

Instead of storing an spdk_nvme_transport_id, store the object that
contains it. This will make a few later patches easier.

Change-Id: I36b74889fe39af3b7ab2b900fb3ea4b3f39e1f83
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9484
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Ben Walker 2021-09-22 11:10:28 -07:00 committed by Tomasz Zawadzki
parent 3184f6e227
commit a91079fd2d
4 changed files with 24 additions and 24 deletions

View File

@ -251,7 +251,7 @@ nvme_bdev_ctrlr_get_ctrlr(struct nvme_bdev_ctrlr *nbdev_ctrlr,
struct nvme_ctrlr *nvme_ctrlr;
TAILQ_FOREACH(nvme_ctrlr, &nbdev_ctrlr->ctrlrs, tailq) {
if (spdk_nvme_transport_id_compare(trid, nvme_ctrlr->connected_trid) == 0) {
if (spdk_nvme_transport_id_compare(trid, &nvme_ctrlr->connected_trid->trid) == 0) {
break;
}
}
@ -815,7 +815,7 @@ bdev_nvme_reset_complete(struct nvme_ctrlr *nvme_ctrlr, int rc)
curr_trid = TAILQ_FIRST(&nvme_ctrlr->trids);
assert(curr_trid != NULL);
assert(&curr_trid->trid == nvme_ctrlr->connected_trid);
assert(curr_trid == nvme_ctrlr->connected_trid);
curr_trid->is_failed = rc != 0 ? true : false;
@ -1013,7 +1013,7 @@ bdev_nvme_failover_start(struct nvme_ctrlr *nvme_ctrlr, bool remove)
curr_trid = TAILQ_FIRST(&nvme_ctrlr->trids);
assert(curr_trid);
assert(&curr_trid->trid == nvme_ctrlr->connected_trid);
assert(curr_trid == nvme_ctrlr->connected_trid);
next_trid = TAILQ_NEXT(curr_trid, link);
if (nvme_ctrlr->resetting) {
@ -1038,7 +1038,7 @@ bdev_nvme_failover_start(struct nvme_ctrlr *nvme_ctrlr, bool remove)
nvme_ctrlr->failover_in_progress = true;
spdk_nvme_ctrlr_fail(nvme_ctrlr->ctrlr);
nvme_ctrlr->connected_trid = &next_trid->trid;
nvme_ctrlr->connected_trid = next_trid;
rc = spdk_nvme_ctrlr_set_trid(nvme_ctrlr->ctrlr, &next_trid->trid);
assert(rc == 0);
TAILQ_REMOVE(&nvme_ctrlr->trids, curr_trid, link);
@ -1950,7 +1950,7 @@ timeout_cb(void *cb_arg, struct spdk_nvme_ctrlr *ctrlr,
* would submit another fabrics cmd on the admin queue to read CSTS and check for its
* completion recursively.
*/
if (nvme_ctrlr->connected_trid->trtype == SPDK_NVME_TRANSPORT_PCIE || qpair != NULL) {
if (nvme_ctrlr->connected_trid->trid.trtype == SPDK_NVME_TRANSPORT_PCIE || qpair != NULL) {
csts = spdk_nvme_ctrlr_get_regs_csts(ctrlr);
if (csts.bits.cfs) {
SPDK_ERRLOG("Controller Fatal Status, reset required\n");
@ -2515,7 +2515,7 @@ nvme_ctrlr_create(struct spdk_nvme_ctrlr *ctrlr,
}
trid_entry->trid = *trid;
nvme_ctrlr->connected_trid = &trid_entry->trid;
nvme_ctrlr->connected_trid = trid_entry;
TAILQ_INSERT_HEAD(&nvme_ctrlr->trids, trid_entry, link);
nvme_ctrlr->thread = spdk_get_thread();
@ -2627,13 +2627,13 @@ _bdev_nvme_delete(struct nvme_ctrlr *nvme_ctrlr, bool hotplug)
}
if (!hotplug &&
nvme_ctrlr->connected_trid->trtype == SPDK_NVME_TRANSPORT_PCIE) {
nvme_ctrlr->connected_trid->trid.trtype == SPDK_NVME_TRANSPORT_PCIE) {
entry = calloc(1, sizeof(*entry));
if (!entry) {
pthread_mutex_unlock(&nvme_ctrlr->mutex);
return -ENOMEM;
}
entry->trid = *nvme_ctrlr->connected_trid;
entry->trid = nvme_ctrlr->connected_trid->trid;
TAILQ_INSERT_TAIL(&g_skipped_nvme_ctrlrs, entry, tailq);
}
@ -2827,12 +2827,12 @@ bdev_nvme_compare_trids(struct nvme_ctrlr *nvme_ctrlr,
}
/* Currently we only support failover to the same transport type. */
if (nvme_ctrlr->connected_trid->trtype != trid->trtype) {
if (nvme_ctrlr->connected_trid->trid.trtype != trid->trtype) {
return -EINVAL;
}
/* Currently we only support failover to the same NQN. */
if (strncmp(trid->subnqn, nvme_ctrlr->connected_trid->subnqn, SPDK_NVMF_NQN_MAX_LEN)) {
if (strncmp(trid->subnqn, nvme_ctrlr->connected_trid->trid.subnqn, SPDK_NVMF_NQN_MAX_LEN)) {
return -EINVAL;
}
@ -3078,7 +3078,7 @@ bdev_nvme_delete_secondary_trid(struct nvme_ctrlr *nvme_ctrlr,
{
struct nvme_ctrlr_trid *ctrlr_trid, *tmp_trid;
if (!spdk_nvme_transport_id_compare(trid, nvme_ctrlr->connected_trid)) {
if (!spdk_nvme_transport_id_compare(trid, &nvme_ctrlr->connected_trid->trid)) {
return -EBUSY;
}
@ -3122,9 +3122,9 @@ bdev_nvme_delete(const char *name, const struct spdk_nvme_transport_id *trid)
if (rc != 0) {
return rc;
}
} else if (!spdk_nvme_transport_id_compare(trid, nvme_ctrlr->connected_trid)) {
} else if (!spdk_nvme_transport_id_compare(trid, &nvme_ctrlr->connected_trid->trid)) {
ctrlr_trid = TAILQ_FIRST(&nvme_ctrlr->trids);
assert(nvme_ctrlr->connected_trid == &ctrlr_trid->trid);
assert(nvme_ctrlr->connected_trid == ctrlr_trid);
if (!TAILQ_NEXT(ctrlr_trid, link)) {
/* Case 2A: The current path is the only path. */
return _bdev_nvme_delete(nvme_ctrlr, false);
@ -4145,7 +4145,7 @@ nvme_ctrlr_config_json(struct spdk_json_write_ctx *w,
{
struct spdk_nvme_transport_id *trid;
trid = nvme_ctrlr->connected_trid;
trid = &nvme_ctrlr->connected_trid->trid;
spdk_json_write_object_begin(w);

View File

@ -94,7 +94,7 @@ struct nvme_ctrlr {
* target for CONTROLLER IDENTIFY command during initialization
*/
struct spdk_nvme_ctrlr *ctrlr;
struct spdk_nvme_transport_id *connected_trid;
struct nvme_ctrlr_trid *connected_trid;
int ref;
bool resetting;
bool failover_in_progress;

View File

@ -428,7 +428,7 @@ rpc_dump_nvme_controller_info(struct nvme_ctrlr *nvme_ctrlr, void *ctx)
struct spdk_nvme_transport_id *trid;
const struct spdk_nvme_ctrlr_opts *opts;
trid = nvme_ctrlr->connected_trid;
trid = &nvme_ctrlr->connected_trid->trid;
spdk_json_write_object_begin(w);
spdk_json_write_named_string(w, "name", nvme_ctrlr->nbdev_ctrlr->name);

View File

@ -1457,7 +1457,7 @@ test_failover_ctrlr(void)
curr_trid = TAILQ_FIRST(&nvme_ctrlr->trids);
SPDK_CU_ASSERT_FATAL(curr_trid != NULL);
CU_ASSERT(&curr_trid->trid == nvme_ctrlr->connected_trid);
CU_ASSERT(curr_trid == nvme_ctrlr->connected_trid);
CU_ASSERT(spdk_nvme_transport_id_compare(&curr_trid->trid, &trid1) == 0);
/* Failover starts from thread 1. */
@ -1488,7 +1488,7 @@ test_failover_ctrlr(void)
next_trid = TAILQ_FIRST(&nvme_ctrlr->trids);
SPDK_CU_ASSERT_FATAL(next_trid != NULL);
CU_ASSERT(next_trid != curr_trid);
CU_ASSERT(&next_trid->trid == nvme_ctrlr->connected_trid);
CU_ASSERT(next_trid == nvme_ctrlr->connected_trid);
CU_ASSERT(spdk_nvme_transport_id_compare(&next_trid->trid, &trid2) == 0);
poll_threads();
@ -2096,7 +2096,7 @@ test_add_remove_trid(void)
nvme_ctrlr = nvme_ctrlr_get_by_name("nvme0");
SPDK_CU_ASSERT_FATAL(nvme_ctrlr != NULL);
CU_ASSERT(spdk_nvme_transport_id_compare(nvme_ctrlr->connected_trid, &trid1) == 0);
CU_ASSERT(spdk_nvme_transport_id_compare(&nvme_ctrlr->connected_trid->trid, &trid1) == 0);
ctrlr2 = ut_attach_ctrlr(&trid2, 0, false, false);
SPDK_CU_ASSERT_FATAL(ctrlr2 != NULL);
@ -2108,7 +2108,7 @@ test_add_remove_trid(void)
spdk_delay_us(1000);
poll_threads();
CU_ASSERT(spdk_nvme_transport_id_compare(nvme_ctrlr->connected_trid, &trid1) == 0);
CU_ASSERT(spdk_nvme_transport_id_compare(&nvme_ctrlr->connected_trid->trid, &trid1) == 0);
TAILQ_FOREACH(ctrid, &nvme_ctrlr->trids, link) {
if (spdk_nvme_transport_id_compare(&ctrid->trid, &trid2) == 0) {
break;
@ -2138,7 +2138,7 @@ test_add_remove_trid(void)
spdk_delay_us(1000);
poll_threads();
CU_ASSERT(spdk_nvme_transport_id_compare(nvme_ctrlr->connected_trid, &trid1) == 0);
CU_ASSERT(spdk_nvme_transport_id_compare(&nvme_ctrlr->connected_trid->trid, &trid1) == 0);
TAILQ_FOREACH(ctrid, &nvme_ctrlr->trids, link) {
if (spdk_nvme_transport_id_compare(&ctrid->trid, &trid3) == 0) {
break;
@ -2156,7 +2156,7 @@ test_add_remove_trid(void)
TAILQ_FOREACH(ctrid, &nvme_ctrlr->trids, link) {
CU_ASSERT(spdk_nvme_transport_id_compare(&ctrid->trid, &trid1) != 0);
}
CU_ASSERT(spdk_nvme_transport_id_compare(nvme_ctrlr->connected_trid, &trid3) == 0);
CU_ASSERT(spdk_nvme_transport_id_compare(&nvme_ctrlr->connected_trid->trid, &trid3) == 0);
poll_threads();
@ -2186,7 +2186,7 @@ test_add_remove_trid(void)
nvme_ctrlr = nvme_ctrlr_get_by_name("nvme0");
SPDK_CU_ASSERT_FATAL(nvme_ctrlr != NULL);
CU_ASSERT(spdk_nvme_transport_id_compare(nvme_ctrlr->connected_trid, &trid1) == 0);
CU_ASSERT(spdk_nvme_transport_id_compare(&nvme_ctrlr->connected_trid->trid, &trid1) == 0);
ctrlr2 = ut_attach_ctrlr(&trid2, 0, false, false);
SPDK_CU_ASSERT_FATAL(ctrlr2 != NULL);
@ -2198,7 +2198,7 @@ test_add_remove_trid(void)
spdk_delay_us(1000);
poll_threads();
CU_ASSERT(spdk_nvme_transport_id_compare(nvme_ctrlr->connected_trid, &trid1) == 0);
CU_ASSERT(spdk_nvme_transport_id_compare(&nvme_ctrlr->connected_trid->trid, &trid1) == 0);
TAILQ_FOREACH(ctrid, &nvme_ctrlr->trids, link) {
if (spdk_nvme_transport_id_compare(&ctrid->trid, &trid2) == 0) {
break;