All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Qiliang Yuan" <qiliang.yuan@linux.dev>
Cc: linux-nvme@lists.infradead.org
Subject: Re: [PATCH v5 1/2] nvme-multipath: apply delayed_removal_secs changes to a pending removal
Date: Thu, 19 Nov 2026 11:23:57 +0000	[thread overview]
Message-ID: <sashiko-outbox-223024@kernel.org> (raw)
In-Reply-To: <20261119-bug-nvme-mpath-set-live-srcu-v5-1-e1483e2e447f@linux.dev>

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@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


  reply	other threads:[~2026-11-19 11:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 11:06 [PATCH v5 0/2] nvme-multipath: requeue work fixes Qiliang Yuan
2026-11-19 11:07 ` [PATCH v5 1/2] nvme-multipath: apply delayed_removal_secs changes to a pending removal Qiliang Yuan
2026-11-19 11:23   ` sashiko-bot [this message]
2026-11-19 14:22   ` Nilay Shroff
2026-11-20 17:25   ` Christoph Hellwig
2026-11-19 11:07 ` [PATCH v5 2/2] nvme-multipath: don't wait for a grace period in nvme_mpath_set_live() Qiliang Yuan
2026-11-20 17:26   ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-223024@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=qiliang.yuan@linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.