nvme: change the type of paramter for timeout_callback set

Change the type of nvme_timeout parameter in
spdk_nvme_ctrlr_register_timeout_callback from uin32_t to uint64_t.

Reason: This will make the timeout trigger test more flexible and
will not affect the original meanings.

Also for the configuration file, still maintain the compatability
support

Change-Id: I94c90f67b2e9c57220ab82ecea11a1590d62aed4
Signed-off-by: Ziye Yang <optimistyzy@gmail.com>
Reviewed-on: https://review.gerrithub.io/419326
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Ziye Yang 2018-07-16 09:58:45 +08:00 committed by Changpeng Liu
parent ee9db7dac0
commit b1da5cecaa
4 changed files with 31 additions and 13 deletions

View File

@ -21,6 +21,11 @@ New API function spdk_nvme_qpair_add_cmd_error_injection() and
spdk_nvme_qpair_remove_cmd_error_injection() have been added for NVMe error emulation, spdk_nvme_qpair_remove_cmd_error_injection() have been added for NVMe error emulation,
users can set specified command with specified error status for error emulation. users can set specified command with specified error status for error emulation.
Change the name `timeout_sec` parameter to `timeout_us` in API function
spdk_nvme_ctrlr_register_timeout_callback, and also change the type from uint32_t to
uint64_t. This will give users more fine-grained control over the timeout period for
calling callback functions.
### Build System ### Build System
The build system now generates a combined shared library (libspdk.so) that may be used The build system now generates a combined shared library (libspdk.so) that may be used

View File

@ -688,12 +688,12 @@ typedef void (*spdk_nvme_timeout_cb)(void *cb_arg,
* for timeout callback. * for timeout callback.
* *
* \param ctrlr NVMe controller on which to monitor for timeout. * \param ctrlr NVMe controller on which to monitor for timeout.
* \param timeout_sec Timeout value in seconds. * \param timeout_us Timeout value in microseconds.
* \param cb_fn A function pointer that points to the callback function. * \param cb_fn A function pointer that points to the callback function.
* \param cb_arg Argument to the callback function. * \param cb_arg Argument to the callback function.
*/ */
void spdk_nvme_ctrlr_register_timeout_callback(struct spdk_nvme_ctrlr *ctrlr, void spdk_nvme_ctrlr_register_timeout_callback(struct spdk_nvme_ctrlr *ctrlr,
uint32_t timeout_sec, spdk_nvme_timeout_cb cb_fn, void *cb_arg); uint64_t timeout_us, spdk_nvme_timeout_cb cb_fn, void *cb_arg);
/** /**
* NVMe I/O queue pair initialization options. * NVMe I/O queue pair initialization options.

View File

@ -102,7 +102,7 @@ enum timeout_action {
static int g_hot_insert_nvme_controller_index = 0; static int g_hot_insert_nvme_controller_index = 0;
static enum timeout_action g_action_on_timeout = TIMEOUT_ACTION_NONE; static enum timeout_action g_action_on_timeout = TIMEOUT_ACTION_NONE;
static int g_timeout = 0; static uint64_t g_timeout_us = 0;
static int g_nvme_adminq_poll_timeout_us = 0; static int g_nvme_adminq_poll_timeout_us = 0;
static bool g_nvme_hotplug_enabled = false; static bool g_nvme_hotplug_enabled = false;
static int g_nvme_hotplug_poll_timeout_us = 0; static int g_nvme_hotplug_poll_timeout_us = 0;
@ -946,7 +946,7 @@ create_ctrlr(struct spdk_nvme_ctrlr *ctrlr,
TAILQ_INSERT_TAIL(&g_nvme_ctrlrs, nvme_ctrlr, tailq); TAILQ_INSERT_TAIL(&g_nvme_ctrlrs, nvme_ctrlr, tailq);
if (g_action_on_timeout != TIMEOUT_ACTION_NONE) { if (g_action_on_timeout != TIMEOUT_ACTION_NONE) {
spdk_nvme_ctrlr_register_timeout_callback(ctrlr, g_timeout, spdk_nvme_ctrlr_register_timeout_callback(ctrlr, g_timeout_us,
timeout_cb, NULL); timeout_cb, NULL);
} }
@ -1099,6 +1099,7 @@ bdev_nvme_library_init(void)
size_t i; size_t i;
struct nvme_probe_ctx *probe_ctx = NULL; struct nvme_probe_ctx *probe_ctx = NULL;
int retry_count; int retry_count;
int timeout;
uint32_t local_nvme_num = 0; uint32_t local_nvme_num = 0;
sp = spdk_conf_find_section(NULL, "Nvme"); sp = spdk_conf_find_section(NULL, "Nvme");
@ -1124,17 +1125,29 @@ bdev_nvme_library_init(void)
spdk_nvme_retry_count = retry_count; spdk_nvme_retry_count = retry_count;
if ((g_timeout = spdk_conf_section_get_intval(sp, "Timeout")) < 0) { val = spdk_conf_section_get_val(sp, "TimeoutUsec");
if (val != NULL) {
g_timeout_us = strtoll(val, NULL, 10);
} else {
/* Check old name for backward compatibility */ /* Check old name for backward compatibility */
if ((g_timeout = spdk_conf_section_get_intval(sp, "NvmeTimeoutValue")) < 0) { timeout = spdk_conf_section_get_intval(sp, "Timeout");
g_timeout = 0; if (timeout < 0) {
timeout = spdk_conf_section_get_intval(sp, "NvmeTimeoutValue");
if (timeout < 0) {
g_timeout_us = 0;
} else {
g_timeout_us = timeout * 1000000ULL;
SPDK_WARNLOG("NvmeTimeoutValue (in seconds) was renamed to TimeoutUsec (in microseconds)\n");
SPDK_WARNLOG("Please update your configuration file\n");
}
} else { } else {
SPDK_WARNLOG("NvmeTimeoutValue was renamed to Timeout\n"); g_timeout_us = timeout * 1000000ULL;
SPDK_WARNLOG("Timeout (in seconds) was renamed to TimeoutUsec (in microseconds)\n");
SPDK_WARNLOG("Please update your configuration file\n"); SPDK_WARNLOG("Please update your configuration file\n");
} }
} }
if (g_timeout > 0) { if (g_timeout_us > 0) {
val = spdk_conf_section_get_val(sp, "ActionOnTimeout"); val = spdk_conf_section_get_val(sp, "ActionOnTimeout");
if (val != NULL) { if (val != NULL) {
if (!strcasecmp(val, "Reset")) { if (!strcasecmp(val, "Reset")) {
@ -1566,8 +1579,8 @@ bdev_nvme_get_spdk_running_config(FILE *fp)
"# this key to get the default behavior.\n"); "# this key to get the default behavior.\n");
fprintf(fp, "RetryCount %d\n", spdk_nvme_retry_count); fprintf(fp, "RetryCount %d\n", spdk_nvme_retry_count);
fprintf(fp, "\n" fprintf(fp, "\n"
"# Timeout for each command, in seconds. If 0, don't track timeouts.\n"); "# Timeout for each command, in microseconds. If 0, don't track timeouts.\n");
fprintf(fp, "Timeout %d\n", g_timeout); fprintf(fp, "Timeout %"PRIu64"\n", g_timeout_us);
fprintf(fp, "\n" fprintf(fp, "\n"
"# Action to take on command time out. Only valid when Timeout is greater\n" "# Action to take on command time out. Only valid when Timeout is greater\n"

View File

@ -2015,7 +2015,7 @@ spdk_nvme_ctrlr_register_aer_callback(struct spdk_nvme_ctrlr *ctrlr,
void void
spdk_nvme_ctrlr_register_timeout_callback(struct spdk_nvme_ctrlr *ctrlr, spdk_nvme_ctrlr_register_timeout_callback(struct spdk_nvme_ctrlr *ctrlr,
uint32_t nvme_timeout, spdk_nvme_timeout_cb cb_fn, void *cb_arg) uint64_t timeout_us, spdk_nvme_timeout_cb cb_fn, void *cb_arg)
{ {
struct spdk_nvme_ctrlr_process *active_proc; struct spdk_nvme_ctrlr_process *active_proc;
@ -2023,7 +2023,7 @@ spdk_nvme_ctrlr_register_timeout_callback(struct spdk_nvme_ctrlr *ctrlr,
active_proc = spdk_nvme_ctrlr_get_current_process(ctrlr); active_proc = spdk_nvme_ctrlr_get_current_process(ctrlr);
if (active_proc) { if (active_proc) {
active_proc->timeout_ticks = nvme_timeout * spdk_get_ticks_hz(); active_proc->timeout_ticks = timeout_us * spdk_get_ticks_hz() / 1000000ULL;
active_proc->timeout_cb_fn = cb_fn; active_proc->timeout_cb_fn = cb_fn;
active_proc->timeout_cb_arg = cb_arg; active_proc->timeout_cb_arg = cb_arg;
} }