aboutsummaryrefslogtreecommitdiff
path: root/block/elevator.c
diff options
context:
space:
mode:
authorTatyana Brokhman <tlinder@codeaurora.org>2012-12-04 15:54:43 +0200
committerMoyster <oysterized@gmail.com>2016-08-26 20:07:38 +0200
commit82356c71fd5b6b4ace46e4f31c318cc68657a598 (patch)
tree175599c36ce271b8a44ed774012ce1e69f649719 /block/elevator.c
parentcaba403ebea4069d40816267ed8f894801e1e31d (diff)
block: Add support for reinsert a dispatched req
Add support for reinserting a dispatched request back to the scheduler's internal data structures. This capability is used by the device driver when it chooses to interrupt the current request transmission and execute another (more urgent) pending request. For example: interrupting long write in order to handle pending read. The device driver re-inserts the remaining write request back to the scheduler, to be rescheduled for transmission later on. Add API for verifying whether the current scheduler supports reinserting requests mechanism. If reinsert mechanism isn't supported by the scheduler, this code path will never be activated. Change-Id: I5c982a66b651ebf544aae60063ac8a340d79e67f Signed-off-by: Tatyana Brokhman <tlinder@codeaurora.org> Signed-off-by: Stefan Guendhoer <stefan@guendhoer.com>
Diffstat (limited to 'block/elevator.c')
-rw-r--r--block/elevator.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/block/elevator.c b/block/elevator.c
index 6d765f7e2..3d1c3a729 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -575,6 +575,41 @@ void elv_requeue_request(struct request_queue *q, struct request *rq)
__elv_add_request(q, rq, ELEVATOR_INSERT_REQUEUE);
}
+/**
+ * elv_reinsert_request() - Insert a request back to the scheduler
+ * @q: request queue where request should be inserted
+ * @rq: request to be inserted
+ *
+ * This function returns the request back to the scheduler to be
+ * inserted as if it was never dispatched
+ *
+ * Return: 0 on success, error code on failure
+ */
+int elv_reinsert_request(struct request_queue *q, struct request *rq)
+{
+ int res;
+
+ if (!q->elevator->type->ops.elevator_reinsert_req_fn)
+ return -EPERM;
+
+ res = q->elevator->type->ops.elevator_reinsert_req_fn(q, rq);
+ if (!res) {
+ /*
+ * it already went through dequeue, we need to decrement the
+ * in_flight count again
+ */
+ if (blk_account_rq(rq)) {
+ q->in_flight[rq_is_sync(rq)]--;
+ if (rq->cmd_flags & REQ_SORTED)
+ elv_deactivate_rq(q, rq);
+ }
+ rq->cmd_flags &= ~REQ_STARTED;
+ q->nr_sorted++;
+ }
+
+ return res;
+}
+
void elv_drain_elevator(struct request_queue *q)
{
static int printed;