blob: b1730b62c37e4793a2401df975680c1231903d16 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 */
13static int elevator_noop_merge(request_queue_t *q, struct request **req,
14 struct bio *bio)
15{
Linus Torvalds1da177e2005-04-16 15:20:36 -070016 int ret;
17
Jens Axboe1181c1f2005-05-01 08:59:06 -070018 ret = elv_try_last_merge(q, bio);
19 if (ret != ELEVATOR_NO_MERGE)
Linus Torvalds1da177e2005-04-16 15:20:36 -070020 *req = q->last_merge;
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
Jens Axboe1181c1f2005-05-01 08:59:06 -070022 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -070023}
24
25static 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
31static void elevator_noop_add_request(request_queue_t *q, struct request *rq,
32 int where)
33{
34 if (where == ELEVATOR_INSERT_FRONT)
35 list_add(&rq->queuelist, &q->queue_head);
36 else
37 list_add_tail(&rq->queuelist, &q->queue_head);
38
39 /*
40 * new merges must not precede this barrier
41 */
42 if (rq->flags & REQ_HARDBARRIER)
43 q->last_merge = NULL;
44 else if (!q->last_merge)
45 q->last_merge = rq;
46}
47
48static struct request *elevator_noop_next_request(request_queue_t *q)
49{
50 if (!list_empty(&q->queue_head))
51 return list_entry_rq(q->queue_head.next);
52
53 return NULL;
54}
55
56static struct elevator_type elevator_noop = {
57 .ops = {
58 .elevator_merge_fn = elevator_noop_merge,
59 .elevator_merge_req_fn = elevator_noop_merge_requests,
60 .elevator_next_req_fn = elevator_noop_next_request,
61 .elevator_add_req_fn = elevator_noop_add_request,
62 },
63 .elevator_name = "noop",
64 .elevator_owner = THIS_MODULE,
65};
66
67static int __init noop_init(void)
68{
69 return elv_register(&elevator_noop);
70}
71
72static void __exit noop_exit(void)
73{
74 elv_unregister(&elevator_noop);
75}
76
77module_init(noop_init);
78module_exit(noop_exit);
79
80
81MODULE_AUTHOR("Jens Axboe");
82MODULE_LICENSE("GPL");
83MODULE_DESCRIPTION("No-op IO scheduler");