diff options
author | Tejun Heo <tj@kernel.org> | 2012-03-05 16:14:57 -0500 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2012-03-06 15:27:21 -0500 |
commit | b2fab5acd28ead6f0dd6c3996ba23f0ef1772f15 (patch) | |
tree | b0b96984e1a4d9c856edc9ddfc36e427951c5a86 | |
parent | 5a5bafdc396b1da7570f84fb96a0f8a288970c5e (diff) |
elevator: make elevator_init_fn() return 0/-errno
elevator_ops->elevator_init_fn() has a weird return value. It returns
a void * which the caller should assign to q->elevator->elevator_data
and %NULL return denotes init failure.
Update such that it returns integer 0/-errno and sets elevator_data
directly as necessary.
This makes the interface more conventional and eases further cleanup.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | block/cfq-iosched.c | 9 | ||||
-rw-r--r-- | block/deadline-iosched.c | 8 | ||||
-rw-r--r-- | block/elevator.c | 12 | ||||
-rw-r--r-- | block/noop-iosched.c | 8 | ||||
-rw-r--r-- | include/linux/elevator.h | 2 |
5 files changed, 18 insertions, 21 deletions
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c index 388fe01de18e..72680a6715fc 100644 --- a/block/cfq-iosched.c +++ b/block/cfq-iosched.c | |||
@@ -3656,7 +3656,7 @@ static void cfq_exit_queue(struct elevator_queue *e) | |||
3656 | kfree(cfqd); | 3656 | kfree(cfqd); |
3657 | } | 3657 | } |
3658 | 3658 | ||
3659 | static void *cfq_init_queue(struct request_queue *q) | 3659 | static int cfq_init_queue(struct request_queue *q) |
3660 | { | 3660 | { |
3661 | struct cfq_data *cfqd; | 3661 | struct cfq_data *cfqd; |
3662 | int i, j; | 3662 | int i, j; |
@@ -3665,7 +3665,7 @@ static void *cfq_init_queue(struct request_queue *q) | |||
3665 | 3665 | ||
3666 | cfqd = kmalloc_node(sizeof(*cfqd), GFP_KERNEL | __GFP_ZERO, q->node); | 3666 | cfqd = kmalloc_node(sizeof(*cfqd), GFP_KERNEL | __GFP_ZERO, q->node); |
3667 | if (!cfqd) | 3667 | if (!cfqd) |
3668 | return NULL; | 3668 | return -ENOMEM; |
3669 | 3669 | ||
3670 | /* Init root service tree */ | 3670 | /* Init root service tree */ |
3671 | cfqd->grp_service_tree = CFQ_RB_ROOT; | 3671 | cfqd->grp_service_tree = CFQ_RB_ROOT; |
@@ -3692,7 +3692,7 @@ static void *cfq_init_queue(struct request_queue *q) | |||
3692 | if (blkio_alloc_blkg_stats(&cfqg->blkg)) { | 3692 | if (blkio_alloc_blkg_stats(&cfqg->blkg)) { |
3693 | kfree(cfqg); | 3693 | kfree(cfqg); |
3694 | kfree(cfqd); | 3694 | kfree(cfqd); |
3695 | return NULL; | 3695 | return -ENOMEM; |
3696 | } | 3696 | } |
3697 | 3697 | ||
3698 | rcu_read_lock(); | 3698 | rcu_read_lock(); |
@@ -3723,6 +3723,7 @@ static void *cfq_init_queue(struct request_queue *q) | |||
3723 | cfq_link_cfqq_cfqg(&cfqd->oom_cfqq, &cfqd->root_group); | 3723 | cfq_link_cfqq_cfqg(&cfqd->oom_cfqq, &cfqd->root_group); |
3724 | 3724 | ||
3725 | cfqd->queue = q; | 3725 | cfqd->queue = q; |
3726 | q->elevator->elevator_data = cfqd; | ||
3726 | 3727 | ||
3727 | init_timer(&cfqd->idle_slice_timer); | 3728 | init_timer(&cfqd->idle_slice_timer); |
3728 | cfqd->idle_slice_timer.function = cfq_idle_slice_timer; | 3729 | cfqd->idle_slice_timer.function = cfq_idle_slice_timer; |
@@ -3747,7 +3748,7 @@ static void *cfq_init_queue(struct request_queue *q) | |||
3747 | * second, in order to have larger depth for async operations. | 3748 | * second, in order to have larger depth for async operations. |
3748 | */ | 3749 | */ |
3749 | cfqd->last_delayed_sync = jiffies - HZ; | 3750 | cfqd->last_delayed_sync = jiffies - HZ; |
3750 | return cfqd; | 3751 | return 0; |
3751 | } | 3752 | } |
3752 | 3753 | ||
3753 | /* | 3754 | /* |
diff --git a/block/deadline-iosched.c b/block/deadline-iosched.c index 7bf12d793fcd..599b12e5380f 100644 --- a/block/deadline-iosched.c +++ b/block/deadline-iosched.c | |||
@@ -337,13 +337,13 @@ static void deadline_exit_queue(struct elevator_queue *e) | |||
337 | /* | 337 | /* |
338 | * initialize elevator private data (deadline_data). | 338 | * initialize elevator private data (deadline_data). |
339 | */ | 339 | */ |
340 | static void *deadline_init_queue(struct request_queue *q) | 340 | static int deadline_init_queue(struct request_queue *q) |
341 | { | 341 | { |
342 | struct deadline_data *dd; | 342 | struct deadline_data *dd; |
343 | 343 | ||
344 | dd = kmalloc_node(sizeof(*dd), GFP_KERNEL | __GFP_ZERO, q->node); | 344 | dd = kmalloc_node(sizeof(*dd), GFP_KERNEL | __GFP_ZERO, q->node); |
345 | if (!dd) | 345 | if (!dd) |
346 | return NULL; | 346 | return -ENOMEM; |
347 | 347 | ||
348 | INIT_LIST_HEAD(&dd->fifo_list[READ]); | 348 | INIT_LIST_HEAD(&dd->fifo_list[READ]); |
349 | INIT_LIST_HEAD(&dd->fifo_list[WRITE]); | 349 | INIT_LIST_HEAD(&dd->fifo_list[WRITE]); |
@@ -354,7 +354,9 @@ static void *deadline_init_queue(struct request_queue *q) | |||
354 | dd->writes_starved = writes_starved; | 354 | dd->writes_starved = writes_starved; |
355 | dd->front_merges = 1; | 355 | dd->front_merges = 1; |
356 | dd->fifo_batch = fifo_batch; | 356 | dd->fifo_batch = fifo_batch; |
357 | return dd; | 357 | |
358 | q->elevator->elevator_data = dd; | ||
359 | return 0; | ||
358 | } | 360 | } |
359 | 361 | ||
360 | /* | 362 | /* |
diff --git a/block/elevator.c b/block/elevator.c index f8c08e1bff2b..f81c061dad15 100644 --- a/block/elevator.c +++ b/block/elevator.c | |||
@@ -121,14 +121,6 @@ static struct elevator_type *elevator_get(const char *name) | |||
121 | return e; | 121 | return e; |
122 | } | 122 | } |
123 | 123 | ||
124 | static int elevator_init_queue(struct request_queue *q) | ||
125 | { | ||
126 | q->elevator->elevator_data = q->elevator->type->ops.elevator_init_fn(q); | ||
127 | if (q->elevator->elevator_data) | ||
128 | return 0; | ||
129 | return -ENOMEM; | ||
130 | } | ||
131 | |||
132 | static char chosen_elevator[ELV_NAME_MAX]; | 124 | static char chosen_elevator[ELV_NAME_MAX]; |
133 | 125 | ||
134 | static int __init elevator_setup(char *str) | 126 | static int __init elevator_setup(char *str) |
@@ -224,7 +216,7 @@ int elevator_init(struct request_queue *q, char *name) | |||
224 | if (!q->elevator) | 216 | if (!q->elevator) |
225 | return -ENOMEM; | 217 | return -ENOMEM; |
226 | 218 | ||
227 | err = elevator_init_queue(q); | 219 | err = e->ops.elevator_init_fn(q); |
228 | if (err) { | 220 | if (err) { |
229 | kobject_put(&q->elevator->kobj); | 221 | kobject_put(&q->elevator->kobj); |
230 | return err; | 222 | return err; |
@@ -927,7 +919,7 @@ static int elevator_switch(struct request_queue *q, struct elevator_type *new_e) | |||
927 | if (!q->elevator) | 919 | if (!q->elevator) |
928 | goto fail_init; | 920 | goto fail_init; |
929 | 921 | ||
930 | err = elevator_init_queue(q); | 922 | err = new_e->ops.elevator_init_fn(q); |
931 | if (err) { | 923 | if (err) { |
932 | kobject_put(&q->elevator->kobj); | 924 | kobject_put(&q->elevator->kobj); |
933 | goto fail_init; | 925 | goto fail_init; |
diff --git a/block/noop-iosched.c b/block/noop-iosched.c index 413a0b1d788c..5d1bf70e33d5 100644 --- a/block/noop-iosched.c +++ b/block/noop-iosched.c | |||
@@ -59,15 +59,17 @@ noop_latter_request(struct request_queue *q, struct request *rq) | |||
59 | return list_entry(rq->queuelist.next, struct request, queuelist); | 59 | return list_entry(rq->queuelist.next, struct request, queuelist); |
60 | } | 60 | } |
61 | 61 | ||
62 | static void *noop_init_queue(struct request_queue *q) | 62 | static int noop_init_queue(struct request_queue *q) |
63 | { | 63 | { |
64 | struct noop_data *nd; | 64 | struct noop_data *nd; |
65 | 65 | ||
66 | nd = kmalloc_node(sizeof(*nd), GFP_KERNEL, q->node); | 66 | nd = kmalloc_node(sizeof(*nd), GFP_KERNEL, q->node); |
67 | if (!nd) | 67 | if (!nd) |
68 | return NULL; | 68 | return -ENOMEM; |
69 | |||
69 | INIT_LIST_HEAD(&nd->queue); | 70 | INIT_LIST_HEAD(&nd->queue); |
70 | return nd; | 71 | q->elevator->elevator_data = nd; |
72 | return 0; | ||
71 | } | 73 | } |
72 | 74 | ||
73 | static void noop_exit_queue(struct elevator_queue *e) | 75 | static void noop_exit_queue(struct elevator_queue *e) |
diff --git a/include/linux/elevator.h b/include/linux/elevator.h index 7d4e0356f329..97fb2557a18c 100644 --- a/include/linux/elevator.h +++ b/include/linux/elevator.h | |||
@@ -33,7 +33,7 @@ typedef void (elevator_put_req_fn) (struct request *); | |||
33 | typedef void (elevator_activate_req_fn) (struct request_queue *, struct request *); | 33 | typedef void (elevator_activate_req_fn) (struct request_queue *, struct request *); |
34 | typedef void (elevator_deactivate_req_fn) (struct request_queue *, struct request *); | 34 | typedef void (elevator_deactivate_req_fn) (struct request_queue *, struct request *); |
35 | 35 | ||
36 | typedef void *(elevator_init_fn) (struct request_queue *); | 36 | typedef int (elevator_init_fn) (struct request_queue *); |
37 | typedef void (elevator_exit_fn) (struct elevator_queue *); | 37 | typedef void (elevator_exit_fn) (struct elevator_queue *); |
38 | 38 | ||
39 | struct elevator_ops | 39 | struct elevator_ops |