blk-mq: Document locking assumptions
authorBart Van Assche <[email protected]>
Tue, 20 Jun 2017 18:15:47 +0000 (11:15 -0700)
committerJens Axboe <[email protected]>
Wed, 21 Jun 2017 01:27:14 +0000 (19:27 -0600)
Document the locking assumptions in functions that modify
blk_mq_ctx.rq_list to make it easier for humans to verify
this code.

Signed-off-by: Bart Van Assche <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Cc: Hannes Reinecke <[email protected]>
Cc: Omar Sandoval <[email protected]>
Cc: Ming Lei <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
block/blk-mq-sched.c
block/blk-mq.c

index 9f025289da63c6a4e24a43ccdf835822dd34abfc..191bf82d185e82aa2cc7bedd51925de978ed42a4 100644 (file)
@@ -150,6 +150,8 @@ static bool blk_mq_attempt_merge(struct request_queue *q,
        struct request *rq;
        int checked = 8;
 
+       lockdep_assert_held(&ctx->lock);
+
        list_for_each_entry_reverse(rq, &ctx->rq_list, queuelist) {
                bool merged = false;
 
index 6268380c680fcf315b6173355ad2a1d93e978626..1d8050e49a942819f73c3907b43ebdf1939ba49f 100644 (file)
@@ -1317,6 +1317,8 @@ static inline void __blk_mq_insert_req_list(struct blk_mq_hw_ctx *hctx,
 {
        struct blk_mq_ctx *ctx = rq->mq_ctx;
 
+       lockdep_assert_held(&ctx->lock);
+
        trace_block_rq_insert(hctx->queue, rq);
 
        if (at_head)
@@ -1330,6 +1332,8 @@ void __blk_mq_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq,
 {
        struct blk_mq_ctx *ctx = rq->mq_ctx;
 
+       lockdep_assert_held(&ctx->lock);
+
        __blk_mq_insert_req_list(hctx, rq, at_head);
        blk_mq_hctx_mark_pending(hctx, ctx);
 }