block: Add FIFO scheduler
Signed-off-by: andip71 <andreasp@gmx.de> Signed-off-by: djb77 <dwayne.bakewell@gmail.com> Signed-off-by: prashantpaddune <elonpras@my.smccd.edu>
This commit is contained in:
parent
b8a7393f07
commit
5d4baa68a8
|
@ -310,11 +310,13 @@ CONFIG_IOSCHED_BFQ=y
|
|||
# CONFIG_BFQ_GROUP_IOSCHED is not set
|
||||
CONFIG_IOSCHED_FIOPS=y
|
||||
CONFIG_IOSCHED_SIO=y
|
||||
CONFIG_IOSCHED_FIFO=y
|
||||
CONFIG_DEFAULT_CFQ=y
|
||||
# CONFIG_DEFAULT_BFQ is not set
|
||||
# CONFIG_DEFAULT_NOOP is not set
|
||||
# CONFIG_DEFAULT_FIOPS is not set
|
||||
# CONFIG_DEFAULT_SIO is not set
|
||||
# CONFIG_DEFAULT_FIFO is not set
|
||||
CONFIG_DEFAULT_IOSCHED="cfq"
|
||||
CONFIG_ASN1=y
|
||||
CONFIG_UNINLINE_SPIN_UNLOCK=y
|
||||
|
|
|
@ -76,6 +76,13 @@ config IOSCHED_FIOPS
|
|||
IOPS equally among all processes in the system. It's mainly for
|
||||
Flash based storage.
|
||||
|
||||
config IOSCHED_FIFO
|
||||
tristate "FIFO I/O scheduler"
|
||||
default y
|
||||
---help---
|
||||
Fifo is similar to no-op I/O scheduler and it's a minimal scheduler that does basic merging
|
||||
and sorting. Ported from: https://github.com/AndroidDeveloperAlliance/ZenKernel_TUNA/blob/master/block/fifo-iosched.c
|
||||
|
||||
choice
|
||||
prompt "Default I/O scheduler"
|
||||
default DEFAULT_CFQ
|
||||
|
@ -108,6 +115,9 @@ choice
|
|||
config DEFAULT_SIO
|
||||
bool "SIO" if IOSCHED_SIO=y
|
||||
|
||||
config DEFAULT_FIFO
|
||||
bool "fifo" if IOSCHED_FIFO=y
|
||||
|
||||
endchoice
|
||||
|
||||
config DEFAULT_IOSCHED
|
||||
|
@ -118,6 +128,7 @@ config DEFAULT_IOSCHED
|
|||
default "fiops" if DEFAULT_FIOPS
|
||||
default "noop" if DEFAULT_NOOP
|
||||
default "sio" if DEFAULT_SIO
|
||||
default "fifo" if DEFAULT_FIFO
|
||||
|
||||
endmenu
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ obj-$(CONFIG_IOSCHED_CFQ) += cfq-iosched.o
|
|||
obj-$(CONFIG_IOSCHED_BFQ) += bfq-iosched.o
|
||||
obj-$(CONFIG_IOSCHED_FIOPS) += fiops-iosched.o
|
||||
obj-$(CONFIG_IOSCHED_SIO) += sio-iosched.o
|
||||
obj-$(CONFIG_IOSCHED_FIFO) += fifo-iosched.o
|
||||
|
||||
obj-$(CONFIG_BLOCK_COMPAT) += compat_ioctl.o
|
||||
obj-$(CONFIG_BLK_CMDLINE_PARSER) += cmdline-parser.o
|
||||
|
|
99
block/fifo-iosched.c
Normal file
99
block/fifo-iosched.c
Normal file
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
* FIFO I/O scheduler (_really_ does no-op)
|
||||
*/
|
||||
#include <linux/blkdev.h>
|
||||
#include <linux/elevator.h>
|
||||
#include <linux/bio.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
|
||||
struct fifo_data {
|
||||
struct list_head queue;
|
||||
};
|
||||
|
||||
static int fifo_dispatch(struct request_queue *q, int force)
|
||||
{
|
||||
struct fifo_data *fifo_d = q->elevator->elevator_data;
|
||||
|
||||
if (!list_empty(&fifo_d->queue)) {
|
||||
struct request *req = list_entry(fifo_d->queue.next, struct request, queuelist);
|
||||
list_del_init(&req->queuelist);
|
||||
elv_dispatch_add_tail(q, req);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void fifo_add_request(struct request_queue *q, struct request *req)
|
||||
{
|
||||
struct fifo_data *fifo_d = q->elevator->elevator_data;
|
||||
list_add_tail(&req->queuelist, &fifo_d->queue);
|
||||
}
|
||||
|
||||
static int fifo_init_queue(struct request_queue *q, struct elevator_type *e)
|
||||
{
|
||||
struct fifo_data *fifo_d;
|
||||
struct elevator_queue *eq;
|
||||
|
||||
eq = elevator_alloc(q, e);
|
||||
if (!eq)
|
||||
return -ENOMEM;
|
||||
|
||||
fifo_d = kmalloc_node(sizeof(*fifo_d), GFP_KERNEL, q->node);
|
||||
if (!fifo_d) {
|
||||
kobject_put(&eq->kobj);
|
||||
return -ENOMEM;
|
||||
}
|
||||
eq->elevator_data = fifo_d;
|
||||
|
||||
INIT_LIST_HEAD(&fifo_d->queue);
|
||||
|
||||
spin_lock_irq(q->queue_lock);
|
||||
q->elevator = eq;
|
||||
spin_unlock_irq(q->queue_lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void fifo_exit_queue(struct elevator_queue *e)
|
||||
{
|
||||
struct fifo_data *fifo_d = e->elevator_data;
|
||||
|
||||
BUG_ON(!list_empty(&fifo_d->queue));
|
||||
kfree(fifo_d);
|
||||
}
|
||||
|
||||
static int fifo_deny_merge(struct request_queue *req_q, struct request *req,
|
||||
struct bio *bio)
|
||||
{
|
||||
return ELEVATOR_NO_MERGE;
|
||||
}
|
||||
|
||||
static struct elevator_type elevator_fifo = {
|
||||
.ops = {
|
||||
.elevator_dispatch_fn = fifo_dispatch,
|
||||
.elevator_add_req_fn = fifo_add_request,
|
||||
.elevator_allow_merge_fn = fifo_deny_merge,
|
||||
.elevator_init_fn = fifo_init_queue,
|
||||
.elevator_exit_fn = fifo_exit_queue,
|
||||
},
|
||||
.elevator_name = "fifo",
|
||||
.elevator_owner = THIS_MODULE,
|
||||
};
|
||||
|
||||
static int __init fifo_init(void)
|
||||
{
|
||||
return elv_register(&elevator_fifo);
|
||||
}
|
||||
|
||||
static void __exit fifo_exit(void)
|
||||
{
|
||||
elv_unregister(&elevator_fifo);
|
||||
}
|
||||
|
||||
module_init(fifo_init);
|
||||
module_exit(fifo_exit);
|
||||
|
||||
MODULE_AUTHOR("Aaron Carroll");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION("No-op IO scheduler that actually does nothing");
|
Loading…
Reference in New Issue
Block a user