Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _LINUX_ELEVATOR_H |
| 2 | #define _LINUX_ELEVATOR_H |
| 3 | |
| 4 | typedef int (elevator_merge_fn) (request_queue_t *, struct request **, |
| 5 | struct bio *); |
| 6 | |
| 7 | typedef void (elevator_merge_req_fn) (request_queue_t *, struct request *, struct request *); |
| 8 | |
| 9 | typedef void (elevator_merged_fn) (request_queue_t *, struct request *); |
| 10 | |
Tejun Heo | 8922e16 | 2005-10-20 16:23:44 +0200 | [diff] [blame] | 11 | typedef int (elevator_dispatch_fn) (request_queue_t *, int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | |
Tejun Heo | 8922e16 | 2005-10-20 16:23:44 +0200 | [diff] [blame] | 13 | typedef void (elevator_add_req_fn) (request_queue_t *, struct request *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | typedef int (elevator_queue_empty_fn) (request_queue_t *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | typedef struct request *(elevator_request_list_fn) (request_queue_t *, struct request *); |
| 16 | typedef void (elevator_completed_req_fn) (request_queue_t *, struct request *); |
Jens Axboe | 22e2c50 | 2005-06-27 10:55:12 +0200 | [diff] [blame] | 17 | typedef int (elevator_may_queue_fn) (request_queue_t *, int, struct bio *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | |
Al Viro | 8267e26 | 2005-10-21 03:20:53 -0400 | [diff] [blame] | 19 | typedef int (elevator_set_req_fn) (request_queue_t *, struct request *, struct bio *, gfp_t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | typedef void (elevator_put_req_fn) (request_queue_t *, struct request *); |
Tejun Heo | 8922e16 | 2005-10-20 16:23:44 +0200 | [diff] [blame] | 21 | typedef void (elevator_activate_req_fn) (request_queue_t *, struct request *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | typedef void (elevator_deactivate_req_fn) (request_queue_t *, struct request *); |
| 23 | |
| 24 | typedef int (elevator_init_fn) (request_queue_t *, elevator_t *); |
| 25 | typedef void (elevator_exit_fn) (elevator_t *); |
| 26 | |
| 27 | struct elevator_ops |
| 28 | { |
| 29 | elevator_merge_fn *elevator_merge_fn; |
| 30 | elevator_merged_fn *elevator_merged_fn; |
| 31 | elevator_merge_req_fn *elevator_merge_req_fn; |
| 32 | |
Tejun Heo | 8922e16 | 2005-10-20 16:23:44 +0200 | [diff] [blame] | 33 | elevator_dispatch_fn *elevator_dispatch_fn; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | elevator_add_req_fn *elevator_add_req_fn; |
Tejun Heo | 8922e16 | 2005-10-20 16:23:44 +0200 | [diff] [blame] | 35 | elevator_activate_req_fn *elevator_activate_req_fn; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | elevator_deactivate_req_fn *elevator_deactivate_req_fn; |
| 37 | |
| 38 | elevator_queue_empty_fn *elevator_queue_empty_fn; |
| 39 | elevator_completed_req_fn *elevator_completed_req_fn; |
| 40 | |
| 41 | elevator_request_list_fn *elevator_former_req_fn; |
| 42 | elevator_request_list_fn *elevator_latter_req_fn; |
| 43 | |
| 44 | elevator_set_req_fn *elevator_set_req_fn; |
| 45 | elevator_put_req_fn *elevator_put_req_fn; |
| 46 | |
| 47 | elevator_may_queue_fn *elevator_may_queue_fn; |
| 48 | |
| 49 | elevator_init_fn *elevator_init_fn; |
| 50 | elevator_exit_fn *elevator_exit_fn; |
| 51 | }; |
| 52 | |
| 53 | #define ELV_NAME_MAX (16) |
| 54 | |
| 55 | /* |
| 56 | * identifies an elevator type, such as AS or deadline |
| 57 | */ |
| 58 | struct elevator_type |
| 59 | { |
| 60 | struct list_head list; |
| 61 | struct elevator_ops ops; |
| 62 | struct elevator_type *elevator_type; |
| 63 | struct kobj_type *elevator_ktype; |
| 64 | char elevator_name[ELV_NAME_MAX]; |
| 65 | struct module *elevator_owner; |
| 66 | }; |
| 67 | |
| 68 | /* |
| 69 | * each queue has an elevator_queue assoicated with it |
| 70 | */ |
| 71 | struct elevator_queue |
| 72 | { |
| 73 | struct elevator_ops *ops; |
| 74 | void *elevator_data; |
| 75 | struct kobject kobj; |
| 76 | struct elevator_type *elevator_type; |
| 77 | }; |
| 78 | |
| 79 | /* |
| 80 | * block elevator interface |
| 81 | */ |
Jens Axboe | 1b47f53 | 2005-10-20 16:37:00 +0200 | [diff] [blame] | 82 | extern void elv_dispatch_sort(request_queue_t *, struct request *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | extern void elv_add_request(request_queue_t *, struct request *, int, int); |
| 84 | extern void __elv_add_request(request_queue_t *, struct request *, int, int); |
| 85 | extern int elv_merge(request_queue_t *, struct request **, struct bio *); |
| 86 | extern void elv_merge_requests(request_queue_t *, struct request *, |
| 87 | struct request *); |
| 88 | extern void elv_merged_request(request_queue_t *, struct request *); |
Tejun Heo | 8922e16 | 2005-10-20 16:23:44 +0200 | [diff] [blame] | 89 | extern void elv_dequeue_request(request_queue_t *, struct request *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | extern void elv_requeue_request(request_queue_t *, struct request *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | extern int elv_queue_empty(request_queue_t *); |
| 92 | extern struct request *elv_next_request(struct request_queue *q); |
| 93 | extern struct request *elv_former_request(request_queue_t *, struct request *); |
| 94 | extern struct request *elv_latter_request(request_queue_t *, struct request *); |
| 95 | extern int elv_register_queue(request_queue_t *q); |
| 96 | extern void elv_unregister_queue(request_queue_t *q); |
Jens Axboe | 22e2c50 | 2005-06-27 10:55:12 +0200 | [diff] [blame] | 97 | extern int elv_may_queue(request_queue_t *, int, struct bio *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | extern void elv_completed_request(request_queue_t *, struct request *); |
Al Viro | 8267e26 | 2005-10-21 03:20:53 -0400 | [diff] [blame] | 99 | extern int elv_set_request(request_queue_t *, struct request *, struct bio *, gfp_t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | extern void elv_put_request(request_queue_t *, struct request *); |
| 101 | |
| 102 | /* |
| 103 | * io scheduler registration |
| 104 | */ |
| 105 | extern int elv_register(struct elevator_type *); |
| 106 | extern void elv_unregister(struct elevator_type *); |
| 107 | |
| 108 | /* |
| 109 | * io scheduler sysfs switching |
| 110 | */ |
| 111 | extern ssize_t elv_iosched_show(request_queue_t *, char *); |
| 112 | extern ssize_t elv_iosched_store(request_queue_t *, const char *, size_t); |
| 113 | |
| 114 | extern int elevator_init(request_queue_t *, char *); |
| 115 | extern void elevator_exit(elevator_t *); |
| 116 | extern int elv_rq_merge_ok(struct request *, struct bio *); |
| 117 | extern int elv_try_merge(struct request *, struct bio *); |
| 118 | extern int elv_try_last_merge(request_queue_t *, struct bio *); |
| 119 | |
| 120 | /* |
| 121 | * Return values from elevator merger |
| 122 | */ |
| 123 | #define ELEVATOR_NO_MERGE 0 |
| 124 | #define ELEVATOR_FRONT_MERGE 1 |
| 125 | #define ELEVATOR_BACK_MERGE 2 |
| 126 | |
| 127 | /* |
| 128 | * Insertion selection |
| 129 | */ |
| 130 | #define ELEVATOR_INSERT_FRONT 1 |
| 131 | #define ELEVATOR_INSERT_BACK 2 |
| 132 | #define ELEVATOR_INSERT_SORT 3 |
| 133 | |
| 134 | /* |
| 135 | * return values from elevator_may_queue_fn |
| 136 | */ |
| 137 | enum { |
| 138 | ELV_MQUEUE_MAY, |
| 139 | ELV_MQUEUE_NO, |
| 140 | ELV_MQUEUE_MUST, |
| 141 | }; |
| 142 | |
Jens Axboe | 1b47f53 | 2005-10-20 16:37:00 +0200 | [diff] [blame] | 143 | #define rq_end_sector(rq) ((rq)->sector + (rq)->nr_sectors) |
| 144 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | #endif |