diff options
author | Jens Axboe <jens.axboe@oracle.com> | 2007-01-14 06:26:09 -0500 |
---|---|---|
committer | Jens Axboe <axboe@carl.home.kernel.dk> | 2007-02-11 17:14:44 -0500 |
commit | cad9751642b62cbb5f62feedc546b4f7890497d4 (patch) | |
tree | f73352cb6ed7fbd66614fb59b1e8694f39ebc838 /block/elevator.c | |
parent | 958b7f37ee0fb2846c8d44310a68ae9605614ff9 (diff) |
elevator: abstract out the activate and deactivate functions
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block/elevator.c')
-rw-r--r-- | block/elevator.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/block/elevator.c b/block/elevator.c index f6dafa8c7c4d..d03762399147 100644 --- a/block/elevator.c +++ b/block/elevator.c | |||
@@ -269,6 +269,22 @@ void elevator_exit(elevator_t *e) | |||
269 | 269 | ||
270 | EXPORT_SYMBOL(elevator_exit); | 270 | EXPORT_SYMBOL(elevator_exit); |
271 | 271 | ||
272 | static void elv_activate_rq(request_queue_t *q, struct request *rq) | ||
273 | { | ||
274 | elevator_t *e = q->elevator; | ||
275 | |||
276 | if (e->ops->elevator_activate_req_fn) | ||
277 | e->ops->elevator_activate_req_fn(q, rq); | ||
278 | } | ||
279 | |||
280 | static void elv_deactivate_rq(request_queue_t *q, struct request *rq) | ||
281 | { | ||
282 | elevator_t *e = q->elevator; | ||
283 | |||
284 | if (e->ops->elevator_deactivate_req_fn) | ||
285 | e->ops->elevator_deactivate_req_fn(q, rq); | ||
286 | } | ||
287 | |||
272 | static inline void __elv_rqhash_del(struct request *rq) | 288 | static inline void __elv_rqhash_del(struct request *rq) |
273 | { | 289 | { |
274 | hlist_del_init(&rq->hash); | 290 | hlist_del_init(&rq->hash); |
@@ -498,16 +514,14 @@ void elv_merge_requests(request_queue_t *q, struct request *rq, | |||
498 | 514 | ||
499 | void elv_requeue_request(request_queue_t *q, struct request *rq) | 515 | void elv_requeue_request(request_queue_t *q, struct request *rq) |
500 | { | 516 | { |
501 | elevator_t *e = q->elevator; | ||
502 | |||
503 | /* | 517 | /* |
504 | * it already went through dequeue, we need to decrement the | 518 | * it already went through dequeue, we need to decrement the |
505 | * in_flight count again | 519 | * in_flight count again |
506 | */ | 520 | */ |
507 | if (blk_account_rq(rq)) { | 521 | if (blk_account_rq(rq)) { |
508 | q->in_flight--; | 522 | q->in_flight--; |
509 | if (blk_sorted_rq(rq) && e->ops->elevator_deactivate_req_fn) | 523 | if (blk_sorted_rq(rq)) |
510 | e->ops->elevator_deactivate_req_fn(q, rq); | 524 | elv_deactivate_rq(q, rq); |
511 | } | 525 | } |
512 | 526 | ||
513 | rq->cmd_flags &= ~REQ_STARTED; | 527 | rq->cmd_flags &= ~REQ_STARTED; |
@@ -700,16 +714,13 @@ struct request *elv_next_request(request_queue_t *q) | |||
700 | 714 | ||
701 | while ((rq = __elv_next_request(q)) != NULL) { | 715 | while ((rq = __elv_next_request(q)) != NULL) { |
702 | if (!(rq->cmd_flags & REQ_STARTED)) { | 716 | if (!(rq->cmd_flags & REQ_STARTED)) { |
703 | elevator_t *e = q->elevator; | ||
704 | |||
705 | /* | 717 | /* |
706 | * This is the first time the device driver | 718 | * This is the first time the device driver |
707 | * sees this request (possibly after | 719 | * sees this request (possibly after |
708 | * requeueing). Notify IO scheduler. | 720 | * requeueing). Notify IO scheduler. |
709 | */ | 721 | */ |
710 | if (blk_sorted_rq(rq) && | 722 | if (blk_sorted_rq(rq)) |
711 | e->ops->elevator_activate_req_fn) | 723 | elv_activate_rq(q, rq); |
712 | e->ops->elevator_activate_req_fn(q, rq); | ||
713 | 724 | ||
714 | /* | 725 | /* |
715 | * just mark as started even if we don't start | 726 | * just mark as started even if we don't start |