forked from MoKee/android_kernel_zte_nx507j
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfifo-iosched.c
87 lines (73 loc) · 1.93 KB
/
fifo-iosched.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
* 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 void *fifo_init_queue(struct request_queue *q)
{
struct fifo_data *fifo_d;
fifo_d = kmalloc_node(sizeof(*fifo_d), GFP_KERNEL, q->node);
if (!fifo_d)
return NULL;
INIT_LIST_HEAD(&fifo_d->queue);
return fifo_d;
}
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)
{
elv_register(&elevator_fifo);
return 0;
}
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");