bdev/nvme: bdev_nvme_delete treats empty trid fields as wildcards
The RPC that calls this function needs wildcard behavior. Change-Id: Ie373d8fdd6f0308476e23de8a7a5be1d2595e574 Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9575 Community-CI: Mellanox Build Bot Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
parent
6a8379c7ff
commit
6b54f432a8
@ -3098,8 +3098,8 @@ bdev_nvme_delete(const char *name, const struct spdk_nvme_transport_id *trid)
|
|||||||
{
|
{
|
||||||
struct nvme_bdev_ctrlr *nbdev_ctrlr;
|
struct nvme_bdev_ctrlr *nbdev_ctrlr;
|
||||||
struct nvme_ctrlr *nvme_ctrlr, *tmp_nvme_ctrlr;
|
struct nvme_ctrlr *nvme_ctrlr, *tmp_nvme_ctrlr;
|
||||||
struct nvme_ctrlr_trid *ctrlr_trid;
|
struct nvme_ctrlr_trid *ctrlr_trid, *tmp_trid;
|
||||||
int rc = 0;
|
int rc = -ENXIO;
|
||||||
|
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@ -3117,27 +3117,73 @@ bdev_nvme_delete(const char *name, const struct spdk_nvme_transport_id *trid)
|
|||||||
|
|
||||||
TAILQ_FOREACH_SAFE(nvme_ctrlr, &nbdev_ctrlr->ctrlrs, tailq, tmp_nvme_ctrlr) {
|
TAILQ_FOREACH_SAFE(nvme_ctrlr, &nbdev_ctrlr->ctrlrs, tailq, tmp_nvme_ctrlr) {
|
||||||
if (trid == NULL) {
|
if (trid == NULL) {
|
||||||
/* Case 1: Remove all nvme_ctrlrs of the nvme_bdev_ctrlr. */
|
/* Remove all nvme_ctrlrs of the nvme_bdev_ctrlr. */
|
||||||
rc = _bdev_nvme_delete(nvme_ctrlr, false);
|
rc = _bdev_nvme_delete(nvme_ctrlr, false);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
} else if (!spdk_nvme_transport_id_compare(trid, &nvme_ctrlr->connected_trid->trid)) {
|
|
||||||
ctrlr_trid = TAILQ_FIRST(&nvme_ctrlr->trids);
|
continue;
|
||||||
assert(nvme_ctrlr->connected_trid == ctrlr_trid);
|
}
|
||||||
if (!TAILQ_NEXT(ctrlr_trid, link)) {
|
|
||||||
/* Case 2A: The current path is the only path. */
|
TAILQ_FOREACH_REVERSE_SAFE(ctrlr_trid, &nvme_ctrlr->trids, nvme_paths, link, tmp_trid) {
|
||||||
return _bdev_nvme_delete(nvme_ctrlr, false);
|
if (trid->trtype != 0) {
|
||||||
} else {
|
if (trid->trtype == SPDK_NVME_TRANSPORT_CUSTOM) {
|
||||||
/* Case 2B: There is an alternative path. */
|
if (strcasecmp(trid->trstring, ctrlr_trid->trid.trstring) != 0) {
|
||||||
return bdev_nvme_failover(nvme_ctrlr, true);
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Case 3: We are not using the specified path. */
|
if (trid->trtype != ctrlr_trid->trid.trtype) {
|
||||||
rc = bdev_nvme_delete_secondary_trid(nvme_ctrlr, trid);
|
continue;
|
||||||
if (rc != -ENXIO) {
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!spdk_mem_all_zero(trid->traddr, sizeof(trid->traddr))) {
|
||||||
|
if (strcasecmp(trid->traddr, ctrlr_trid->trid.traddr) != 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (trid->adrfam != 0) {
|
||||||
|
if (trid->adrfam != ctrlr_trid->trid.adrfam) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!spdk_mem_all_zero(trid->trsvcid, sizeof(trid->trsvcid))) {
|
||||||
|
if (strcasecmp(trid->trsvcid, ctrlr_trid->trid.trsvcid) != 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!spdk_mem_all_zero(trid->subnqn, sizeof(trid->subnqn))) {
|
||||||
|
if (strcmp(trid->subnqn, ctrlr_trid->trid.subnqn) != 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If we made it here, then this path is a match! Now we need to remove it. */
|
||||||
|
if (ctrlr_trid == nvme_ctrlr->connected_trid) {
|
||||||
|
/* This is the active path in use right now. The active path is always the first in the list. */
|
||||||
|
|
||||||
|
if (!TAILQ_NEXT(ctrlr_trid, link)) {
|
||||||
|
/* The current path is the only path. */
|
||||||
|
rc = _bdev_nvme_delete(nvme_ctrlr, false);
|
||||||
|
} else {
|
||||||
|
/* There is an alternative path. */
|
||||||
|
rc = bdev_nvme_failover(nvme_ctrlr, true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* We are not using the specified path. */
|
||||||
|
rc = bdev_nvme_delete_secondary_trid(nvme_ctrlr, &ctrlr_trid->trid);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rc < 0 && rc != -ENXIO) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ struct nvme_ctrlr {
|
|||||||
TAILQ_ENTRY(nvme_ctrlr) tailq;
|
TAILQ_ENTRY(nvme_ctrlr) tailq;
|
||||||
struct nvme_bdev_ctrlr *nbdev_ctrlr;
|
struct nvme_bdev_ctrlr *nbdev_ctrlr;
|
||||||
|
|
||||||
TAILQ_HEAD(, nvme_ctrlr_trid) trids;
|
TAILQ_HEAD(nvme_paths, nvme_ctrlr_trid) trids;
|
||||||
|
|
||||||
uint32_t ana_log_page_size;
|
uint32_t ana_log_page_size;
|
||||||
struct spdk_nvme_ana_page *ana_log_page;
|
struct spdk_nvme_ana_page *ana_log_page;
|
||||||
|
Loading…
Reference in New Issue
Block a user