[PATCH v5 1/2] nvme-multipath: apply delayed_removal_secs changes to a pending removal

sashiko-bot at kernel.org sashiko-bot at kernel.org
Thu Nov 19 03:23:57 PST 2026


Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] nvme-multipath: clearing delayed_removal_secs fails to kick
  requeue_work
- [Low] nvme-multipath: 32-bit overflow in sec * HZ in
  delayed_removal_secs_store()
--

commit 6d5b135aa1c8a348dae91223319bfb27c4526bcb
Author: Qiliang Yuan <qiliang.yuan at linux.dev>

nvme-multipath: apply delayed_removal_secs changes to a pending removal

This commit updates delayed_removal_secs_store() to cancel and requeue
any pending head->remove_work with the new delay, and moves the
remove_work cancellation in nvme_init_ns_head() under subsys->lock.

> diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
> index ae8059366b57d..51c59cc3ea246 100644
> --- a/drivers/nvme/host/multipath.c
> +++ b/drivers/nvme/host/multipath.c
> @@ -1242,6 +1242,12 @@ static ssize_t delayed_removal_secs_store(struct device *dev,
>  	mutex_lock(&head->subsys->lock);
>  	head->delayed_removal_secs = sec;
>  	assign_bit(NVME_NSHEAD_QUEUE_IF_NO_PATH, &head->flags, sec);
> +	/*
> +	 * Apply the new delay to a removal that is still pending. The module
> +	 * reference taken for it carries over to the requeued work.
> +	 */
> +	if (cancel_delayed_work(&head->remove_work))
> +		queue_delayed_work(nvme_wq, &head->remove_work, sec * HZ);

[Severity: Low]
Can sec * HZ overflow 32-bit unsigned int arithmetic before being widened
to unsigned long?  sec is parsed with kstrtouint() without an upper bound
(and nvme_mpath_remove_disk() does the same head->delayed_removal_secs * HZ
multiplication), so a value above UINT_MAX / HZ wraps the delay and can
remove the head right away even though NVME_NSHEAD_QUEUE_IF_NO_PATH is set.
Using secs_to_jiffies() or clamping sec would avoid the wrap.

>  	mutex_unlock(&head->subsys->lock);
>  	/*
>  	 * Ensure that update to NVME_NSHEAD_QUEUE_IF_NO_PATH is seen

[Severity: Medium]
When sec is set to 0 while head->remove_work is not pending, does this
leave bios that were already queued on head->requeue_list stuck?

If paths are still present on head->list in NVME_ANA_INACCESSIBLE or
NVME_ANA_PERSISTENT_LOSS states, remove_work is not queued, yet
nvme_available_path() returns nvme_mpath_queue_if_no_path(head) and
nvme_ns_head_submit_bio() parks incoming bios on head->requeue_list while
NVME_NSHEAD_QUEUE_IF_NO_PATH is set.  Clearing delayed_removal_secs to 0
clears NVME_NSHEAD_QUEUE_IF_NO_PATH, but without scheduling
head->requeue_work after synchronize_srcu(&head->srcu) (as
fail_on_ctrl_loss_store() does), nothing drains and fails the bios already
on head->requeue_list.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261119-bug-nvme-mpath-set-live-srcu-v5-0-e1483e2e447f@linux.dev?part=1



More information about the Linux-nvme mailing list