All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nilay Shroff <nilay@linux.ibm.com>
To: John Garry <john.garry@linux.dev>,
	kbusch@kernel.org, axboe@kernel.dk, hch@lst.de, sagi@grimberg.me
Cc: linux-nvme@lists.infradead.org, John Garry <john.g.garry@oracle.com>
Subject: Re: [PATCH] nvme: swap synchronization ordering in nvme_remove_head()
Date: Wed, 8 Jul 2026 19:05:24 +0530	[thread overview]
Message-ID: <6849f4db-500d-41ec-b6ac-7bc82fa6ea73@linux.ibm.com> (raw)
In-Reply-To: <20260707135744.1470014-1-john.garry@linux.dev>

Hi John,

On 7/7/26 7:27 PM, John Garry wrote:
> From: John Garry <john.g.garry@oracle.com>
> 
> sashiko bot reported a potential issue in the requeue handling in [0] -
> the code there is same as the NVMe driver.
> 
> The issue is that when we schedule the requeue work, if a bio is added to
> the requeue list afterwards in nvme_ns_head_submit_bio(), it is missed by
> the requeue worker.
> 
> This issue can be recreated by hacking a large delay in the bio submission
> requeue path:
> 
>          } else if (nvme_available_path(head)) {
>                  dev_warn_ratelimited(dev, "no usable path - requeuing I/O\n");
> 
> +               msleep(30000);
>                  spin_lock_irq(&head->requeue_lock);
>                  bio_list_add(&head->requeue_list, bio);
>                  spin_unlock_irq(&head->requeue_lock);
> 
> 
> Then if we issue a write after removing all paths, a hang can be seen:
> 
> # echo 20 > /sys/devices/virtual/nvme-subsystem/nvme-subsys1/nvme1n1/delayed_removal_secs
> #
> # ./ini_nvme_teardown.sh
> [   25.877224] nvme nvme1: Removing ctrl: NQN "nvme-test-target"
> [   25.939569] nvme nvme2: Removing ctrl: NQN "nvme-test-target"
> #
> # xfs_io -d -C "pwrite -b 64k -V 1 -D 0 64k" /dev/nvme1n1p1
> [   29.883653] block nvme1n1: no usable path - requeuing I/O
> 
> Fix by re-ordering the SRCU synchronization and scheduling the requeue
> work.
> 
> [0] https://lore.kernel.org/linux-scsi/20260703102918.3723667-1-john.g.garry@oracle.com/T/#m72af1f29deb0ebfb2973464207f201f1be1f660c
> 
> Signed-off-by: John Garry <john.g.garry@oracle.com>
> ---
> I am not sure if we still require the synchronize_srcu() after nvme_cdev_del().
> 
> diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
> index 016b6b0128c7..0b017eeb82b2 100644
> --- a/drivers/nvme/host/multipath.c
> +++ b/drivers/nvme/host/multipath.c
> @@ -690,14 +690,15 @@ static void nvme_remove_head(struct nvme_ns_head *head)
>   {
>   	if (test_and_clear_bit(NVME_NSHEAD_DISK_LIVE, &head->flags)) {
>   		/*
> -		 * requeue I/O after NVME_NSHEAD_DISK_LIVE has been cleared
> -		 * to allow multipath to fail all I/O.
> +		 * Requeue I/O after NVME_NSHEAD_DISK_LIVE has been cleared
> +		 * to allow multipath to fail all I/O. First synchronize to
> +		 * add any bios to the requeue list.
>   		 */
> +		synchronize_srcu(&head->srcu);
>   		kblockd_schedule_work(&head->requeue_work);
>   
>   		if (test_and_clear_bit(NVME_NSHEAD_CDEV_LIVE, &head->flags))
>   			nvme_cdev_del(&head->cdev, &head->cdev_device);
> -		synchronize_srcu(&head->srcu);
>   		del_gendisk(head->disk);
>   	}
>   	nvme_put_ns_head(head);

With the above change now I wonder do we really need to schedule ->requeue_work
from nvme_mpath_put_disk()? Maybe we still want to keep it as a defensive
"safety net". Though having it doesn't harm but looks redundant.

Otherwise, this change look good to me,

Reviewed-by: Nilay Shroff <nilay@linux.ibm.com>



  parent reply	other threads:[~2026-07-08 13:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07 13:57 [PATCH] nvme: swap synchronization ordering in nvme_remove_head() John Garry
2026-07-08  9:17 ` Christoph Hellwig
2026-07-08 13:35 ` Nilay Shroff [this message]
2026-07-08 19:14 ` Keith Busch
2026-07-14 13:20 ` Hannes Reinecke

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=6849f4db-500d-41ec-b6ac-7bc82fa6ea73@linux.ibm.com \
    --to=nilay@linux.ibm.com \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=john.g.garry@oracle.com \
    --cc=john.garry@linux.dev \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /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.