nvme: add timeout value to multi-process driver init

Unit tests will be added as part of a separate patch updating all UT for
nvme.c.  Global used for timeout value so it can be easily overwritten
by the upcoming unit tests for this function.

Change-Id: I7fc15aab91601ac57c94cae266b212c0998d2495
Signed-off-by: paul luse <paul.e.luse@intel.com>
This commit is contained in:
Paul Luse 2017-05-08 12:11:23 -07:00 committed by Jim Harris
parent c7f6f553b9
commit bf31637789

View File

@ -40,6 +40,9 @@ struct nvme_driver *g_spdk_nvme_driver;
int32_t spdk_nvme_retry_count;
/* gross timeout of 180 seconds in milliseconds */
static int g_nvme_driver_timeout_ms = 3 * 60 * 1000;
int
spdk_nvme_detach(struct spdk_nvme_ctrlr *ctrlr)
{
@ -255,9 +258,18 @@ nvme_driver_init(void)
/* The unique named memzone already reserved by the primary process. */
if (g_spdk_nvme_driver != NULL) {
int ms_waited = 0;
/* Wait the nvme driver to get initialized. */
while (g_spdk_nvme_driver->initialized == false) {
nvme_delay(1000);
while ((g_spdk_nvme_driver->initialized == false) &&
(ms_waited < g_nvme_driver_timeout_ms)) {
ms_waited++;
nvme_delay(1000); /* delay 1ms */
}
if (g_spdk_nvme_driver->initialized == false) {
SPDK_ERRLOG("timeout waiting for primary process to init\n");
return -1;
}
} else {
SPDK_ERRLOG("primary process is not started yet\n");