From: Nilay Shroff <nilay@linux.ibm.com>
To: Yu Kuai <yukuai@kernel.org>, Jens Axboe <axboe@kernel.dk>,
Tejun Heo <tj@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>, Keith Busch <kbusch@kernel.org>,
Sagi Grimberg <sagi@grimberg.me>,
Alasdair Kergon <agk@redhat.com>,
Benjamin Marzinski <bmarzins@redhat.com>,
Mike Snitzer <snitzer@kernel.org>,
Mikulas Patocka <mpatocka@redhat.com>,
Dongsheng Yang <dongsheng.yang@linux.dev>,
Zheng Gu <cengku@gmail.com>, Coly Li <colyli@fygo.io>,
Kent Overstreet <kent.overstreet@linux.dev>,
Josef Bacik <josef@toxicpanda.com>, Yu Kuai <yukuai@fygo.io>,
linux-block@vger.kernel.org, cgroups@vger.kernel.org,
linux-nvme@lists.infradead.org, dm-devel@lists.linux.dev,
linux-bcache@vger.kernel.org
Subject: Re: [RFC PATCH v1 01/17] nvme-multipath: retarget failedover bios from requeue work
Date: Sat, 18 Jul 2026 00:42:08 +0530 [thread overview]
Message-ID: <6baae2af-640e-48bd-9909-977cd316c8d5@linux.ibm.com> (raw)
In-Reply-To: <20260704195124.1375075-2-yukuai@kernel.org>
On 7/5/26 1:21 AM, Yu Kuai wrote:
> From: Yu Kuai <yukuai@fygo.io>
>
> bio_set_dev() is about to become explicitly sleepable because it can
> associate the bio with a blkg for the destination queue. NVMe failover
> can run from request completion context, and nvme_failover_req() also holds
> head->requeue_lock with interrupts disabled while it steals bios from the
> failed request. Calling bio_set_dev() there is not safe once the helper is
> allowed to sleep.
>
> The requeue lock only protects head->requeue_list. Keep the list
> manipulation under that lock, but defer retargeting to nvme_requeue_work(),
> which already drains the list from process context before resubmitting each
> bio. The bios remain private to the requeue list until the worker pops
> them, so moving the device switch there preserves the existing retry flow
> while avoiding a sleepable helper in completion context.
>
> Signed-off-by: Yu Kuai <yukuai@fygo.io>
> ---
> drivers/nvme/host/multipath.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
> index 9b9a657fa330..76baa180ae1c 100644
> --- a/drivers/nvme/host/multipath.c
> +++ b/drivers/nvme/host/multipath.c
> @@ -149,7 +149,6 @@ void nvme_failover_req(struct request *req)
> struct nvme_ns *ns = req->q->queuedata;
> u16 status = nvme_req(req)->status & NVME_SCT_SC_MASK;
> unsigned long flags;
> - struct bio *bio;
>
> nvme_mpath_clear_current_path(ns);
> atomic_long_inc(&ns->failover);
> @@ -165,8 +164,6 @@ void nvme_failover_req(struct request *req)
> }
>
> spin_lock_irqsave(&ns->head->requeue_lock, flags);
> - for (bio = req->bio; bio; bio = bio->bi_next)
> - bio_set_dev(bio, ns->head->disk->part0);
> blk_steal_bios(&ns->head->requeue_list, req);
> spin_unlock_irqrestore(&ns->head->requeue_lock, flags);
>
> @@ -684,6 +681,7 @@ static void nvme_requeue_work(struct work_struct *work)
> next = bio->bi_next;
> bio->bi_next = NULL;
>
> + bio_set_dev(bio, head->disk->part0);
> submit_bio_noacct(bio);
What happens if bio_set_dev() fails to associate a blkg? From what
I understand, bio_associate_blkg() may fail, leaving bio->bi_blkg
set to NULL. Later, submit_bio_noacct() can invoke blkcg-related
helpers such as blk_should_throtl(), which expect a valid bio->bi_blkg.
However if bio->bi_blkg is NULL then accessing it without NULL check
could crash the kernel. This is probably not a bug introduced with your
changes, but you may want to check it.
The question is, is bio_associate_blkg() guaranteed never to fail, or
should the failure be handled explicitly before the bio is resubmitted?
I also skimmed through the rest of the series. However, as Christoph
mentioned in an earlier thread, we may be moving away from non-blocking
blkg allocation altogether. If that's the direction we're taking, this
series will likely need to be reworked. I'd therefore prefer to wait for
the next revision before reviewing the other patches.
Thanks,
--Nilay
next prev parent reply other threads:[~2026-07-17 19:13 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-04 19:51 [RFC PATCH v1 00/17] blk-cgroup: protect blkgs with blkcg_mutex Yu Kuai
2026-07-04 19:51 ` [RFC PATCH v1 01/17] nvme-multipath: retarget failedover bios from requeue work Yu Kuai
2026-07-09 6:10 ` Christoph Hellwig
2026-07-13 9:29 ` Hannes Reinecke
2026-07-13 12:12 ` Christoph Hellwig
2026-07-14 1:21 ` yu kuai
2026-07-17 19:12 ` Nilay Shroff [this message]
2026-07-04 19:51 ` [RFC PATCH v1 02/17] dm thin: avoid bio_set_dev under pool lock Yu Kuai
2026-07-04 19:51 ` [RFC PATCH v1 03/17] dm snapshot: avoid bio_set_dev in locked map paths Yu Kuai
2026-07-04 19:51 ` [RFC PATCH v1 04/17] blk-throttle: protect throttle state with td lock Yu Kuai
2026-07-04 19:51 ` [RFC PATCH v1 05/17] block: add bio_alloc_atomic() for atomic bio users Yu Kuai
2026-07-04 19:51 ` [RFC PATCH v1 06/17] blk-cgroup: support non-blocking bio association Yu Kuai
2026-07-09 6:13 ` Christoph Hellwig
2026-07-04 19:51 ` [RFC PATCH v1 07/17] block: support non-blocking bio allocation with a bdev Yu Kuai
2026-07-09 6:15 ` Christoph Hellwig
2026-07-09 10:02 ` yu kuai
2026-07-04 19:51 ` [RFC PATCH v1 08/17] bcache: avoid sleeping blkg association from locked paths Yu Kuai
2026-07-04 19:51 ` [RFC PATCH v1 09/17] dm bufio: avoid blkg association from GFP_NOWAIT bio init Yu Kuai
2026-07-04 19:51 ` [RFC PATCH v1 10/17] dm pcache: handle non-blocking bio clone init failure Yu Kuai
2026-07-04 19:51 ` [RFC PATCH v1 11/17] block: avoid scheduling from non-blocking helper allocations Yu Kuai
2026-07-04 19:51 ` [RFC PATCH v1 12/17] dm: avoid sleeping blkg association from NOWAIT remaps Yu Kuai
2026-07-04 19:51 ` [RFC PATCH v1 13/17] bfq: avoid blkg lookup from locked cgroup update Yu Kuai
2026-07-04 19:51 ` [RFC PATCH v1 14/17] blk-cgroup: protect blkgs with blkcg_mutex Yu Kuai
2026-07-04 19:51 ` [RFC PATCH v1 15/17] blk-cgroup: remove blkg radix tree preloading Yu Kuai
2026-07-09 6:18 ` Christoph Hellwig
2026-07-09 9:57 ` yu kuai
2026-07-04 19:51 ` [RFC PATCH v1 16/17] blk-cgroup: allocate blkgs in blkg_create Yu Kuai
2026-07-04 19:51 ` [RFC PATCH v1 17/17] blk-cgroup: share blkg creation between lookup and config prep Yu Kuai
2026-07-09 6:09 ` [RFC PATCH v1 00/17] blk-cgroup: protect blkgs with blkcg_mutex Christoph Hellwig
2026-07-09 10:08 ` yu kuai
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=6baae2af-640e-48bd-9909-977cd316c8d5@linux.ibm.com \
--to=nilay@linux.ibm.com \
--cc=agk@redhat.com \
--cc=axboe@kernel.dk \
--cc=bmarzins@redhat.com \
--cc=cengku@gmail.com \
--cc=cgroups@vger.kernel.org \
--cc=colyli@fygo.io \
--cc=dm-devel@lists.linux.dev \
--cc=dongsheng.yang@linux.dev \
--cc=hch@lst.de \
--cc=josef@toxicpanda.com \
--cc=kbusch@kernel.org \
--cc=kent.overstreet@linux.dev \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=mpatocka@redhat.com \
--cc=sagi@grimberg.me \
--cc=snitzer@kernel.org \
--cc=tj@kernel.org \
--cc=yukuai@fygo.io \
--cc=yukuai@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox