* Description:
  *   Sometimes queueing needs to be postponed for a little while, to allow
  *   resources to come back. This function will make sure that queueing is
- *   restarted around the specified time. Queue lock must be held.
+ *   restarted around the specified time.
  */
 void blk_delay_queue(struct request_queue *q, unsigned long msecs)
 {
+       lockdep_assert_held(q->queue_lock);
+
        if (likely(!blk_queue_dead(q)))
                queue_delayed_work(kblockd_workqueue, &q->delay_work,
                                   msecs_to_jiffies(msecs));
  **/
 void blk_start_queue_async(struct request_queue *q)
 {
+       lockdep_assert_held(q->queue_lock);
+
        queue_flag_clear(QUEUE_FLAG_STOPPED, q);
        blk_run_queue_async(q);
 }
  * Description:
  *   blk_start_queue() will clear the stop flag on the queue, and call
  *   the request_fn for the queue if it was in a stopped state when
- *   entered. Also see blk_stop_queue(). Queue lock must be held.
+ *   entered. Also see blk_stop_queue().
  **/
 void blk_start_queue(struct request_queue *q)
 {
+       lockdep_assert_held(q->queue_lock);
        WARN_ON(!irqs_disabled());
 
        queue_flag_clear(QUEUE_FLAG_STOPPED, q);
  *   or if it simply chooses not to queue more I/O at one point, it can
  *   call this function to prevent the request_fn from being called until
  *   the driver has signalled it's ready to go again. This happens by calling
- *   blk_start_queue() to restart queue operations. Queue lock must be held.
+ *   blk_start_queue() to restart queue operations.
  **/
 void blk_stop_queue(struct request_queue *q)
 {
+       lockdep_assert_held(q->queue_lock);
+
        cancel_delayed_work(&q->delay_work);
        queue_flag_set(QUEUE_FLAG_STOPPED, q);
 }
  */
 inline void __blk_run_queue_uncond(struct request_queue *q)
 {
+       lockdep_assert_held(q->queue_lock);
+
        if (unlikely(blk_queue_dead(q)))
                return;
 
  * @q: The queue to run
  *
  * Description:
- *    See @blk_run_queue. This variant must be called with the queue lock
- *    held and interrupts disabled.
+ *    See @blk_run_queue.
  */
 void __blk_run_queue(struct request_queue *q)
 {
+       lockdep_assert_held(q->queue_lock);
+
        if (unlikely(blk_queue_stopped(q)))
                return;
 
  *
  * Description:
  *    Tells kblockd to perform the equivalent of @blk_run_queue on behalf
- *    of us. The caller must hold the queue lock.
+ *    of us.
+ *
+ * Note:
+ *    Since it is not allowed to run q->delay_work after blk_cleanup_queue()
+ *    has canceled q->delay_work, callers must hold the queue lock to avoid
+ *    race conditions between blk_cleanup_queue() and blk_run_queue_async().
  */
 void blk_run_queue_async(struct request_queue *q)
 {
+       lockdep_assert_held(q->queue_lock);
+
        if (likely(!blk_queue_stopped(q) && !blk_queue_dead(q)))
                mod_delayed_work(kblockd_workqueue, &q->delay_work, 0);
 }
        int may_queue;
        req_flags_t rq_flags = RQF_ALLOCED;
 
+       lockdep_assert_held(q->queue_lock);
+
        if (unlikely(blk_queue_dying(q)))
                return ERR_PTR(-ENODEV);
 
        struct request_list *rl;
        struct request *rq;
 
+       lockdep_assert_held(q->queue_lock);
+
        rl = blk_get_rl(q, bio);        /* transferred to @rq on success */
 retry:
        rq = __get_request(rl, op, bio, gfp_mask);
  */
 void blk_requeue_request(struct request_queue *q, struct request *rq)
 {
+       lockdep_assert_held(q->queue_lock);
+
        blk_delete_timer(rq);
        blk_clear_rq_complete(rq);
        trace_block_rq_requeue(q, rq);
 static inline void blk_pm_put_request(struct request *rq) {}
 #endif
 
-/*
- * queue lock must be held
- */
 void __blk_put_request(struct request_queue *q, struct request *req)
 {
        req_flags_t rq_flags = req->rq_flags;
                return;
        }
 
+       lockdep_assert_held(q->queue_lock);
+
        blk_pm_put_request(req);
 
        elv_completed_request(q, req);
  *
  * Return:
  *     The number of bytes to fail.
- *
- * Context:
- *     queue_lock must be held.
  */
 unsigned int blk_rq_err_bytes(const struct request *rq)
 {
  * Return:
  *     Pointer to the request at the top of @q if available.  Null
  *     otherwise.
- *
- * Context:
- *     queue_lock must be held.
  */
 struct request *blk_peek_request(struct request_queue *q)
 {
        struct request *rq;
        int ret;
 
+       lockdep_assert_held(q->queue_lock);
+
        while ((rq = __elv_next_request(q)) != NULL) {
 
                rq = blk_pm_peek_request(q, rq);
  *
  *     Block internal functions which don't want to start timer should
  *     call blk_dequeue_request().
- *
- * Context:
- *     queue_lock must be held.
  */
 void blk_start_request(struct request *req)
 {
+       lockdep_assert_held(req->q->queue_lock);
+
        blk_dequeue_request(req);
 
        if (test_bit(QUEUE_FLAG_STATS, &req->q->queue_flags)) {
  * Return:
  *     Pointer to the request at the top of @q if available.  Null
  *     otherwise.
- *
- * Context:
- *     queue_lock must be held.
  */
 struct request *blk_fetch_request(struct request_queue *q)
 {
        struct request *rq;
 
+       lockdep_assert_held(q->queue_lock);
+
        rq = blk_peek_request(q);
        if (rq)
                blk_start_request(rq);
 }
 EXPORT_SYMBOL_GPL(blk_unprep_request);
 
-/*
- * queue lock must be held
- */
 void blk_finish_request(struct request *req, blk_status_t error)
 {
        struct request_queue *q = req->q;
 
+       lockdep_assert_held(req->q->queue_lock);
+
        if (req->rq_flags & RQF_STATS)
                blk_stat_add(req);
 
 static bool __blk_end_bidi_request(struct request *rq, blk_status_t error,
                                   unsigned int nr_bytes, unsigned int bidi_bytes)
 {
+       lockdep_assert_held(rq->q->queue_lock);
+
        if (blk_update_bidi_request(rq, error, nr_bytes, bidi_bytes))
                return true;
 
 bool __blk_end_request(struct request *rq, blk_status_t error,
                unsigned int nr_bytes)
 {
+       lockdep_assert_held(rq->q->queue_lock);
+
        return __blk_end_bidi_request(rq, error, nr_bytes, 0);
 }
 EXPORT_SYMBOL(__blk_end_request);
        bool pending;
        unsigned int bidi_bytes = 0;
 
+       lockdep_assert_held(rq->q->queue_lock);
+
        if (unlikely(blk_bidi_rq(rq)))
                bidi_bytes = blk_rq_bytes(rq->next_rq);
 
                            bool from_schedule)
        __releases(q->queue_lock)
 {
+       lockdep_assert_held(q->queue_lock);
+
        trace_block_unplug(q, depth, !from_schedule);
 
        if (from_schedule)
 
  *    all transfers have been done for a request. It's important to call
  *    this function before end_that_request_last(), as that will put the
  *    request back on the free list thus corrupting the internal tag list.
- *
- *  Notes:
- *   queue lock must be held.
  **/
 void blk_queue_end_tag(struct request_queue *q, struct request *rq)
 {
        struct blk_queue_tag *bqt = q->queue_tags;
        unsigned tag = rq->tag; /* negative tags invalid */
 
+       lockdep_assert_held(q->queue_lock);
+
        BUG_ON(tag >= bqt->real_max_depth);
 
        list_del_init(&rq->queuelist);
  *    calling this function.  The request will also be removed from
  *    the request queue, so it's the drivers responsibility to readd
  *    it if it should need to be restarted for some reason.
- *
- *  Notes:
- *   queue lock must be held.
  **/
 int blk_queue_start_tag(struct request_queue *q, struct request *rq)
 {
        unsigned max_depth;
        int tag;
 
+       lockdep_assert_held(q->queue_lock);
+
        if (unlikely((rq->rq_flags & RQF_QUEUED))) {
                printk(KERN_ERR
                       "%s: request %p for device [%s] already tagged %d",
  *   Hardware conditions may dictate a need to stop all pending requests.
  *   In this case, we will safely clear the block side of the tag queue and
  *   readd all requests to the request queue in the right order.
- *
- *  Notes:
- *   queue lock must be held.
  **/
 void blk_queue_invalidate_tags(struct request_queue *q)
 {
        struct list_head *tmp, *n;
 
+       lockdep_assert_held(q->queue_lock);
+
        list_for_each_safe(tmp, n, &q->tag_busy_list)
                blk_requeue_request(q, list_entry_rq(tmp));
 }