bdev/nvme: Factor out deleting secondary trid into a helper function
Factor out deleting secondary trid from bdev_nvme_delete() into a helper function bdev_nvme_delete_secondary_trid(). This will make the following changes simpler. Besides, fix a typo, the case should be not 1B but 2B. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: Iba21efa0d8036ed15d2743a2548df05e866089d6 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7123 Community-CI: Broadcom CI 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: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
parent
08e2210ace
commit
45d8309e52
@ -2356,11 +2356,32 @@ bdev_nvme_create(struct spdk_nvme_transport_id *trid,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
bdev_nvme_delete_secondary_trid(struct nvme_bdev_ctrlr *nvme_bdev_ctrlr,
|
||||
const struct spdk_nvme_transport_id *trid)
|
||||
{
|
||||
struct nvme_bdev_ctrlr_trid *ctrlr_trid, *tmp_trid;
|
||||
|
||||
if (!spdk_nvme_transport_id_compare(trid, nvme_bdev_ctrlr->connected_trid)) {
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
TAILQ_FOREACH_SAFE(ctrlr_trid, &nvme_bdev_ctrlr->trids, link, tmp_trid) {
|
||||
if (!spdk_nvme_transport_id_compare(&ctrlr_trid->trid, trid)) {
|
||||
TAILQ_REMOVE(&nvme_bdev_ctrlr->trids, ctrlr_trid, link);
|
||||
free(ctrlr_trid);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
int
|
||||
bdev_nvme_delete(const char *name, const struct spdk_nvme_transport_id *trid)
|
||||
{
|
||||
struct nvme_bdev_ctrlr *nvme_bdev_ctrlr;
|
||||
struct nvme_bdev_ctrlr_trid *ctrlr_trid, *tmp_trid;
|
||||
struct nvme_bdev_ctrlr_trid *ctrlr_trid;
|
||||
|
||||
if (name == NULL) {
|
||||
return -EINVAL;
|
||||
@ -2386,20 +2407,12 @@ bdev_nvme_delete(const char *name, const struct spdk_nvme_transport_id *trid)
|
||||
return _bdev_nvme_delete(nvme_bdev_ctrlr, false);
|
||||
}
|
||||
|
||||
/* case 1B: there is an alternative path. */
|
||||
/* case 2B: there is an alternative path. */
|
||||
return bdev_nvme_failover(nvme_bdev_ctrlr, true);
|
||||
}
|
||||
/* case 3: We are not using the specified path. */
|
||||
TAILQ_FOREACH_SAFE(ctrlr_trid, &nvme_bdev_ctrlr->trids, link, tmp_trid) {
|
||||
if (!spdk_nvme_transport_id_compare(&ctrlr_trid->trid, trid)) {
|
||||
TAILQ_REMOVE(&nvme_bdev_ctrlr->trids, ctrlr_trid, link);
|
||||
free(ctrlr_trid);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* case 3A: The address isn't even in the registered list. */
|
||||
return -ENXIO;
|
||||
/* case 3: We are not using the specified path. */
|
||||
return bdev_nvme_delete_secondary_trid(nvme_bdev_ctrlr, trid);
|
||||
}
|
||||
|
||||
static int
|
||||
|
Loading…
x
Reference in New Issue
Block a user