]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - drivers/block/noop-iosched.c
[PATCH] 02/05: update ioscheds to use generic dispatch queue
[mirror_ubuntu-artful-kernel.git] / drivers / block / noop-iosched.c
1 /*
2 * elevator noop
3 */
4 #include <linux/blkdev.h>
5 #include <linux/elevator.h>
6 #include <linux/bio.h>
7 #include <linux/module.h>
8 #include <linux/init.h>
9
10 /*
11 * See if we can find a request that this buffer can be coalesced with.
12 */
13 static int elevator_noop_merge(request_queue_t *q, struct request **req,
14 struct bio *bio)
15 {
16 int ret;
17
18 ret = elv_try_last_merge(q, bio);
19 if (ret != ELEVATOR_NO_MERGE)
20 *req = q->last_merge;
21
22 return ret;
23 }
24
25 static void elevator_noop_merge_requests(request_queue_t *q, struct request *req,
26 struct request *next)
27 {
28 list_del_init(&next->queuelist);
29 }
30
31 static void elevator_noop_add_request(request_queue_t *q, struct request *rq)
32 {
33 elv_dispatch_add_tail(q, rq);
34
35 /*
36 * new merges must not precede this barrier
37 */
38 if (rq->flags & REQ_HARDBARRIER)
39 q->last_merge = NULL;
40 else if (!q->last_merge)
41 q->last_merge = rq;
42 }
43
44 static int elevator_noop_dispatch(request_queue_t *q, int force)
45 {
46 return 0;
47 }
48
49 static struct elevator_type elevator_noop = {
50 .ops = {
51 .elevator_merge_fn = elevator_noop_merge,
52 .elevator_merge_req_fn = elevator_noop_merge_requests,
53 .elevator_dispatch_fn = elevator_noop_dispatch,
54 .elevator_add_req_fn = elevator_noop_add_request,
55 },
56 .elevator_name = "noop",
57 .elevator_owner = THIS_MODULE,
58 };
59
60 static int __init noop_init(void)
61 {
62 return elv_register(&elevator_noop);
63 }
64
65 static void __exit noop_exit(void)
66 {
67 elv_unregister(&elevator_noop);
68 }
69
70 module_init(noop_init);
71 module_exit(noop_exit);
72
73
74 MODULE_AUTHOR("Jens Axboe");
75 MODULE_LICENSE("GPL");
76 MODULE_DESCRIPTION("No-op IO scheduler");