blk-mq: introduce blk_mq_complete_request_sync()
authorMing Lei <ming.lei@redhat.com>
Mon, 8 Apr 2019 22:31:21 +0000 (06:31 +0800)
committerJens Axboe <axboe@kernel.dk>
Wed, 10 Apr 2019 15:57:33 +0000 (09:57 -0600)
commit1b8f21b74c3c9c82fce5a751d7aefb7cc0b8d33d
treeb6e8eac9fe39c7d114587047c6addc7728009bbd
parent1978f30a87732d4d9072a20abeded9fe17884f1b
blk-mq: introduce blk_mq_complete_request_sync()

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: Sagi Grimberg <sagi@grimberg.me>
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: James Smart <james.smart@broadcom.com>
Cc: linux-nvme@lists.infradead.org
Reviewed-by: Keith Busch <keith.busch@intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-mq.c
include/linux/blk-mq.h