lib/nvme: change timeout in wait_for_completions to usec
This allows for much more granular control over the timeout. Signed-off-by: Seth Howell <seth.howell@intel.com> Change-Id: Ib23de21e60eec4207c55320579699edf284f4e16 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3794 Community-CI: Mellanox Build Bot Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
85ff3fcea6
commit
b3bb3a1bbf
@ -164,7 +164,7 @@ nvme_wait_for_completion(struct spdk_nvme_qpair *qpair,
|
|||||||
* \param qpair queue to poll
|
* \param qpair queue to poll
|
||||||
* \param status completion status. The user must fill this structure with zeroes before calling
|
* \param status completion status. The user must fill this structure with zeroes before calling
|
||||||
* this function
|
* this function
|
||||||
* \param timeout_in_secs optional timeout
|
* \param timeout_in_usecs optional timeout
|
||||||
*
|
*
|
||||||
* \return 0 if command completed without error,
|
* \return 0 if command completed without error,
|
||||||
* -EIO if command completed with error,
|
* -EIO if command completed with error,
|
||||||
@ -176,13 +176,13 @@ nvme_wait_for_completion(struct spdk_nvme_qpair *qpair,
|
|||||||
int
|
int
|
||||||
nvme_wait_for_completion_timeout(struct spdk_nvme_qpair *qpair,
|
nvme_wait_for_completion_timeout(struct spdk_nvme_qpair *qpair,
|
||||||
struct nvme_completion_poll_status *status,
|
struct nvme_completion_poll_status *status,
|
||||||
uint64_t timeout_in_secs)
|
uint64_t timeout_in_usecs)
|
||||||
{
|
{
|
||||||
uint64_t timeout_tsc = 0;
|
uint64_t timeout_tsc = 0;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
if (timeout_in_secs) {
|
if (timeout_in_usecs) {
|
||||||
timeout_tsc = spdk_get_ticks() + timeout_in_secs * spdk_get_ticks_hz();
|
timeout_tsc = spdk_get_ticks() + timeout_in_usecs * spdk_get_ticks_hz() / SPDK_SEC_TO_USEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (status->done == false) {
|
while (status->done == false) {
|
||||||
|
@ -653,7 +653,7 @@ static int nvme_ctrlr_set_intel_support_log_pages(struct spdk_nvme_ctrlr *ctrlr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (nvme_wait_for_completion_timeout(ctrlr->adminq, status,
|
if (nvme_wait_for_completion_timeout(ctrlr->adminq, status,
|
||||||
ctrlr->opts.admin_timeout_ms / 1000)) {
|
ctrlr->opts.admin_timeout_ms * 1000)) {
|
||||||
spdk_free(log_page_directory);
|
spdk_free(log_page_directory);
|
||||||
SPDK_WARNLOG("Intel log pages not supported on Intel drive!\n");
|
SPDK_WARNLOG("Intel log pages not supported on Intel drive!\n");
|
||||||
if (!status->timed_out) {
|
if (!status->timed_out) {
|
||||||
@ -738,7 +738,7 @@ nvme_ctrlr_set_arbitration_feature(struct spdk_nvme_ctrlr *ctrlr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (nvme_wait_for_completion_timeout(ctrlr->adminq, status,
|
if (nvme_wait_for_completion_timeout(ctrlr->adminq, status,
|
||||||
ctrlr->opts.admin_timeout_ms / 1000)) {
|
ctrlr->opts.admin_timeout_ms * 1000)) {
|
||||||
SPDK_ERRLOG("Timeout to set arbitration feature\n");
|
SPDK_ERRLOG("Timeout to set arbitration feature\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,8 @@
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define NVME_FABRIC_CONNECT_COMMAND_TIMEOUT 0
|
#define NVME_FABRIC_CONNECT_COMMAND_TIMEOUT 0
|
||||||
#else
|
#else
|
||||||
#define NVME_FABRIC_CONNECT_COMMAND_TIMEOUT 1
|
/* 500 millisecond timeout. */
|
||||||
|
#define NVME_FABRIC_CONNECT_COMMAND_TIMEOUT 500000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -896,7 +896,7 @@ int nvme_wait_for_completion_robust_lock(struct spdk_nvme_qpair *qpair,
|
|||||||
pthread_mutex_t *robust_mutex);
|
pthread_mutex_t *robust_mutex);
|
||||||
int nvme_wait_for_completion_timeout(struct spdk_nvme_qpair *qpair,
|
int nvme_wait_for_completion_timeout(struct spdk_nvme_qpair *qpair,
|
||||||
struct nvme_completion_poll_status *status,
|
struct nvme_completion_poll_status *status,
|
||||||
uint64_t timeout_in_secs);
|
uint64_t timeout_in_usecs);
|
||||||
|
|
||||||
struct spdk_nvme_ctrlr_process *nvme_ctrlr_get_process(struct spdk_nvme_ctrlr *ctrlr,
|
struct spdk_nvme_ctrlr_process *nvme_ctrlr_get_process(struct spdk_nvme_ctrlr *ctrlr,
|
||||||
pid_t pid);
|
pid_t pid);
|
||||||
|
@ -1233,15 +1233,15 @@ test_nvme_request_check_timeout(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct nvme_completion_poll_status g_status;
|
struct nvme_completion_poll_status g_status;
|
||||||
uint64_t completion_delay, timeout_in_secs;
|
uint64_t completion_delay_us, timeout_in_usecs;
|
||||||
int g_process_comp_result;
|
int g_process_comp_result;
|
||||||
|
|
||||||
int
|
int
|
||||||
spdk_nvme_qpair_process_completions(struct spdk_nvme_qpair *qpair, uint32_t max_completions)
|
spdk_nvme_qpair_process_completions(struct spdk_nvme_qpair *qpair, uint32_t max_completions)
|
||||||
{
|
{
|
||||||
spdk_delay_us(completion_delay * spdk_get_ticks_hz());
|
spdk_delay_us(completion_delay_us);
|
||||||
|
|
||||||
g_status.done = completion_delay < timeout_in_secs && g_process_comp_result == 0 ? true : false;
|
g_status.done = completion_delay_us < timeout_in_usecs && g_process_comp_result == 0 ? true : false;
|
||||||
|
|
||||||
return g_process_comp_result;
|
return g_process_comp_result;
|
||||||
}
|
}
|
||||||
@ -1256,9 +1256,9 @@ test_nvme_wait_for_completion(void)
|
|||||||
|
|
||||||
/* completion timeout */
|
/* completion timeout */
|
||||||
memset(&g_status, 0, sizeof(g_status));
|
memset(&g_status, 0, sizeof(g_status));
|
||||||
completion_delay = 2;
|
completion_delay_us = 2000000;
|
||||||
timeout_in_secs = 1;
|
timeout_in_usecs = 1000000;
|
||||||
rc = nvme_wait_for_completion_timeout(&qpair, &g_status, timeout_in_secs);
|
rc = nvme_wait_for_completion_timeout(&qpair, &g_status, timeout_in_usecs);
|
||||||
CU_ASSERT(g_status.timed_out == true);
|
CU_ASSERT(g_status.timed_out == true);
|
||||||
CU_ASSERT(g_status.done == false);
|
CU_ASSERT(g_status.done == false);
|
||||||
CU_ASSERT(rc == -ECANCELED);
|
CU_ASSERT(rc == -ECANCELED);
|
||||||
@ -1266,9 +1266,9 @@ test_nvme_wait_for_completion(void)
|
|||||||
/* spdk_nvme_qpair_process_completions returns error */
|
/* spdk_nvme_qpair_process_completions returns error */
|
||||||
memset(&g_status, 0, sizeof(g_status));
|
memset(&g_status, 0, sizeof(g_status));
|
||||||
g_process_comp_result = -1;
|
g_process_comp_result = -1;
|
||||||
completion_delay = 1;
|
completion_delay_us = 1000000;
|
||||||
timeout_in_secs = 2;
|
timeout_in_usecs = 2000000;
|
||||||
rc = nvme_wait_for_completion_timeout(&qpair, &g_status, timeout_in_secs);
|
rc = nvme_wait_for_completion_timeout(&qpair, &g_status, timeout_in_usecs);
|
||||||
CU_ASSERT(rc == -ECANCELED);
|
CU_ASSERT(rc == -ECANCELED);
|
||||||
CU_ASSERT(g_status.timed_out == true);
|
CU_ASSERT(g_status.timed_out == true);
|
||||||
CU_ASSERT(g_status.done == false);
|
CU_ASSERT(g_status.done == false);
|
||||||
@ -1279,9 +1279,9 @@ test_nvme_wait_for_completion(void)
|
|||||||
|
|
||||||
/* complete in time */
|
/* complete in time */
|
||||||
memset(&g_status, 0, sizeof(g_status));
|
memset(&g_status, 0, sizeof(g_status));
|
||||||
completion_delay = 1;
|
completion_delay_us = 1000000;
|
||||||
timeout_in_secs = 2;
|
timeout_in_usecs = 2000000;
|
||||||
rc = nvme_wait_for_completion_timeout(&qpair, &g_status, timeout_in_secs);
|
rc = nvme_wait_for_completion_timeout(&qpair, &g_status, timeout_in_usecs);
|
||||||
CU_ASSERT(g_status.timed_out == false);
|
CU_ASSERT(g_status.timed_out == false);
|
||||||
CU_ASSERT(g_status.done == true);
|
CU_ASSERT(g_status.done == true);
|
||||||
CU_ASSERT(rc == 0);
|
CU_ASSERT(rc == 0);
|
||||||
|
@ -318,7 +318,7 @@ nvme_wait_for_completion(struct spdk_nvme_qpair *qpair,
|
|||||||
int
|
int
|
||||||
nvme_wait_for_completion_timeout(struct spdk_nvme_qpair *qpair,
|
nvme_wait_for_completion_timeout(struct spdk_nvme_qpair *qpair,
|
||||||
struct nvme_completion_poll_status *status,
|
struct nvme_completion_poll_status *status,
|
||||||
uint64_t timeout_in_secs)
|
uint64_t timeout_in_usecs)
|
||||||
{
|
{
|
||||||
return nvme_wait_for_completion_robust_lock(qpair, status, NULL);
|
return nvme_wait_for_completion_robust_lock(qpair, status, NULL);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user