]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit
block: directly insert blk-mq request from blk_insert_cloned_request()
authorJens Axboe <axboe@kernel.dk>
Mon, 11 Sep 2017 22:43:57 +0000 (16:43 -0600)
committerSeth Forshee <seth.forshee@canonical.com>
Thu, 28 Sep 2017 14:34:55 +0000 (10:34 -0400)
commitc8e7f707168229f61c8acf5a9a19f692b85ed9eb
treee7db91954a1a2182a8661682ff6536852066c936
parent4309af1079d6a64fd368c44fcfa54ea889a7c210
block: directly insert blk-mq request from blk_insert_cloned_request()

BugLink: http://bugs.launchpad.net/bugs/1720154
commit 157f377beb710e84bd8bc7a3c4475c0674ebebd7 upstream.

A NULL pointer crash was reported for the case of having the BFQ IO
scheduler attached to the underlying blk-mq paths of a DM multipath
device.  The crash occured in blk_mq_sched_insert_request()'s call to
e->type->ops.mq.insert_requests().

Paolo Valente correctly summarized why the crash occured with:
"the call chain (dm_mq_queue_rq -> map_request -> setup_clone ->
blk_rq_prep_clone) creates a cloned request without invoking
e->type->ops.mq.prepare_request for the target elevator e.  The cloned
request is therefore not initialized for the scheduler, but it is
however inserted into the scheduler by blk_mq_sched_insert_request."

All said, a request-based DM multipath device's IO scheduler should be
the only one used -- when the original requests are issued to the
underlying paths as cloned requests they are inserted directly in the
underlying dispatch queue(s) rather than through an additional elevator.

But commit bd166ef18 ("blk-mq-sched: add framework for MQ capable IO
schedulers") switched blk_insert_cloned_request() from using
blk_mq_insert_request() to blk_mq_sched_insert_request().  Which
incorrectly added elevator machinery into a call chain that isn't
supposed to have any.

To fix this introduce a blk-mq private blk_mq_request_bypass_insert()
that blk_insert_cloned_request() calls to insert the request without
involving any elevator that may be attached to the cloned request's
request_queue.

Fixes: bd166ef183c2 ("blk-mq-sched: add framework for MQ capable IO schedulers")
Reported-by: Bart Van Assche <Bart.VanAssche@wdc.com>
Tested-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
block/blk-core.c
block/blk-mq.c
block/blk-mq.h