aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2005-11-10 12:21:30 -0500
committerJens Axboe <axboe@nelson.home.kernel.dk>2005-11-12 04:56:52 -0500
commit5a7c47eefb31f6b4982add7473ef3e551b058ea4 (patch)
tree6bff2f1ab58080d759c8788680e05359ba0d5f69 /block
parentb740d98f5614e34b4cff2e1e67826f007c8d4f30 (diff)
[BLOCK] noop-iosched: reimplementation of request dispatching
The original implementation directly used dispatch queue. As new generic dispatch queue imposes stricter rules over ioscheds and dispatch queue usage, this direct use becomes somewhat problematic. This patch reimplements noop-iosched such that it complies to generic iosched model better. Request merging with q->last_merge and rq->queuelist.prev/next work again now. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jens Axboe <axboe@suse.de
Diffstat (limited to 'block')
-rw-r--r--block/noop-iosched.c85
1 files changed, 79 insertions, 6 deletions
diff --git a/block/noop-iosched.c b/block/noop-iosched.c
index e54f006e7e60..f370e4a7fe6d 100644
--- a/block/noop-iosched.c
+++ b/block/noop-iosched.c
@@ -7,21 +7,94 @@
7#include <linux/module.h> 7#include <linux/module.h>
8#include <linux/init.h> 8#include <linux/init.h>
9 9
10static void elevator_noop_add_request(request_queue_t *q, struct request *rq) 10struct noop_data {
11 struct list_head queue;
12};
13
14static void noop_merged_requests(request_queue_t *q, struct request *rq,
15 struct request *next)
16{
17 list_del_init(&next->queuelist);
18}
19
20static int noop_dispatch(request_queue_t *q, int force)
21{
22 struct noop_data *nd = q->elevator->elevator_data;
23
24 if (!list_empty(&nd->queue)) {
25 struct request *rq;
26 rq = list_entry(nd->queue.next, struct request, queuelist);
27 list_del_init(&rq->queuelist);
28 elv_dispatch_sort(q, rq);
29 return 1;
30 }
31 return 0;
32}
33
34static void noop_add_request(request_queue_t *q, struct request *rq)
35{
36 struct noop_data *nd = q->elevator->elevator_data;
37
38 list_add_tail(&rq->queuelist, &nd->queue);
39}
40
41static int noop_queue_empty(request_queue_t *q)
11{ 42{
12 rq->flags |= REQ_NOMERGE; 43 struct noop_data *nd = q->elevator->elevator_data;
13 elv_dispatch_add_tail(q, rq); 44
45 return list_empty(&nd->queue);
46}
47
48static struct request *
49noop_former_request(request_queue_t *q, struct request *rq)
50{
51 struct noop_data *nd = q->elevator->elevator_data;
52
53 if (rq->queuelist.prev == &nd->queue)
54 return NULL;
55 return list_entry(rq->queuelist.prev, struct request, queuelist);
56}
57
58static struct request *
59noop_latter_request(request_queue_t *q, struct request *rq)
60{
61 struct noop_data *nd = q->elevator->elevator_data;
62
63 if (rq->queuelist.next == &nd->queue)
64 return NULL;
65 return list_entry(rq->queuelist.next, struct request, queuelist);
14} 66}
15 67
16static int elevator_noop_dispatch(request_queue_t *q, int force) 68static int noop_init_queue(request_queue_t *q, elevator_t *e)
17{ 69{
70 struct noop_data *nd;
71
72 nd = kmalloc(sizeof(*nd), GFP_KERNEL);
73 if (!nd)
74 return -ENOMEM;
75 INIT_LIST_HEAD(&nd->queue);
76 e->elevator_data = nd;
18 return 0; 77 return 0;
19} 78}
20 79
80static void noop_exit_queue(elevator_t *e)
81{
82 struct noop_data *nd = e->elevator_data;
83
84 BUG_ON(!list_empty(&nd->queue));
85 kfree(nd);
86}
87
21static struct elevator_type elevator_noop = { 88static struct elevator_type elevator_noop = {
22 .ops = { 89 .ops = {
23 .elevator_dispatch_fn = elevator_noop_dispatch, 90 .elevator_merge_req_fn = noop_merged_requests,
24 .elevator_add_req_fn = elevator_noop_add_request, 91 .elevator_dispatch_fn = noop_dispatch,
92 .elevator_add_req_fn = noop_add_request,
93 .elevator_queue_empty_fn = noop_queue_empty,
94 .elevator_former_req_fn = noop_former_request,
95 .elevator_latter_req_fn = noop_latter_request,
96 .elevator_init_fn = noop_init_queue,
97 .elevator_exit_fn = noop_exit_queue,
25 }, 98 },
26 .elevator_name = "noop", 99 .elevator_name = "noop",
27 .elevator_owner = THIS_MODULE, 100 .elevator_owner = THIS_MODULE,