bdev/nvme: Change if->else to if->return for failover_trid()

This refactroing will reduce the size of the next patch significantly.

Signed-off-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: I2eb7ec62e6c559d9e69334e73de49e8bf97a35dd
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17652
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
This commit is contained in:
Shuhei Matsumoto 2023-04-20 13:54:36 +09:00 committed by David Ko
parent 610265c9fa
commit ae8eebd680

View File

@ -1738,25 +1738,27 @@ bdev_nvme_failover_trid(struct nvme_ctrlr *nvme_ctrlr, bool remove)
path_id->is_failed = true; path_id->is_failed = true;
if (next_path) { if (next_path == NULL) {
assert(path_id->trid.trtype != SPDK_NVME_TRANSPORT_PCIE); return;
}
SPDK_NOTICELOG("Start failover from %s:%s to %s:%s\n", path_id->trid.traddr, assert(path_id->trid.trtype != SPDK_NVME_TRANSPORT_PCIE);
path_id->trid.trsvcid, next_path->trid.traddr, next_path->trid.trsvcid);
spdk_nvme_ctrlr_fail(nvme_ctrlr->ctrlr); SPDK_NOTICELOG("Start failover from %s:%s to %s:%s\n", path_id->trid.traddr,
nvme_ctrlr->active_path_id = next_path; path_id->trid.trsvcid, next_path->trid.traddr, next_path->trid.trsvcid);
rc = spdk_nvme_ctrlr_set_trid(nvme_ctrlr->ctrlr, &next_path->trid);
assert(rc == 0); spdk_nvme_ctrlr_fail(nvme_ctrlr->ctrlr);
TAILQ_REMOVE(&nvme_ctrlr->trids, path_id, link); nvme_ctrlr->active_path_id = next_path;
if (!remove) { rc = spdk_nvme_ctrlr_set_trid(nvme_ctrlr->ctrlr, &next_path->trid);
/** Shuffle the old trid to the end of the list and use the new one. assert(rc == 0);
* Allows for round robin through multiple connections. TAILQ_REMOVE(&nvme_ctrlr->trids, path_id, link);
*/ if (!remove) {
TAILQ_INSERT_TAIL(&nvme_ctrlr->trids, path_id, link); /** Shuffle the old trid to the end of the list and use the new one.
} else { * Allows for round robin through multiple connections.
free(path_id); */
} TAILQ_INSERT_TAIL(&nvme_ctrlr->trids, path_id, link);
} else {
free(path_id);
} }
} }