/* * row_dispatch_insert() - move request to dispatch queue * @rd: pointer to struct row_data * @rq: the request to dispatch * * This function moves the given request to the dispatch queue * */ static void row_dispatch_insert(struct row_data *rd, struct request *rq) { struct row_queue *rqueue = RQ_ROWQ(rq); row_remove_request(rd, rq); elv_dispatch_sort(rd->dispatch_queue, rq); if (rq->cmd_flags & REQ_URGENT) { WARN_ON(rd->urgent_in_flight); rd->urgent_in_flight = true; } rqueue->nr_dispatched++; row_clear_rowq_unserved(rd, rqueue->prio); row_log_rowq(rd, rqueue->prio, " Dispatched request %p nr_disp = %d", rq, rqueue->nr_dispatched); if (rqueue->prio < ROWQ_REG_PRIO_IDX) { rd->last_served_ioprio_class = IOPRIO_CLASS_RT; if (row_regular_req_pending(rd)) rd->reg_prio_starvation.starvation_counter++; if (row_low_req_pending(rd)) rd->low_prio_starvation.starvation_counter++; } else if (rqueue->prio < ROWQ_LOW_PRIO_IDX) { rd->last_served_ioprio_class = IOPRIO_CLASS_BE; rd->reg_prio_starvation.starvation_counter = 0; if (row_low_req_pending(rd)) rd->low_prio_starvation.starvation_counter++; } else { rd->last_served_ioprio_class = IOPRIO_CLASS_IDLE; rd->low_prio_starvation.starvation_counter = 0; } }
static int greedy_dispatch(struct request_queue *q, int force) { struct request* rq, next_upper, next_lower; struct greedy_data *nd = q->elevator->elevator_data; struct sector lower_sector, upper_sector; if(list_empty(nd->lower_queue) && list_empty(nd->upper_queue)) return NULL; if(list_empty(nd->lower_queue)) { rq = greedy_next_upper(q, nd); goto end; } if(list_empty(nd->upper_queue)) { rq = greedy_next_lower(q, nd); goto end; } next_lower = greedy_next_lower(nd); next_upper = greedy_next_upper(nd); lower_sector = blk_rq_pos(next_lower); upper_sector = blk_rq_pos(next_upper); if((upper_sector - nd->head_sector) < (nd->head_sector - lower_sector)) { rq = next_upper; goto end; } rq = next_lower; end: nd->head_sector = rq_end_sector(rq); list_del_init(&rq->queuelist); elv_dispatch_sort(q, rq); return 1; }
static int noop_dispatch(struct request_queue *q, int force) { struct noop_data *nd = q->elevator->elevator_data; if (!list_empty(&nd->queue)) { struct request *rq; rq = list_entry(nd->queue.next, struct request, queuelist); list_del_init(&rq->queuelist); elv_dispatch_sort(q, rq); return 1; } return 0; }
static int noop_dispatch(struct request_queue *q, int force) { struct noop_data *nd = q->elevator->elevator_data; struct request *rq; rq = list_first_entry_or_null(&nd->queue, struct request, queuelist); if (rq) { list_del_init(&rq->queuelist); elv_dispatch_sort(q, rq); return 1; } return 0; }
static int mpq_dispatch(struct request_queue *q, int force) { struct mpq_data *nd = q->elevator->elevator_data; struct request *rq; unsigned long endTime, serveTime; rq = list_first_entry_or_null(&nd->queue[0], struct request, queuelist); if(rq) { list_del_init(&rq->queuelist); elv_dispatch_sort(q, rq); endTime = jiffies; serveTime = rq->fifo_time - endTime; printk(KERN_ALERT "Dispatched from Queue 1 with ProcessID : %d : Time required %lu \n", q1, serveTime); return 1; } else { rq = list_first_entry_or_null(&nd->queue[1], struct request, queuelist); if(rq) { list_del_init(&rq->queuelist); elv_dispatch_sort(q, rq); endTime = jiffies; serveTime = rq->fifo_time - endTime; printk(KERN_ALERT "Dispatched from Queue 2 with ProcessID : %d : Time required %lu \n", q2, serveTime); return 1; } else { rq = list_first_entry_or_null(&nd->queue[2], struct request, queuelist); if(rq) { list_del_init(&rq->queuelist); elv_dispatch_sort(q, rq); endTime = jiffies; serveTime = rq->fifo_time - endTime; printk(KERN_ALERT "Dispatched from Queue 3 for general process: Time required %lu \n", serveTime); return 1; } } } return 0; }
static int sstf_dispatch(struct request_queue *q, int force) { struct sstf_data *nd = q->elevator->elevator_data; if (!list_empty(&nd->queue)) { struct request *nextrq, *prevrq, *rq; nextrq = list_entry(nd->queue.next, struct request, queuelist); prevrq = list_entry(nd->queue.prev, struct request, queuelist); /* Check if there is only one element in list */ if (nextrq == prevrq) { rq = nextrq; } else { if (nd->direction == HEAD_FWD) { if (nextrq->sector > nd->head_pos) { rq = nextrq; } else { nd->direction = HEAD_BCK; rq = prevrq; } } else { /* Head is going backwards */ if (prevrq->sector < nd->head_pos) { rq = prevrq; } else { nd->direction = HEAD_FWD; rq = nextrq; } } } list_del_init(&rq->queuelist); nd->head_pos = rq->sector + rq->nr_sectors; elv_dispatch_sort(q, rq); /* Debugging */ if(rq_data_dir(rq) == 0) printk("[SSTF] dsp READ %lu\n",rq->sector); else printk("[SSTF] dsp WRITE %lu\n",rq->sector); return 1; } return 0; }