Mike Snitzer aa6df8dd28 dm: fix free_rq_clone() NULL pointer when requeueing unmapped request
Commit 022333427a ("dm: optimize dm_mq_queue_rq to _not_ use kthread if
using pure blk-mq") mistakenly removed free_rq_clone()'s clone->q check
before testing clone->q->mq_ops.  It was an oversight to discontinue
that check for 1 of the 2 use-cases for free_rq_clone():
1) free_rq_clone() called when an unmapped original request is requeued
2) free_rq_clone() called in the request-based IO completion path

The clone->q check made sense for case #1 but not for #2.  However, we
cannot just reinstate the check as it'd mask a serious bug in the IO
completion case #2 -- no in-flight request should have an uninitialized
request_queue (basic block layer refcounting _should_ ensure this).

The NULL pointer seen for case #1 is detailed here:
https://www.redhat.com/archives/dm-devel/2015-April/msg00160.html

Fix this free_rq_clone() NULL pointer by simply checking if the
mapped_device's type is DM_TYPE_MQ_REQUEST_BASED (clone's queue is
blk-mq) rather than checking clone->q->mq_ops.  This avoids the need to
dereference clone->q, but a WARN_ON_ONCE is added to let us know if an
uninitialized clone request is being completed.

Reported-by: Bart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2015-04-30 10:25:21 -04:00
..
2015-04-22 07:59:39 +10:00
2015-04-22 07:59:39 +10:00
2014-01-14 23:23:03 -05:00
2013-11-23 22:33:47 -08:00
2013-08-23 09:02:13 -04:00
2013-11-23 22:33:47 -08:00
2015-04-15 12:10:24 -04:00
2012-07-30 17:25:16 -07:00
2013-09-05 20:46:06 -04:00
2007-10-20 02:01:26 +01:00
2015-02-04 08:35:52 +11:00
2015-04-24 09:28:01 -07:00
2015-02-04 08:35:52 +11:00
2015-04-24 09:28:01 -07:00
2015-04-22 07:59:39 +10:00
2015-04-22 07:59:39 +10:00
2015-02-04 08:35:52 +11:00