diff options
-rw-r--r-- | block/row-iosched.c | 85 |
1 files changed, 79 insertions, 6 deletions
diff --git a/block/row-iosched.c b/block/row-iosched.c index e60ff4e..fe740bd 100644 --- a/block/row-iosched.c +++ b/block/row-iosched.c @@ -58,6 +58,17 @@ static const bool queue_idling_enabled[] = { false, /* ROWQ_PRIO_LOW_SWRITE */ }; +/* Flags indicating whether the queue can notify on urgent requests */ +static const bool urgent_queues[] = { + true, /* ROWQ_PRIO_HIGH_READ */ + true, /* ROWQ_PRIO_REG_READ */ + false, /* ROWQ_PRIO_HIGH_SWRITE */ + false, /* ROWQ_PRIO_REG_SWRITE */ + false, /* ROWQ_PRIO_REG_WRITE */ + false, /* ROWQ_PRIO_LOW_READ */ + false, /* ROWQ_PRIO_LOW_SWRITE */ +}; + /* Default values for row queues quantums in each dispatch cycle */ static const int queue_quantum[] = { 100, /* ROWQ_PRIO_HIGH_READ */ @@ -69,9 +80,9 @@ static const int queue_quantum[] = { 1 /* ROWQ_PRIO_LOW_SWRITE */ }; -/* Default values for idling on read queues */ -#define ROW_IDLE_TIME_MSEC 5 /* msec */ -#define ROW_READ_FREQ_MSEC 20 /* msec */ +/* Default values for idling on read queues (in msec) */ +#define ROW_IDLE_TIME_MSEC 5 +#define ROW_READ_FREQ_MSEC 20 /** * struct rowq_idling_data - parameters for idling on the queue @@ -271,10 +282,70 @@ static void row_add_request(struct request_queue *q, rqueue->idle_data.last_insert_time = ktime_get(); } - row_log_rowq(rd, rqueue->prio, "added request"); + if (urgent_queues[rqueue->prio] && + row_rowq_unserved(rd, rqueue->prio)) { + row_log_rowq(rd, rqueue->prio, + "added urgent req curr_queue = %d", + rd->curr_queue); + } else + row_log_rowq(rd, rqueue->prio, "added request"); } -/* +/** + * row_reinsert_req() - Reinsert request back to the scheduler + * @q: requests queue + * @rq: request to add + * + * Reinsert the given request back to the queue it was + * dispatched from as if it was never dispatched. + * + * Returns 0 on success, error code otherwise + */ +static int row_reinsert_req(struct request_queue *q, + struct request *rq) +{ + struct row_data *rd = q->elevator->elevator_data; + struct row_queue *rqueue = RQ_ROWQ(rq); + + /* Verify rqueue is legitimate */ + if (rqueue->prio >= ROWQ_MAX_PRIO) { + pr_err("\n\nROW BUG: row_reinsert_req() rqueue->prio = %d\n", + rqueue->prio); + blk_dump_rq_flags(rq, ""); + return -EIO; + } + + list_add(&rq->queuelist, &rqueue->fifo); + rd->nr_reqs[rq_data_dir(rq)]++; + + row_log_rowq(rd, rqueue->prio, "request reinserted"); + + return 0; +} + +/** + * row_urgent_pending() - Return TRUE if there is an urgent + * request on scheduler + * @q: requests queue + */ +static bool row_urgent_pending(struct request_queue *q) +{ + struct row_data *rd = q->elevator->elevator_data; + int i; + + for (i = 0; i < ROWQ_MAX_PRIO; i++) + if (urgent_queues[i] && row_rowq_unserved(rd, i) && + !list_empty(&rd->row_queues[i].rqueue.fifo)) { + row_log_rowq(rd, i, + "Urgent request pending (curr=%i)", + rd->curr_queue); + return true; + } + + return false; +} + +/** * row_remove_request() - Remove given request from scheduler * @q: requests queue * @rq: request to remove @@ -664,6 +735,8 @@ static struct elevator_type iosched_row = { .elevator_merge_req_fn = row_merged_requests, .elevator_dispatch_fn = row_dispatch_requests, .elevator_add_req_fn = row_add_request, + .elevator_reinsert_req_fn = row_reinsert_req, + .elevator_is_urgent_fn = row_urgent_pending, .elevator_former_req_fn = elv_rb_former_request, .elevator_latter_req_fn = elv_rb_latter_request, .elevator_set_req_fn = row_set_request, @@ -691,4 +764,4 @@ module_init(row_init); module_exit(row_exit); MODULE_LICENSE("GPLv2"); -MODULE_DESCRIPTION("Read Over Write IO scheduler"); +MODULE_DESCRIPTION("Read Over Write IO scheduler");
\ No newline at end of file |