[PATCH RFC 4/5] nvme: add sysfs attribute to change IO timeout per nvme controller
Maurizio Lombardi
mlombard at arkamax.eu
Wed Feb 18 05:28:03 PST 2026
On Tue Feb 17, 2026 at 9:25 PM CET, Mohamed Khalfella wrote:
>> @@ -4169,6 +4169,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, struct nvme_ns_info *info)
>> mutex_unlock(&ctrl->namespaces_lock);
>> goto out_unlink_ns;
>> }
>> + blk_queue_rq_timeout(ns->queue, ctrl->io_timeout);
>
> Given that io tagset->timeout has been initialized to ctrl->io_timeout
> Do we still need the line above?
Yes, the line is necessary. While the tagset is initialized with
ctrl->io_timeout, that happens only once during tagset allocation.
If the user later changes io_timeout via sysfs, ctrl->io_timeout is updated,
but the tagset->timeout remains at the old default value. I deliberately
do not update tagset->timeout in the sysfs handler because the tagset
lifetime is tied to the controller state (e.g., it may be freed during a
controller reset). Attempting to update the tagset from the sysfs path
introduces a race condition where we might dereference a pointer to
a tagset that is being destroyed.
Therefore, when a new namespace is allocated (nvme_alloc_ns), the block
layer initializes the queue using the stale tagset->timeout. We must
explicitly override that with the current ctrl->io_timeout to
ensure the new namespace respects the runtime configuration.
Maurizio
More information about the Linux-nvme
mailing list