From: Bart Van Assche <bvanassche@acm.org>
To: Ross Lagerwall <ross.lagerwall@citrix.com>,
Christoph Hellwig <hch@infradead.org>,
Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] blk-mq: Fix stall due to recursive flush plug
Date: Fri, 14 Jul 2023 09:04:05 -0700 [thread overview]
Message-ID: <4399bb4f-8127-f9fb-fe47-ab02ec3566c9@acm.org> (raw)
In-Reply-To: <20230714101106.3635611-1-ross.lagerwall@citrix.com>
On 7/14/23 03:11, Ross Lagerwall wrote:
> diff --git a/block/blk-core.c b/block/blk-core.c
> index 99d8b9812b18..90de50082146 100644
> --- a/block/blk-core.c
> +++ b/block/blk-core.c
> @@ -1144,8 +1144,7 @@ void __blk_flush_plug(struct blk_plug *plug, bool from_schedule)
> {
> if (!list_empty(&plug->cb_list))
> flush_plug_callbacks(plug, from_schedule);
> - if (!rq_list_empty(plug->mq_list))
> - blk_mq_flush_plug_list(plug, from_schedule);
> + blk_mq_flush_plug_list(plug, from_schedule);
> /*
> * Unconditionally flush out cached requests, even if the unplug
> * event came from schedule. Since we know hold references to the
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 5504719b970d..e6bd9c5f42bb 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -2742,7 +2742,14 @@ void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule)
> {
> struct request *rq;
>
> - if (rq_list_empty(plug->mq_list))
> + /*
> + * We may have been called recursively midway through handling
> + * plug->mq_list via a schedule() in the driver's queue_rq() callback.
> + * To avoid mq_list changing under our feet, clear rq_count early and
> + * bail out specifically if rq_count is 0 rather than checking
> + * whether the mq_list is empty.
> + */
> + if (plug->rq_count == 0)
> return;
> plug->rq_count = 0;
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
next prev parent reply other threads:[~2023-07-14 16:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-14 10:11 Ross Lagerwall
2023-07-14 16:04 ` Bart Van Assche [this message]
2023-07-14 19:44 ` Jens Axboe
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=4399bb4f-8127-f9fb-fe47-ab02ec3566c9@acm.org \
--to=bvanassche@acm.org \
--cc=axboe@kernel.dk \
--cc=hch@infradead.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ross.lagerwall@citrix.com \
/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
all inboxes | Powered by JetHome®