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:
parent
ee9db7dac0
commit
b1da5cecaa
@ -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,
|
||||
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
|
||||
|
||||
The build system now generates a combined shared library (libspdk.so) that may be used
|
||||
|
@ -688,12 +688,12 @@ typedef void (*spdk_nvme_timeout_cb)(void *cb_arg,
|
||||
* for timeout callback.
|
||||
*
|
||||
* \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_arg Argument to the callback function.
|
||||
*/
|
||||
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.
|
||||
|
@ -102,7 +102,7 @@ enum timeout_action {
|
||||
|
||||
static int g_hot_insert_nvme_controller_index = 0;
|
||||
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 bool g_nvme_hotplug_enabled = false;
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -1099,6 +1099,7 @@ bdev_nvme_library_init(void)
|
||||
size_t i;
|
||||
struct nvme_probe_ctx *probe_ctx = NULL;
|
||||
int retry_count;
|
||||
int timeout;
|
||||
uint32_t local_nvme_num = 0;
|
||||
|
||||
sp = spdk_conf_find_section(NULL, "Nvme");
|
||||
@ -1124,17 +1125,29 @@ bdev_nvme_library_init(void)
|
||||
|
||||
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 */
|
||||
if ((g_timeout = spdk_conf_section_get_intval(sp, "NvmeTimeoutValue")) < 0) {
|
||||
g_timeout = 0;
|
||||
timeout = spdk_conf_section_get_intval(sp, "Timeout");
|
||||
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 {
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
if (g_timeout > 0) {
|
||||
if (g_timeout_us > 0) {
|
||||
val = spdk_conf_section_get_val(sp, "ActionOnTimeout");
|
||||
if (val != NULL) {
|
||||
if (!strcasecmp(val, "Reset")) {
|
||||
@ -1566,8 +1579,8 @@ bdev_nvme_get_spdk_running_config(FILE *fp)
|
||||
"# this key to get the default behavior.\n");
|
||||
fprintf(fp, "RetryCount %d\n", spdk_nvme_retry_count);
|
||||
fprintf(fp, "\n"
|
||||
"# Timeout for each command, in seconds. If 0, don't track timeouts.\n");
|
||||
fprintf(fp, "Timeout %d\n", g_timeout);
|
||||
"# Timeout for each command, in microseconds. If 0, don't track timeouts.\n");
|
||||
fprintf(fp, "Timeout %"PRIu64"\n", g_timeout_us);
|
||||
|
||||
fprintf(fp, "\n"
|
||||
"# Action to take on command time out. Only valid when Timeout is greater\n"
|
||||
|
@ -2015,7 +2015,7 @@ spdk_nvme_ctrlr_register_aer_callback(struct spdk_nvme_ctrlr *ctrlr,
|
||||
|
||||
void
|
||||
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;
|
||||
|
||||
@ -2023,7 +2023,7 @@ spdk_nvme_ctrlr_register_timeout_callback(struct spdk_nvme_ctrlr *ctrlr,
|
||||
|
||||
active_proc = spdk_nvme_ctrlr_get_current_process(ctrlr);
|
||||
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_arg = cb_arg;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user