mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
nvme: add a timeout for Format NVM commands
Format commands need a longer timeout. Reviewed by: seuros, chuck Differential Revision: https://reviews.freebsd.org/D59827
This commit is contained in:
1 parent
894f70a2bd
commit
5258b44e84
3 files changed
+30
No files matched your search
@@ -1843,6 +1843,12 @@ nvme_ctrlr_construct(struct nvme_controller *ctrlr, device_t dev)
|
||||
timeout_period = max(timeout_period, NVME_MIN_TIMEOUT_PERIOD);
|
||||
ctrlr->timeout_period = timeout_period;
|
||||
|
||||
timeout_period = NVME_FORMAT_TIMEOUT_PERIOD;
|
||||
TUNABLE_INT_FETCH("hw.nvme.format_timeout_period", &timeout_period);
|
||||
timeout_period = min(timeout_period, NVME_MAX_FORMAT_TIMEOUT_PERIOD);
|
||||
timeout_period = max(timeout_period, NVME_MIN_TIMEOUT_PERIOD);
|
||||
ctrlr->format_timeout_period = timeout_period;
|
||||
|
||||
nvme_retry_count = NVME_DEFAULT_RETRY_COUNT;
|
||||
TUNABLE_INT_FETCH("hw.nvme.retry_count", &nvme_retry_count);
|
||||
|
||||
|
||||
@@ -81,8 +81,10 @@ MALLOC_DECLARE(M_NVME);
|
||||
|
||||
#define NVME_ADMIN_TIMEOUT_PERIOD (60) /* in seconds */
|
||||
#define NVME_DEFAULT_TIMEOUT_PERIOD (30) /* in seconds */
|
||||
#define NVME_FORMAT_TIMEOUT_PERIOD (10 * 60) /* in seconds */
|
||||
#define NVME_MIN_TIMEOUT_PERIOD (5)
|
||||
#define NVME_MAX_TIMEOUT_PERIOD (120)
|
||||
#define NVME_MAX_FORMAT_TIMEOUT_PERIOD (60 * 60)
|
||||
|
||||
#define NVME_DEFAULT_RETRY_COUNT (4)
|
||||
|
||||
@@ -302,6 +304,7 @@ struct nvme_controller {
|
||||
|
||||
/** timeout period in seconds */
|
||||
uint32_t admin_timeout_period;
|
||||
uint32_t format_timeout_period;
|
||||
uint32_t timeout_period;
|
||||
|
||||
/** doorbell stride */
|
||||
|
||||
@@ -131,6 +131,22 @@ nvme_sysctl_timeout_period(SYSCTL_HANDLER_ARGS)
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
nvme_sysctl_format_timeout_period(SYSCTL_HANDLER_ARGS)
|
||||
{
|
||||
uint32_t *ptr = arg1;
|
||||
uint32_t newval = *ptr;
|
||||
int error = sysctl_handle_int(oidp, &newval, 0, req);
|
||||
|
||||
if (error || req->newptr == NULL)
|
||||
return (error);
|
||||
if (newval > NVME_MAX_FORMAT_TIMEOUT_PERIOD ||
|
||||
newval < NVME_MIN_TIMEOUT_PERIOD)
|
||||
return (EINVAL);
|
||||
*ptr = newval;
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
nvme_qpair_reset_stats(struct nvme_qpair *qpair)
|
||||
{
|
||||
@@ -279,6 +295,11 @@ nvme_sysctl_initialize_ctrlr(struct nvme_controller *ctrlr)
|
||||
&ctrlr->timeout_period, 0, nvme_sysctl_timeout_period, "IU",
|
||||
"Timeout period for I/O queues (in seconds)");
|
||||
|
||||
SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO,
|
||||
"format_timeout_period", CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE,
|
||||
&ctrlr->format_timeout_period, 0, nvme_sysctl_format_timeout_period,
|
||||
"IU", "Timeout period for Format NVM commands (in seconds)");
|
||||
|
||||
SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO,
|
||||
"num_cmds", CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_MPSAFE,
|
||||
ctrlr, offsetof(struct nvme_qpair, num_cmds),
|
||||
|
||||
Reference in new issue
Block a user