4 #include <linux/blkdev.h>
5 #include <linux/elevator.h>
7 #include <linux/module.h>
8 #include <linux/init.h>
11 * See if we can find a request that this buffer can be coalesced with.
13 static int elevator_noop_merge(request_queue_t
*q
, struct request
**req
,
16 struct list_head
*entry
= &q
->queue_head
;
20 if ((ret
= elv_try_last_merge(q
, bio
))) {
25 while ((entry
= entry
->prev
) != &q
->queue_head
) {
26 __rq
= list_entry_rq(entry
);
28 if (__rq
->flags
& (REQ_SOFTBARRIER
| REQ_HARDBARRIER
))
30 else if (__rq
->flags
& REQ_STARTED
)
33 if (!blk_fs_request(__rq
))
36 if ((ret
= elv_try_merge(__rq
, bio
))) {
43 return ELEVATOR_NO_MERGE
;
46 static void elevator_noop_merge_requests(request_queue_t
*q
, struct request
*req
,
49 list_del_init(&next
->queuelist
);
52 static void elevator_noop_add_request(request_queue_t
*q
, struct request
*rq
,
55 if (where
== ELEVATOR_INSERT_FRONT
)
56 list_add(&rq
->queuelist
, &q
->queue_head
);
58 list_add_tail(&rq
->queuelist
, &q
->queue_head
);
61 * new merges must not precede this barrier
63 if (rq
->flags
& REQ_HARDBARRIER
)
65 else if (!q
->last_merge
)
69 static struct request
*elevator_noop_next_request(request_queue_t
*q
)
71 if (!list_empty(&q
->queue_head
))
72 return list_entry_rq(q
->queue_head
.next
);
77 static struct elevator_type elevator_noop
= {
79 .elevator_merge_fn
= elevator_noop_merge
,
80 .elevator_merge_req_fn
= elevator_noop_merge_requests
,
81 .elevator_next_req_fn
= elevator_noop_next_request
,
82 .elevator_add_req_fn
= elevator_noop_add_request
,
84 .elevator_name
= "noop",
85 .elevator_owner
= THIS_MODULE
,
88 static int __init
noop_init(void)
90 return elv_register(&elevator_noop
);
93 static void __exit
noop_exit(void)
95 elv_unregister(&elevator_noop
);
98 module_init(noop_init
);
99 module_exit(noop_exit
);
102 MODULE_AUTHOR("Jens Axboe");
103 MODULE_LICENSE("GPL");
104 MODULE_DESCRIPTION("No-op IO scheduler");