|
@@ -2167,3 +2167,65 @@ void blk_dequeue_request(struct request *rq)
|
|
|
|
|
|
list_del_init(&rq->queuelist);
|
|
|
|
|
|
+ /*
|
|
|
+ * the time frame between a request being removed from the lists
|
|
|
+ * and to it is freed is accounted as io that is in progress at
|
|
|
+ * the driver side.
|
|
|
+ */
|
|
|
+ if (blk_account_rq(rq)) {
|
|
|
+ q->in_flight[rq_is_sync(rq)]++;
|
|
|
+ set_io_start_time_ns(rq);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * blk_start_request - start request processing on the driver
|
|
|
+ * @req: request to dequeue
|
|
|
+ *
|
|
|
+ * Description:
|
|
|
+ * Dequeue @req and start timeout timer on it. This hands off the
|
|
|
+ * request to the driver.
|
|
|
+ *
|
|
|
+ * 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)
|
|
|
+{
|
|
|
+ blk_dequeue_request(req);
|
|
|
+
|
|
|
+ /*
|
|
|
+ * We are now handing the request to the hardware, initialize
|
|
|
+ * resid_len to full count and add the timeout handler.
|
|
|
+ */
|
|
|
+ req->resid_len = blk_rq_bytes(req);
|
|
|
+ if (unlikely(blk_bidi_rq(req)))
|
|
|
+ req->next_rq->resid_len = blk_rq_bytes(req->next_rq);
|
|
|
+
|
|
|
+ blk_add_timer(req);
|
|
|
+}
|
|
|
+EXPORT_SYMBOL(blk_start_request);
|
|
|
+
|
|
|
+/**
|
|
|
+ * blk_fetch_request - fetch a request from a request queue
|
|
|
+ * @q: request queue to fetch a request from
|
|
|
+ *
|
|
|
+ * Description:
|
|
|
+ * Return the request at the top of @q. The request is started on
|
|
|
+ * return and LLD can start processing it immediately.
|
|
|
+ *
|
|
|
+ * 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;
|
|
|
+
|
|
|
+ rq = blk_peek_request(q);
|
|
|
+ if (rq)
|