Blame view
block/noop-iosched.c
2.61 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 4 5 6 7 |
/* * elevator noop */ #include <linux/blkdev.h> #include <linux/elevator.h> #include <linux/bio.h> #include <linux/module.h> |
5a0e3ad6a include cleanup: ... |
8 |
#include <linux/slab.h> |
1da177e4c Linux-2.6.12-rc2 |
9 |
#include <linux/init.h> |
5a7c47eef [BLOCK] noop-iosc... |
10 11 12 |
struct noop_data { struct list_head queue; }; |
165125e1e [BLOCK] Get rid o... |
13 |
static void noop_merged_requests(struct request_queue *q, struct request *rq, |
5a7c47eef [BLOCK] noop-iosc... |
14 15 16 17 |
struct request *next) { list_del_init(&next->queuelist); } |
165125e1e [BLOCK] Get rid o... |
18 |
static int noop_dispatch(struct request_queue *q, int force) |
5a7c47eef [BLOCK] noop-iosc... |
19 20 |
{ struct noop_data *nd = q->elevator->elevator_data; |
4736346bb elevator: use lis... |
21 |
struct request *rq; |
5a7c47eef [BLOCK] noop-iosc... |
22 |
|
4736346bb elevator: use lis... |
23 24 |
rq = list_first_entry_or_null(&nd->queue, struct request, queuelist); if (rq) { |
5a7c47eef [BLOCK] noop-iosc... |
25 26 27 28 29 30 |
list_del_init(&rq->queuelist); elv_dispatch_sort(q, rq); return 1; } return 0; } |
165125e1e [BLOCK] Get rid o... |
31 |
static void noop_add_request(struct request_queue *q, struct request *rq) |
5a7c47eef [BLOCK] noop-iosc... |
32 33 34 35 36 |
{ struct noop_data *nd = q->elevator->elevator_data; list_add_tail(&rq->queuelist, &nd->queue); } |
5a7c47eef [BLOCK] noop-iosc... |
37 |
static struct request * |
165125e1e [BLOCK] Get rid o... |
38 |
noop_former_request(struct request_queue *q, struct request *rq) |
5a7c47eef [BLOCK] noop-iosc... |
39 40 41 42 43 |
{ struct noop_data *nd = q->elevator->elevator_data; if (rq->queuelist.prev == &nd->queue) return NULL; |
4736346bb elevator: use lis... |
44 |
return list_prev_entry(rq, queuelist); |
5a7c47eef [BLOCK] noop-iosc... |
45 46 47 |
} static struct request * |
165125e1e [BLOCK] Get rid o... |
48 |
noop_latter_request(struct request_queue *q, struct request *rq) |
5a7c47eef [BLOCK] noop-iosc... |
49 50 51 52 53 |
{ struct noop_data *nd = q->elevator->elevator_data; if (rq->queuelist.next == &nd->queue) return NULL; |
4736346bb elevator: use lis... |
54 |
return list_next_entry(rq, queuelist); |
1da177e4c Linux-2.6.12-rc2 |
55 |
} |
d50235b7b elevator: Fix a r... |
56 |
static int noop_init_queue(struct request_queue *q, struct elevator_type *e) |
1da177e4c Linux-2.6.12-rc2 |
57 |
{ |
5a7c47eef [BLOCK] noop-iosc... |
58 |
struct noop_data *nd; |
d50235b7b elevator: Fix a r... |
59 60 61 62 63 |
struct elevator_queue *eq; eq = elevator_alloc(q, e); if (!eq) return -ENOMEM; |
5a7c47eef [BLOCK] noop-iosc... |
64 |
|
b5deef901 [PATCH] Make sure... |
65 |
nd = kmalloc_node(sizeof(*nd), GFP_KERNEL, q->node); |
d50235b7b elevator: Fix a r... |
66 67 |
if (!nd) { kobject_put(&eq->kobj); |
b2fab5acd elevator: make el... |
68 |
return -ENOMEM; |
d50235b7b elevator: Fix a r... |
69 70 |
} eq->elevator_data = nd; |
b2fab5acd elevator: make el... |
71 |
|
5a7c47eef [BLOCK] noop-iosc... |
72 |
INIT_LIST_HEAD(&nd->queue); |
d50235b7b elevator: Fix a r... |
73 74 75 76 |
spin_lock_irq(q->queue_lock); q->elevator = eq; spin_unlock_irq(q->queue_lock); |
b2fab5acd elevator: make el... |
77 |
return 0; |
1da177e4c Linux-2.6.12-rc2 |
78 |
} |
b374d18a4 block: get rid of... |
79 |
static void noop_exit_queue(struct elevator_queue *e) |
5a7c47eef [BLOCK] noop-iosc... |
80 81 82 83 84 85 |
{ struct noop_data *nd = e->elevator_data; BUG_ON(!list_empty(&nd->queue)); kfree(nd); } |
1da177e4c Linux-2.6.12-rc2 |
86 |
static struct elevator_type elevator_noop = { |
c51ca6cf5 block: move exist... |
87 |
.ops.sq = { |
5a7c47eef [BLOCK] noop-iosc... |
88 89 90 |
.elevator_merge_req_fn = noop_merged_requests, .elevator_dispatch_fn = noop_dispatch, .elevator_add_req_fn = noop_add_request, |
5a7c47eef [BLOCK] noop-iosc... |
91 92 93 94 |
.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, |
1da177e4c Linux-2.6.12-rc2 |
95 96 97 98 99 100 101 |
}, .elevator_name = "noop", .elevator_owner = THIS_MODULE, }; static int __init noop_init(void) { |
3d3c2379f block, cfq: move ... |
102 |
return elv_register(&elevator_noop); |
1da177e4c Linux-2.6.12-rc2 |
103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
} 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"); |