From 7f957f56c1290d353a917500a6e58b74924ad86e Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Thu, 30 Mar 2017 12:57:10 -0700 Subject: [PATCH] bdev/nvme: add HotplugEnable option Change-Id: I53fb7c3b469d5d5bb5b86c095bf1efc914299ec7 Signed-off-by: Daniel Verkamp --- etc/spdk/iscsi.conf.in | 3 +++ etc/spdk/nvmf.conf.in | 3 +++ etc/spdk/vhost.conf.in | 4 ++++ lib/bdev/nvme/blockdev_nvme.c | 13 ++++++++++--- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/etc/spdk/iscsi.conf.in b/etc/spdk/iscsi.conf.in index 8bba056e7..8f705ba8e 100644 --- a/etc/spdk/iscsi.conf.in +++ b/etc/spdk/iscsi.conf.in @@ -108,6 +108,9 @@ # Units in microseconds. AdminPollRate 100000 + # Enable handling of hotplug (runtime insert and remove) events + HotplugEnable Yes + # Users may change this section to create a different number or size of # malloc LUNs. # If the system has hardware DMA engine, it will use an IOAT diff --git a/etc/spdk/nvmf.conf.in b/etc/spdk/nvmf.conf.in index df3799a2a..4c998af34 100644 --- a/etc/spdk/nvmf.conf.in +++ b/etc/spdk/nvmf.conf.in @@ -99,6 +99,9 @@ # Units in microseconds. AdminPollRate 100000 + # Enable handling of hotplug (runtime insert and remove) events + HotplugEnable Yes + # The Split virtual block device slices block devices into multiple smaller bdevs. [Split] # Syntax: diff --git a/etc/spdk/vhost.conf.in b/etc/spdk/vhost.conf.in index 625a6b6d6..cb56e6635 100644 --- a/etc/spdk/vhost.conf.in +++ b/etc/spdk/vhost.conf.in @@ -90,6 +90,10 @@ # Units in microseconds. AdminPollRate 100000 + # Enable handling of hotplug (runtime insert and remove) events + # vhost currently does not support hotplug + HotplugEnable No + # The Split virtual block device slices block devices into multiple smaller bdevs. [Split] # Syntax: diff --git a/lib/bdev/nvme/blockdev_nvme.c b/lib/bdev/nvme/blockdev_nvme.c index 35b565327..a7d832dfa 100644 --- a/lib/bdev/nvme/blockdev_nvme.c +++ b/lib/bdev/nvme/blockdev_nvme.c @@ -115,6 +115,7 @@ static int g_hot_insert_nvme_controller_index = 0; static bool g_reset_controller_on_timeout = false; static int g_timeout = 0; static int g_nvme_adminq_poll_timeout_us = 0; +static bool g_nvme_hotplug_enabled; static int g_nvme_hotplug_poll_timeout_us = 0; static int g_nvme_hotplug_poll_core = 0; static struct spdk_poller *g_hotplug_poller; @@ -780,6 +781,8 @@ bdev_nvme_library_init(void) g_nvme_adminq_poll_timeout_us = 1000000; } + g_nvme_hotplug_enabled = spdk_conf_section_get_boolval(sp, "HotplugEnable", true); + g_nvme_hotplug_poll_timeout_us = spdk_conf_section_get_intval(sp, "HotplugPollRate"); if (g_nvme_hotplug_poll_timeout_us <= 0 || g_nvme_hotplug_poll_timeout_us > 100000) { g_nvme_hotplug_poll_timeout_us = 100000; @@ -794,8 +797,10 @@ bdev_nvme_library_init(void) return -1; } - spdk_poller_register(&g_hotplug_poller, blockdev_nvme_hotplug, NULL, - g_nvme_hotplug_poll_core, g_nvme_hotplug_poll_timeout_us); + if (g_nvme_hotplug_enabled) { + spdk_poller_register(&g_hotplug_poller, blockdev_nvme_hotplug, NULL, + g_nvme_hotplug_poll_core, g_nvme_hotplug_poll_timeout_us); + } return 0; } @@ -805,7 +810,9 @@ bdev_nvme_library_fini(void) { struct nvme_bdev *nvme_bdev, *btmp; - spdk_poller_unregister(&g_hotplug_poller, NULL); + if (g_nvme_hotplug_enabled) { + spdk_poller_unregister(&g_hotplug_poller, NULL); + } TAILQ_FOREACH_SAFE(nvme_bdev, &g_nvme_bdevs, link, btmp) { bdev_nvme_destruct(&nvme_bdev->disk);