aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/noop-iosched.c
blob: bc2252b6f2e5fdf553465ed8c269aef70de4c60d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
 * elevator noop
 */
#include <linux/blkdev.h>
#include <linux/elevator.h>
#include <linux/bio.h>
#include <linux/module.h>
#include <linux/init.h>

/*
 * See if we can find a request that this buffer can be coalesced with.
 */
static int elevator_noop_merge(request_queue_t *q, struct request **req,
			       struct bio *bio)
{
	int ret;

	ret = elv_try_last_merge(q, bio);
	if (ret != ELEVATOR_NO_MERGE)
		*req = q->last_merge;

	return ret;
}

static void elevator_noop_merge_requests(request_queue_t *q, struct request *req,
					 struct request *next)
{
	list_del_init(&next->queuelist);
}

static void elevator_noop_add_request(request_queue_t *q, struct request *rq)
{
	elv_dispatch_add_tail(q, rq);

	/*
	 * new merges must not precede this barrier
	 */
	if (rq->flags & REQ_HARDBARRIER)
		q->last_merge = NULL;
	else if (!q->last_merge)
		q->last_merge = rq;
}

static int elevator_noop_dispatch(request_queue_t *q, int force)
{
	return 0;
}

static struct elevator_type elevator_noop = {
	.ops = {
		.elevator_merge_fn		= elevator_noop_merge,
		.elevator_merge_req_fn		= elevator_noop_merge_requests,
		.elevator_dispatch_fn		= elevator_noop_dispatch,
		.elevator_add_req_fn		= elevator_noop_add_request,
	},
	.elevator_name = "noop",
	.elevator_owner = THIS_MODULE,
};

static int __init noop_init(void)
{
	return elv_register(&elevator_noop);
}

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");