Skip to content

Commit e3ef944

Browse files
shroffniaxboe
authored andcommitted
block: validate QoS before calling __rq_qos_done_bio()
If a bio has BIO_QOS_xxx set, it doesn't guarantee that q->rq_qos is also present at-least for stacked block devices. For instance, in case of NVMe when multipath is enabled, the bottom device may have QoS enabled but top device doesn't. So always validate QoS is enabled and q->rq_qos is present before calling __rq_qos_done_bio(). Fixes: 370ac28 ("block: avoid cpu_hotplug_lock depedency on freeze_lock") Reported-by: Venkat Rao Bagalkote <[email protected]> Closes: https://lore.kernel.org/all/[email protected]/ Signed-off-by: Nilay Shroff <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 198f36f commit e3ef944

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

block/blk-rq-qos.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,15 @@ static inline void rq_qos_done_bio(struct bio *bio)
149149
q = bdev_get_queue(bio->bi_bdev);
150150

151151
/*
152-
* If a bio has BIO_QOS_xxx set, it implicitly implies that
153-
* q->rq_qos is present. So, we skip re-checking q->rq_qos
154-
* here as an extra optimization and directly call
155-
* __rq_qos_done_bio().
152+
* A BIO may carry BIO_QOS_* flags even if the associated request_queue
153+
* does not have rq_qos enabled. This can happen with stacked block
154+
* devices — for example, NVMe multipath, where it's possible that the
155+
* bottom device has QoS enabled but the top device does not. Therefore,
156+
* always verify that q->rq_qos is present and QoS is enabled before
157+
* calling __rq_qos_done_bio().
156158
*/
157-
__rq_qos_done_bio(q->rq_qos, bio);
159+
if (test_bit(QUEUE_FLAG_QOS_ENABLED, &q->queue_flags) && q->rq_qos)
160+
__rq_qos_done_bio(q->rq_qos, bio);
158161
}
159162

160163
static inline void rq_qos_throttle(struct request_queue *q, struct bio *bio)

0 commit comments

Comments
 (0)