aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--block/zen-iosched.c40
1 files changed, 25 insertions, 15 deletions
diff --git a/block/zen-iosched.c b/block/zen-iosched.c
index af2537bfd..24a384db5 100644
--- a/block/zen-iosched.c
+++ b/block/zen-iosched.c
@@ -3,7 +3,8 @@
* Primarily based on Noop, deadline, and SIO IO schedulers.
*
* Copyright (C) 2012 Brandon Berhent <bbedward@gmail.com>
- *
+ * (C) 2014 LoungeKatt <twistedumbrella@gmail.com>
+ * 2015 Fixes to stop crashing on 3.10 by Matthew Alex <matthewalex@outlook.com>
* FCFS, dispatches are back-inserted, deadlines ensure fairness.
* Should work best with devices where there is no travel delay.
*/
@@ -156,21 +157,33 @@ static int zen_dispatch_requests(struct request_queue *q, int force)
return 1;
}
-static void *zen_init_queue(struct request_queue *q)
+static int zen_init_queue(struct request_queue *q, struct elevator_type *e)
{
struct zen_data *zdata;
+ struct elevator_queue *eq;
+
+ eq = elevator_alloc(q, e);
+ if (!eq)
+ return -ENOMEM;
zdata = kmalloc_node(sizeof(*zdata), GFP_KERNEL, q->node);
- if (!zdata)
- return NULL;
+ if (!zdata) {
+ kobject_put(&eq->kobj);
+ return -ENOMEM;
+ }
+ eq->elevator_data = zdata;
+
+
+ spin_lock_irq(q->queue_lock);
+ q->elevator = eq;
+ spin_unlock_irq(q->queue_lock);
+
INIT_LIST_HEAD(&zdata->fifo_list[SYNC]);
INIT_LIST_HEAD(&zdata->fifo_list[ASYNC]);
-
zdata->fifo_expire[SYNC] = sync_expire;
zdata->fifo_expire[ASYNC] = async_expire;
zdata->fifo_batch = fifo_batch;
-
- return zdata;
+ return 0;
}
static void zen_exit_queue(struct elevator_queue *e)
@@ -210,7 +223,7 @@ SHOW_FUNCTION(zen_async_expire_show, zdata->fifo_expire[ASYNC], 1);
SHOW_FUNCTION(zen_fifo_batch_show, zdata->fifo_batch, 0);
#undef SHOW_FUNCTION
-#define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX, __CONV, NDX) \
+#define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX, __CONV) \
static ssize_t __FUNC(struct elevator_queue *e, const char *page, size_t count) \
{ \
struct zen_data *zdata = e->elevator_data; \
@@ -226,9 +239,9 @@ static ssize_t __FUNC(struct elevator_queue *e, const char *page, size_t count)
*(__PTR) = __data; \
return ret; \
}
-STORE_FUNCTION(zen_sync_expire_store, &zdata->fifo_expire[SYNC], 0, INT_MAX, 1, 0);
-STORE_FUNCTION(zen_async_expire_store, &zdata->fifo_expire[ASYNC], 0, INT_MAX, 1, 1);
-STORE_FUNCTION(zen_fifo_batch_store, &zdata->fifo_batch, 0, INT_MAX, 0, 2);
+STORE_FUNCTION(zen_sync_expire_store, &zdata->fifo_expire[SYNC], 0, INT_MAX, 1);
+STORE_FUNCTION(zen_async_expire_store, &zdata->fifo_expire[ASYNC], 0, INT_MAX, 1);
+STORE_FUNCTION(zen_fifo_batch_store, &zdata->fifo_batch, 0, INT_MAX, 0);
#undef STORE_FUNCTION
#define DD_ATTR(name) \
@@ -259,9 +272,7 @@ static struct elevator_type iosched_zen = {
static int __init zen_init(void)
{
- elv_register(&iosched_zen);
-
- return 0;
+ return elv_register(&iosched_zen);
}
static void __exit zen_exit(void)
@@ -277,4 +288,3 @@ MODULE_AUTHOR("Brandon Berhent");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Zen IO scheduler");
MODULE_VERSION("1.0");
-