nvme: Support per-device timeout settings
Subsystems (2)
PATCH 1/1 nvme: Support per-device timeout settings
The current 'admin_timeout' and 'io_timeout' parameters in the NVMe driver are global, meaning they apply to all NVMe devices in the system. However, in certain scenarios, it is necessary to set separate timeout values for different types of NVMe devices.
To address this requirement, we propose adding two new fields, 'admin_timeout' and 'io_timeout', to the sysfs interface for each NVMe device. By default, these values will be consistent with the global parameters. If a user sets these values individually for a specific device, the user-defined values will take precedence.
Usage example:
To set admin_timeout=100 and io_timeout=50 for the NVMe device nvme1, use the following commands:
echo 100 > /sys/class/nvme/nvme1/admin_timeout
echo 50 > /sys/class/nvme/nvme1/io_timeout
--- drivers/nvme/host/apple.c | 2 +- drivers/nvme/host/core.c | 6 ++-- drivers/nvme/host/nvme.h | 2 +- drivers/nvme/host/pci.c | 4 +-- drivers/nvme/host/rdma.c | 2 +- drivers/nvme/host/sysfs.c | 62 +++++++++++++++++++++++++++++++++++++++ drivers/nvme/host/tcp.c | 2 +- 7 files changed, 71 insertions(+), 9 deletions(-)
drivers/nvme/host/apple.c +1 -1
@@ -821,7 +821,7 @@ static void apple_nvme_disable(struct apple_nvme *anv, bool shutdown)* doing a safe shutdown. */ if (!dead && shutdown && freeze) -nvme_wait_freeze_timeout (&anv->ctrl,NVME_IO_TIMEOUT ); +nvme_wait_freeze_timeout (&anv->ctrl);nvme_quiesce_io_queues (&anv->ctrl);
drivers/nvme/host/core.c +3 -3
@@ -725,11 +725,10 @@ void nvme_init_request(struct request *req, struct nvme_command *cmd)struct nvme_ns *ns = req->q->disk->private_data; logging_enabled = ns->head->passthru_err_log_enabled; - req->timeout =NVME_IO_TIMEOUT ; }else {/* no queuedata implies admin queue */ logging_enabled = nr->ctrl->passthru_err_log_enabled; - req->timeout =NVME_ADMIN_TIMEOUT ; } + req->timeout = req->q->rq_timeout;if (!logging_enabled) req->rq_flags |=RQF_QUIET ;
@@ -5174,10 +5173,11 @@ void nvme_unfreeze(struct nvme_ctrl *ctrl) }EXPORT_SYMBOL_GPL (nvme_unfreeze); -int nvme_wait_freeze_timeout (struct nvme_ctrl *ctrl,long timeout) +int nvme_wait_freeze_timeout (struct nvme_ctrl *ctrl) {struct nvme_ns *ns;int srcu_idx; +long timeout = ctrl->tagset->timeout; srcu_idx =srcu_read_lock (&ctrl->srcu); list_for_each_entry_srcu(ns, &ctrl->namespaces, list,
drivers/nvme/host/nvme.h +1 -1
@@ -833,7 +833,7 @@ void nvme_sync_queues(struct nvme_ctrl *ctrl);void nvme_sync_io_queues (struct nvme_ctrl *ctrl);void nvme_unfreeze (struct nvme_ctrl *ctrl);void nvme_wait_freeze (struct nvme_ctrl *ctrl); -int nvme_wait_freeze_timeout (struct nvme_ctrl *ctrl,long timeout); +int nvme_wait_freeze_timeout (struct nvme_ctrl *ctrl);void nvme_start_freeze (struct nvme_ctrl *ctrl);static inline enum req_op nvme_req_op (struct nvme_command *cmd)
drivers/nvme/host/pci.c +2 -2
@@ -2690,7 +2690,7 @@ static bool __nvme_delete_io_queues(struct nvme_dev *dev, u8 opcode)unsigned long timeout; retry: - timeout =NVME_ADMIN_TIMEOUT ; + timeout = dev->ctrl.admin_q->rq_timeout;while (nr_queues >0 ) {if (nvme_delete_queue (&dev->queues[nr_queues], opcode))break ;
@@ -2871,7 +2871,7 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown)* if doing a safe shutdown. */ if (!dead && shutdown) -nvme_wait_freeze_timeout (&dev->ctrl,NVME_IO_TIMEOUT ); +nvme_wait_freeze_timeout (&dev->ctrl); }nvme_quiesce_io_queues (&dev->ctrl);
drivers/nvme/host/rdma.c +1 -1
@@ -888,7 +888,7 @@ static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new)if (!new) {nvme_start_freeze (&ctrl->ctrl);nvme_unquiesce_io_queues (&ctrl->ctrl); -if (!nvme_wait_freeze_timeout (&ctrl->ctrl,NVME_IO_TIMEOUT )) { +if (!nvme_wait_freeze_timeout (&ctrl->ctrl)) {/* * If we timed out waiting for freeze we are likely to * be stuck. Fail the controller initialization just
drivers/nvme/host/sysfs.c +62 -0
74 lines not on this page · raw message
drivers/nvme/host/tcp.c +1 -1
@@ -2169,7 +2169,7 @@ static int nvme_tcp_configure_io_queues(struct nvme_ctrl *ctrl, bool new)if (!new) {nvme_start_freeze (ctrl);nvme_unquiesce_io_queues (ctrl); -if (!nvme_wait_freeze_timeout (ctrl,NVME_IO_TIMEOUT )) { +if (!nvme_wait_freeze_timeout (ctrl)) {/* * If we timed out waiting for freeze we are likely to * be stuck. Fail the controller initialization just
Signature · 1 line
2.39.5 (Apple Git-154)
Keith Busch
maintainerQuoted 13 lines · Bitao Hu
The current '
admin_timeout' and 'io_timeout' parameters in the NVMe driver are global, meaning they apply to all NVMe devices in the system. However, in certain scenarios, it is necessary to set separate timeout values for different types of NVMe devices.To address this requirement, we propose adding two new fields, '
admin_timeout' and 'io_timeout', to the sysfs interface for each NVMe device. By default, these values will be consistent with the global parameters. If a user sets these values individually for a specific device, the user-defined values will take precedence.
Quoted 6 lines
Usage example:
To set admin_timeout=100 and io_timeout=50 for the NVMe device nvme1, use the following commands:echo 100 >
/sys/class/nvme/nvme1/admin_timeout
echo 50 >/sys/class/nvme/nvme1/io_timeout
We can already modify the io timeout using the block device's attribute. If you want 50 seconds on all nvme namespaces attached to nvme1, you could do this today:
echo 50000 | tee /sys/class/nvme/nvme1/nvme*n*/queue/io_timeout
We don't have a good way to do that on the admin queue, but I'm not sure if there's a strong need for it: all the driver initiated commands should be very fast for any device (they're just identifies and logs), so a module wide parameter should be good enough for that.
Any long running admin command is almost certainly coming from user space using the passthrough interface, and you can already specify the desired timeout for that specific command.