2005-04-16 18:20:36 -04:00
|
|
|
/*
|
|
|
|
* elevator noop
|
|
|
|
*/
|
|
|
|
#include <linux/blkdev.h>
|
|
|
|
#include <linux/elevator.h>
|
|
|
|
#include <linux/bio.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
|
2005-11-10 12:21:30 -05:00
|
|
|
struct noop_data {
|
|
|
|
struct list_head queue;
|
|
|
|
};
|
|
|
|
|
2007-07-24 03:28:11 -04:00
|
|
|
static void noop_merged_requests(struct request_queue *q, struct request *rq,
|
2005-11-10 12:21:30 -05:00
|
|
|
struct request *next)
|
|
|
|
{
|
|
|
|
list_del_init(&next->queuelist);
|
|
|
|
}
|
|
|
|
|
2007-07-24 03:28:11 -04:00
|
|
|
static int noop_dispatch(struct request_queue *q, int force)
|
2005-11-10 12:21:30 -05:00
|
|
|
{
|
|
|
|
struct noop_data *nd = q->elevator->elevator_data;
|
|
|
|
|
|
|
|
if (!list_empty(&nd->queue)) {
|
|
|
|
struct request *rq;
|
|
|
|
rq = list_entry(nd->queue.next, struct request, queuelist);
|
|
|
|
list_del_init(&rq->queuelist);
|
|
|
|
elv_dispatch_sort(q, rq);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-07-24 03:28:11 -04:00
|
|
|
static void noop_add_request(struct request_queue *q, struct request *rq)
|
2005-11-10 12:21:30 -05:00
|
|
|
{
|
|
|
|
struct noop_data *nd = q->elevator->elevator_data;
|
|
|
|
|
|
|
|
list_add_tail(&rq->queuelist, &nd->queue);
|
|
|
|
}
|
|
|
|
|
2007-07-24 03:28:11 -04:00
|
|
|
static int noop_queue_empty(struct request_queue *q)
|
2005-04-16 18:20:36 -04:00
|
|
|
{
|
2005-11-10 12:21:30 -05:00
|
|
|
struct noop_data *nd = q->elevator->elevator_data;
|
|
|
|
|
|
|
|
return list_empty(&nd->queue);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct request *
|
2007-07-24 03:28:11 -04:00
|
|
|
noop_former_request(struct request_queue *q, struct request *rq)
|
2005-11-10 12:21:30 -05:00
|
|
|
{
|
|
|
|
struct noop_data *nd = q->elevator->elevator_data;
|
|
|
|
|
|
|
|
if (rq->queuelist.prev == &nd->queue)
|
|
|
|
return NULL;
|
|
|
|
return list_entry(rq->queuelist.prev, struct request, queuelist);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct request *
|
2007-07-24 03:28:11 -04:00
|
|
|
noop_latter_request(struct request_queue *q, struct request *rq)
|
2005-11-10 12:21:30 -05:00
|
|
|
{
|
|
|
|
struct noop_data *nd = q->elevator->elevator_data;
|
|
|
|
|
|
|
|
if (rq->queuelist.next == &nd->queue)
|
|
|
|
return NULL;
|
|
|
|
return list_entry(rq->queuelist.next, struct request, queuelist);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
2007-07-24 03:28:11 -04:00
|
|
|
static void *noop_init_queue(struct request_queue *q)
|
2005-04-16 18:20:36 -04:00
|
|
|
{
|
2005-11-10 12:21:30 -05:00
|
|
|
struct noop_data *nd;
|
|
|
|
|
2006-07-19 17:39:40 -04:00
|
|
|
nd = kmalloc_node(sizeof(*nd), GFP_KERNEL, q->node);
|
2005-11-10 12:21:30 -05:00
|
|
|
if (!nd)
|
2006-06-08 02:49:06 -04:00
|
|
|
return NULL;
|
2005-11-10 12:21:30 -05:00
|
|
|
INIT_LIST_HEAD(&nd->queue);
|
2006-06-08 02:49:06 -04:00
|
|
|
return nd;
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
2005-11-10 12:21:30 -05:00
|
|
|
static void noop_exit_queue(elevator_t *e)
|
|
|
|
{
|
|
|
|
struct noop_data *nd = e->elevator_data;
|
|
|
|
|
|
|
|
BUG_ON(!list_empty(&nd->queue));
|
|
|
|
kfree(nd);
|
|
|
|
}
|
|
|
|
|
2005-04-16 18:20:36 -04:00
|
|
|
static struct elevator_type elevator_noop = {
|
|
|
|
.ops = {
|
2005-11-10 12:21:30 -05:00
|
|
|
.elevator_merge_req_fn = noop_merged_requests,
|
|
|
|
.elevator_dispatch_fn = noop_dispatch,
|
|
|
|
.elevator_add_req_fn = noop_add_request,
|
|
|
|
.elevator_queue_empty_fn = noop_queue_empty,
|
|
|
|
.elevator_former_req_fn = noop_former_request,
|
|
|
|
.elevator_latter_req_fn = noop_latter_request,
|
|
|
|
.elevator_init_fn = noop_init_queue,
|
|
|
|
.elevator_exit_fn = noop_exit_queue,
|
2005-04-16 18:20:36 -04:00
|
|
|
},
|
|
|
|
.elevator_name = "noop",
|
|
|
|
.elevator_owner = THIS_MODULE,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init noop_init(void)
|
|
|
|
{
|
2007-12-12 12:51:56 -05:00
|
|
|
elv_register(&elevator_noop);
|
|
|
|
|
|
|
|
return 0;
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit noop_exit(void)
|
|
|
|
{
|
|
|
|
elv_unregister(&elevator_noop);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(noop_init);
|
|
|
|
module_exit(noop_exit);
|
|
|
|
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Jens Axboe");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_DESCRIPTION("No-op IO scheduler");
|