4 #include <linux/blkdev.h>
5 #include <linux/elevator.h>
7 #include <linux/module.h>
8 #include <linux/init.h>
11 struct list_head queue
;
14 static void noop_merged_requests(struct request_queue
*q
, struct request
*rq
,
17 list_del_init(&next
->queuelist
);
20 static int noop_dispatch(struct request_queue
*q
, int force
)
22 struct noop_data
*nd
= q
->elevator
->elevator_data
;
24 if (!list_empty(&nd
->queue
)) {
26 rq
= list_entry(nd
->queue
.next
, struct request
, queuelist
);
27 list_del_init(&rq
->queuelist
);
28 elv_dispatch_sort(q
, rq
);
34 static void noop_add_request(struct request_queue
*q
, struct request
*rq
)
36 struct noop_data
*nd
= q
->elevator
->elevator_data
;
38 list_add_tail(&rq
->queuelist
, &nd
->queue
);
41 static int noop_queue_empty(struct request_queue
*q
)
43 struct noop_data
*nd
= q
->elevator
->elevator_data
;
45 return list_empty(&nd
->queue
);
48 static struct request
*
49 noop_former_request(struct request_queue
*q
, struct request
*rq
)
51 struct noop_data
*nd
= q
->elevator
->elevator_data
;
53 if (rq
->queuelist
.prev
== &nd
->queue
)
55 return list_entry(rq
->queuelist
.prev
, struct request
, queuelist
);
58 static struct request
*
59 noop_latter_request(struct request_queue
*q
, struct request
*rq
)
61 struct noop_data
*nd
= q
->elevator
->elevator_data
;
63 if (rq
->queuelist
.next
== &nd
->queue
)
65 return list_entry(rq
->queuelist
.next
, struct request
, queuelist
);
68 static void *noop_init_queue(struct request_queue
*q
)
72 nd
= kmalloc_node(sizeof(*nd
), GFP_KERNEL
, q
->node
);
75 INIT_LIST_HEAD(&nd
->queue
);
79 static void noop_exit_queue(elevator_t
*e
)
81 struct noop_data
*nd
= e
->elevator_data
;
83 BUG_ON(!list_empty(&nd
->queue
));
87 static struct elevator_type elevator_noop
= {
89 .elevator_merge_req_fn
= noop_merged_requests
,
90 .elevator_dispatch_fn
= noop_dispatch
,
91 .elevator_add_req_fn
= noop_add_request
,
92 .elevator_queue_empty_fn
= noop_queue_empty
,
93 .elevator_former_req_fn
= noop_former_request
,
94 .elevator_latter_req_fn
= noop_latter_request
,
95 .elevator_init_fn
= noop_init_queue
,
96 .elevator_exit_fn
= noop_exit_queue
,
98 .elevator_name
= "noop",
99 .elevator_owner
= THIS_MODULE
,
102 static int __init
noop_init(void)
104 elv_register(&elevator_noop
);
109 static void __exit
noop_exit(void)
111 elv_unregister(&elevator_noop
);
114 module_init(noop_init
);
115 module_exit(noop_exit
);
118 MODULE_AUTHOR("Jens Axboe");
119 MODULE_LICENSE("GPL");
120 MODULE_DESCRIPTION("No-op IO scheduler");