block: mq-deadline: Fix queue restart handling
[platform/kernel/linux-rpi.git] / block / mq-deadline.c
index d5e21ce..69094d6 100644 (file)
@@ -376,13 +376,6 @@ done:
  * hardware queue, but we may return a request that is for a
  * different hardware queue. This is because mq-deadline has shared
  * state for all hardware queues, in terms of sorting, FIFOs, etc.
- *
- * For a zoned block device, __dd_dispatch_request() may return NULL
- * if all the queued write requests are directed at zones that are already
- * locked due to on-going write requests. In this case, make sure to mark
- * the queue as needing a restart to ensure that the queue is run again
- * and the pending writes dispatched once the target zones for the ongoing
- * write requests are unlocked in dd_finish_request().
  */
 static struct request *dd_dispatch_request(struct blk_mq_hw_ctx *hctx)
 {
@@ -391,9 +384,6 @@ static struct request *dd_dispatch_request(struct blk_mq_hw_ctx *hctx)
 
        spin_lock(&dd->lock);
        rq = __dd_dispatch_request(dd);
-       if (!rq && blk_queue_is_zoned(hctx->queue) &&
-           !list_empty(&dd->fifo_list[WRITE]))
-               blk_mq_sched_mark_restart_hctx(hctx);
        spin_unlock(&dd->lock);
 
        return rq;
@@ -559,6 +549,13 @@ static void dd_prepare_request(struct request *rq, struct bio *bio)
  * spinlock so that the zone is never unlocked while deadline_fifo_request()
  * or deadline_next_request() are executing. This function is called for
  * all requests, whether or not these requests complete successfully.
+ *
+ * For a zoned block device, __dd_dispatch_request() may have stopped
+ * dispatching requests if all the queued requests are write requests directed
+ * at zones that are already locked due to on-going write requests. To ensure
+ * write request dispatch progress in this case, mark the queue as needing a
+ * restart to ensure that the queue is run again after completion of the
+ * request and zones being unlocked.
  */
 static void dd_finish_request(struct request *rq)
 {
@@ -570,6 +567,12 @@ static void dd_finish_request(struct request *rq)
 
                spin_lock_irqsave(&dd->zone_lock, flags);
                blk_req_zone_write_unlock(rq);
+               if (!list_empty(&dd->fifo_list[WRITE])) {
+                       struct blk_mq_hw_ctx *hctx;
+
+                       hctx = blk_mq_map_queue(q, rq->mq_ctx->cpu);
+                       blk_mq_sched_mark_restart_hctx(hctx);
+               }
                spin_unlock_irqrestore(&dd->zone_lock, flags);
        }
 }