From: Keith Busch <kbusch@kernel.org>
To: Ming Lei <ming.lei@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, Sagi Grimberg <sagi@grimberg.me>,
Bart Van Assche <bvanassche@acm.org>,
James Smart <james.smart@broadcom.com>,
Christoph Hellwig <hch@lst.de>,
linux-nvme@lists.infradead.org
Subject: Re: [PATCH V3 1/2] blk-mq: introduce blk_mq_complete_request_sync()
Date: Mon, 8 Apr 2019 10:15:05 -0600 [thread overview]
Message-ID: <20190408161505.GA32613@localhost.localdomain> (raw)
In-Reply-To: <20190408094047.29150-2-ming.lei@redhat.com>
On Mon, Apr 08, 2019 at 05:40:46PM +0800, Ming Lei wrote:
> In NVMe's error handler, follows the typical steps of tearing down
> hardware for recovering controller:
>
> 1) stop blk_mq hw queues
> 2) stop the real hw queues
> 3) cancel in-flight requests via
> blk_mq_tagset_busy_iter(tags, cancel_request, ...)
> cancel_request():
> mark the request as abort
> blk_mq_complete_request(req);
> 4) destroy real hw queues
>
> However, there may be race between #3 and #4, because blk_mq_complete_request()
> may run q->mq_ops->complete(rq) remotelly and asynchronously, and
> ->complete(rq) may be run after #4.
>
> This patch introduces blk_mq_complete_request_sync() for fixing the
> above race.
>
> Cc: Keith Busch <kbusch@kernel.org>
> Cc: Sagi Grimberg <sagi@grimberg.me>
> Cc: Bart Van Assche <bvanassche@acm.org>
> Cc: James Smart <james.smart@broadcom.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: linux-nvme@lists.infradead.org
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> ---
> block/blk-mq.c | 11 +++++++++++
> include/linux/blk-mq.h | 1 +
> 2 files changed, 12 insertions(+)
>
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index a9354835cf51..d8d89f3514ac 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -654,6 +654,17 @@ bool blk_mq_complete_request(struct request *rq)
> }
> EXPORT_SYMBOL(blk_mq_complete_request);
>
> +bool blk_mq_complete_request_sync(struct request *rq)
> +{
> + if (unlikely(blk_should_fake_timeout(rq->q)))
> + return false;
> +
> + WRITE_ONCE(rq->state, MQ_RQ_COMPLETE);
> + rq->q->mq_ops->complete(rq);
> + return true;
> +}
> +EXPORT_SYMBOL_GPL(blk_mq_complete_request_sync);
Could we possibly drop the fake timeout in this path? We're using this
in error handling that is past pretending completing requests didn't
happen.
Otherwise this all looks good to me.
WARNING: multiple messages have this Message-ID (diff)
From: kbusch@kernel.org (Keith Busch)
Subject: [PATCH V3 1/2] blk-mq: introduce blk_mq_complete_request_sync()
Date: Mon, 8 Apr 2019 10:15:05 -0600 [thread overview]
Message-ID: <20190408161505.GA32613@localhost.localdomain> (raw)
In-Reply-To: <20190408094047.29150-2-ming.lei@redhat.com>
On Mon, Apr 08, 2019@05:40:46PM +0800, Ming Lei wrote:
> In NVMe's error handler, follows the typical steps of tearing down
> hardware for recovering controller:
>
> 1) stop blk_mq hw queues
> 2) stop the real hw queues
> 3) cancel in-flight requests via
> blk_mq_tagset_busy_iter(tags, cancel_request, ...)
> cancel_request():
> mark the request as abort
> blk_mq_complete_request(req);
> 4) destroy real hw queues
>
> However, there may be race between #3 and #4, because blk_mq_complete_request()
> may run q->mq_ops->complete(rq) remotelly and asynchronously, and
> ->complete(rq) may be run after #4.
>
> This patch introduces blk_mq_complete_request_sync() for fixing the
> above race.
>
> Cc: Keith Busch <kbusch at kernel.org>
> Cc: Sagi Grimberg <sagi at grimberg.me>
> Cc: Bart Van Assche <bvanassche at acm.org>
> Cc: James Smart <james.smart at broadcom.com>
> Cc: Christoph Hellwig <hch at lst.de>
> Cc: linux-nvme at lists.infradead.org
> Signed-off-by: Ming Lei <ming.lei at redhat.com>
> ---
> block/blk-mq.c | 11 +++++++++++
> include/linux/blk-mq.h | 1 +
> 2 files changed, 12 insertions(+)
>
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index a9354835cf51..d8d89f3514ac 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -654,6 +654,17 @@ bool blk_mq_complete_request(struct request *rq)
> }
> EXPORT_SYMBOL(blk_mq_complete_request);
>
> +bool blk_mq_complete_request_sync(struct request *rq)
> +{
> + if (unlikely(blk_should_fake_timeout(rq->q)))
> + return false;
> +
> + WRITE_ONCE(rq->state, MQ_RQ_COMPLETE);
> + rq->q->mq_ops->complete(rq);
> + return true;
> +}
> +EXPORT_SYMBOL_GPL(blk_mq_complete_request_sync);
Could we possibly drop the fake timeout in this path? We're using this
in error handling that is past pretending completing requests didn't
happen.
Otherwise this all looks good to me.
next prev parent reply other threads:[~2019-04-08 16:13 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-08 9:40 [PATCH V3 0/2] blk-mq/nvme: cancel request synchronously Ming Lei
2019-04-08 9:40 ` Ming Lei
2019-04-08 9:40 ` [PATCH V3 1/2] blk-mq: introduce blk_mq_complete_request_sync() Ming Lei
2019-04-08 9:40 ` Ming Lei
2019-04-08 16:15 ` Keith Busch [this message]
2019-04-08 16:15 ` Keith Busch
2019-04-08 16:16 ` Christoph Hellwig
2019-04-08 16:16 ` Christoph Hellwig
2019-04-08 9:40 ` [PATCH V3 2/2] nvme: cancel request synchronously Ming Lei
2019-04-08 9:40 ` Ming Lei
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=20190408161505.GA32613@localhost.localdomain \
--to=kbusch@kernel.org \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=hch@lst.de \
--cc=james.smart@broadcom.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=ming.lei@redhat.com \
--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.