Skip to content

Commit

Permalink
blk-mq: Document locking assumptions
Browse files Browse the repository at this point in the history
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 <bart.vanassche@sandisk.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Omar Sandoval <osandov@fb.com>
Cc: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Bart Van Assche authored and Jens Axboe committed Jun 21, 2017
1 parent 332ebbf commit 7b60781
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions block/blk-mq-sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 4 additions & 0 deletions block/blk-mq.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
}
Expand Down

0 comments on commit 7b60781

Please sign in to comment.