bdev/nvme: don't attach user deleted controllers automaticlly
When hotplug feature is enabled by NVMe driver, users may call delete_nvme_controller() RPC to delete one controller, however, the hotplug monitor will probe this controller automaticlly and attach it back to NVMe driver. We added a skip list, for those user deleted controllers so that NVMe driver will not attach it again. Fix issue #602. Change-Id: Ibbe21ff8a021f968305271acdae86207e6228e20 Signed-off-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-on: https://review.gerrithub.io/c/444323 (master) Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/447595 Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
4d4c3fe813
commit
10cb21522a
@ -95,6 +95,14 @@ struct nvme_probe_ctx {
|
|||||||
const char *hostnqn;
|
const char *hostnqn;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct nvme_probe_skip_entry {
|
||||||
|
struct spdk_nvme_transport_id trid;
|
||||||
|
TAILQ_ENTRY(nvme_probe_skip_entry) tailq;
|
||||||
|
};
|
||||||
|
/* All the controllers deleted by users via RPC are skipped by hotplug monitor */
|
||||||
|
static TAILQ_HEAD(, nvme_probe_skip_entry) g_skipped_nvme_ctrlrs = TAILQ_HEAD_INITIALIZER(
|
||||||
|
g_skipped_nvme_ctrlrs);
|
||||||
|
|
||||||
static struct spdk_bdev_nvme_opts g_opts = {
|
static struct spdk_bdev_nvme_opts g_opts = {
|
||||||
.action_on_timeout = SPDK_BDEV_NVME_TIMEOUT_ACTION_NONE,
|
.action_on_timeout = SPDK_BDEV_NVME_TIMEOUT_ACTION_NONE,
|
||||||
.timeout_us = 0,
|
.timeout_us = 0,
|
||||||
@ -809,6 +817,14 @@ static bool
|
|||||||
hotplug_probe_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
|
hotplug_probe_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
|
||||||
struct spdk_nvme_ctrlr_opts *opts)
|
struct spdk_nvme_ctrlr_opts *opts)
|
||||||
{
|
{
|
||||||
|
struct nvme_probe_skip_entry *entry;
|
||||||
|
|
||||||
|
TAILQ_FOREACH(entry, &g_skipped_nvme_ctrlrs, tailq) {
|
||||||
|
if (spdk_nvme_transport_id_compare(trid, &entry->trid) == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_BDEV_NVME, "Attaching to %s\n", trid->traddr);
|
SPDK_DEBUGLOG(SPDK_LOG_BDEV_NVME, "Attaching to %s\n", trid->traddr);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -1203,6 +1219,7 @@ spdk_bdev_nvme_create(struct spdk_nvme_transport_id *trid,
|
|||||||
struct nvme_bdev *nvme_bdev;
|
struct nvme_bdev *nvme_bdev;
|
||||||
uint32_t i, nsid;
|
uint32_t i, nsid;
|
||||||
size_t j;
|
size_t j;
|
||||||
|
struct nvme_probe_skip_entry *entry, *tmp;
|
||||||
|
|
||||||
if (nvme_ctrlr_get(trid) != NULL) {
|
if (nvme_ctrlr_get(trid) != NULL) {
|
||||||
SPDK_ERRLOG("A controller with the provided trid (traddr: %s) already exists.\n", trid->traddr);
|
SPDK_ERRLOG("A controller with the provided trid (traddr: %s) already exists.\n", trid->traddr);
|
||||||
@ -1214,6 +1231,16 @@ spdk_bdev_nvme_create(struct spdk_nvme_transport_id *trid,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (trid->trtype == SPDK_NVME_TRANSPORT_PCIE) {
|
||||||
|
TAILQ_FOREACH_SAFE(entry, &g_skipped_nvme_ctrlrs, tailq, tmp) {
|
||||||
|
if (spdk_nvme_transport_id_compare(trid, &entry->trid) == 0) {
|
||||||
|
TAILQ_REMOVE(&g_skipped_nvme_ctrlrs, entry, tailq);
|
||||||
|
free(entry);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
spdk_nvme_ctrlr_get_default_ctrlr_opts(&opts, sizeof(opts));
|
spdk_nvme_ctrlr_get_default_ctrlr_opts(&opts, sizeof(opts));
|
||||||
|
|
||||||
if (hostnqn) {
|
if (hostnqn) {
|
||||||
@ -1276,6 +1303,7 @@ int
|
|||||||
spdk_bdev_nvme_delete(const char *name)
|
spdk_bdev_nvme_delete(const char *name)
|
||||||
{
|
{
|
||||||
struct nvme_ctrlr *nvme_ctrlr = NULL;
|
struct nvme_ctrlr *nvme_ctrlr = NULL;
|
||||||
|
struct nvme_probe_skip_entry *entry;
|
||||||
|
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@ -1287,6 +1315,15 @@ spdk_bdev_nvme_delete(const char *name)
|
|||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nvme_ctrlr->trid.trtype == SPDK_NVME_TRANSPORT_PCIE) {
|
||||||
|
entry = calloc(1, sizeof(*entry));
|
||||||
|
if (!entry) {
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
entry->trid = nvme_ctrlr->trid;
|
||||||
|
TAILQ_INSERT_TAIL(&g_skipped_nvme_ctrlrs, entry, tailq);
|
||||||
|
}
|
||||||
|
|
||||||
remove_cb(NULL, nvme_ctrlr->ctrlr);
|
remove_cb(NULL, nvme_ctrlr->ctrlr);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1491,9 +1528,15 @@ static void
|
|||||||
bdev_nvme_library_fini(void)
|
bdev_nvme_library_fini(void)
|
||||||
{
|
{
|
||||||
struct nvme_ctrlr *nvme_ctrlr, *tmp;
|
struct nvme_ctrlr *nvme_ctrlr, *tmp;
|
||||||
|
struct nvme_probe_skip_entry *entry, *entry_tmp;
|
||||||
|
|
||||||
spdk_poller_unregister(&g_hotplug_poller);
|
spdk_poller_unregister(&g_hotplug_poller);
|
||||||
|
|
||||||
|
TAILQ_FOREACH_SAFE(entry, &g_skipped_nvme_ctrlrs, tailq, entry_tmp) {
|
||||||
|
TAILQ_REMOVE(&g_skipped_nvme_ctrlrs, entry, tailq);
|
||||||
|
free(entry);
|
||||||
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&g_bdev_nvme_mutex);
|
pthread_mutex_lock(&g_bdev_nvme_mutex);
|
||||||
TAILQ_FOREACH_SAFE(nvme_ctrlr, &g_nvme_ctrlrs, tailq, tmp) {
|
TAILQ_FOREACH_SAFE(nvme_ctrlr, &g_nvme_ctrlrs, tailq, tmp) {
|
||||||
if (nvme_ctrlr->ref > 0) {
|
if (nvme_ctrlr->ref > 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user