2005-04-17 02:20:36 +04:00
|
|
|
#ifndef _LINUX_ELEVATOR_H
|
|
|
|
#define _LINUX_ELEVATOR_H
|
|
|
|
|
|
|
|
typedef int (elevator_merge_fn) (request_queue_t *, struct request **,
|
|
|
|
struct bio *);
|
|
|
|
|
|
|
|
typedef void (elevator_merge_req_fn) (request_queue_t *, struct request *, struct request *);
|
|
|
|
|
2006-07-13 13:55:04 +04:00
|
|
|
typedef void (elevator_merged_fn) (request_queue_t *, struct request *, int);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2005-10-20 18:23:44 +04:00
|
|
|
typedef int (elevator_dispatch_fn) (request_queue_t *, int);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2005-10-20 18:23:44 +04:00
|
|
|
typedef void (elevator_add_req_fn) (request_queue_t *, struct request *);
|
2005-04-17 02:20:36 +04:00
|
|
|
typedef int (elevator_queue_empty_fn) (request_queue_t *);
|
|
|
|
typedef struct request *(elevator_request_list_fn) (request_queue_t *, struct request *);
|
|
|
|
typedef void (elevator_completed_req_fn) (request_queue_t *, struct request *);
|
2005-06-27 12:55:12 +04:00
|
|
|
typedef int (elevator_may_queue_fn) (request_queue_t *, int, struct bio *);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2005-10-21 11:20:53 +04:00
|
|
|
typedef int (elevator_set_req_fn) (request_queue_t *, struct request *, struct bio *, gfp_t);
|
2005-04-17 02:20:36 +04:00
|
|
|
typedef void (elevator_put_req_fn) (request_queue_t *, struct request *);
|
2005-10-20 18:23:44 +04:00
|
|
|
typedef void (elevator_activate_req_fn) (request_queue_t *, struct request *);
|
2005-04-17 02:20:36 +04:00
|
|
|
typedef void (elevator_deactivate_req_fn) (request_queue_t *, struct request *);
|
|
|
|
|
2006-06-08 10:49:06 +04:00
|
|
|
typedef void *(elevator_init_fn) (request_queue_t *, elevator_t *);
|
2005-04-17 02:20:36 +04:00
|
|
|
typedef void (elevator_exit_fn) (elevator_t *);
|
|
|
|
|
|
|
|
struct elevator_ops
|
|
|
|
{
|
|
|
|
elevator_merge_fn *elevator_merge_fn;
|
|
|
|
elevator_merged_fn *elevator_merged_fn;
|
|
|
|
elevator_merge_req_fn *elevator_merge_req_fn;
|
|
|
|
|
2005-10-20 18:23:44 +04:00
|
|
|
elevator_dispatch_fn *elevator_dispatch_fn;
|
2005-04-17 02:20:36 +04:00
|
|
|
elevator_add_req_fn *elevator_add_req_fn;
|
2005-10-20 18:23:44 +04:00
|
|
|
elevator_activate_req_fn *elevator_activate_req_fn;
|
2005-04-17 02:20:36 +04:00
|
|
|
elevator_deactivate_req_fn *elevator_deactivate_req_fn;
|
|
|
|
|
|
|
|
elevator_queue_empty_fn *elevator_queue_empty_fn;
|
|
|
|
elevator_completed_req_fn *elevator_completed_req_fn;
|
|
|
|
|
|
|
|
elevator_request_list_fn *elevator_former_req_fn;
|
|
|
|
elevator_request_list_fn *elevator_latter_req_fn;
|
|
|
|
|
|
|
|
elevator_set_req_fn *elevator_set_req_fn;
|
|
|
|
elevator_put_req_fn *elevator_put_req_fn;
|
|
|
|
|
|
|
|
elevator_may_queue_fn *elevator_may_queue_fn;
|
|
|
|
|
|
|
|
elevator_init_fn *elevator_init_fn;
|
|
|
|
elevator_exit_fn *elevator_exit_fn;
|
2006-03-18 21:21:20 +03:00
|
|
|
void (*trim)(struct io_context *);
|
2005-04-17 02:20:36 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#define ELV_NAME_MAX (16)
|
|
|
|
|
2006-03-19 06:27:18 +03:00
|
|
|
struct elv_fs_entry {
|
|
|
|
struct attribute attr;
|
|
|
|
ssize_t (*show)(elevator_t *, char *);
|
|
|
|
ssize_t (*store)(elevator_t *, const char *, size_t);
|
|
|
|
};
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* identifies an elevator type, such as AS or deadline
|
|
|
|
*/
|
|
|
|
struct elevator_type
|
|
|
|
{
|
|
|
|
struct list_head list;
|
|
|
|
struct elevator_ops ops;
|
|
|
|
struct elevator_type *elevator_type;
|
2006-03-19 06:27:18 +03:00
|
|
|
struct elv_fs_entry *elevator_attrs;
|
2005-04-17 02:20:36 +04:00
|
|
|
char elevator_name[ELV_NAME_MAX];
|
|
|
|
struct module *elevator_owner;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
2006-01-10 02:09:36 +03:00
|
|
|
* each queue has an elevator_queue associated with it
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
|
|
|
struct elevator_queue
|
|
|
|
{
|
|
|
|
struct elevator_ops *ops;
|
|
|
|
void *elevator_data;
|
|
|
|
struct kobject kobj;
|
|
|
|
struct elevator_type *elevator_type;
|
2006-03-19 02:35:43 +03:00
|
|
|
struct mutex sysfs_lock;
|
2006-07-28 11:23:08 +04:00
|
|
|
struct hlist_head *hash;
|
2005-04-17 02:20:36 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* block elevator interface
|
|
|
|
*/
|
2005-10-20 18:37:00 +04:00
|
|
|
extern void elv_dispatch_sort(request_queue_t *, struct request *);
|
2006-07-28 11:23:08 +04:00
|
|
|
extern void elv_dispatch_add_tail(request_queue_t *, struct request *);
|
2005-04-17 02:20:36 +04:00
|
|
|
extern void elv_add_request(request_queue_t *, struct request *, int, int);
|
|
|
|
extern void __elv_add_request(request_queue_t *, struct request *, int, int);
|
2006-02-08 12:01:31 +03:00
|
|
|
extern void elv_insert(request_queue_t *, struct request *, int);
|
2005-04-17 02:20:36 +04:00
|
|
|
extern int elv_merge(request_queue_t *, struct request **, struct bio *);
|
|
|
|
extern void elv_merge_requests(request_queue_t *, struct request *,
|
|
|
|
struct request *);
|
2006-07-13 13:55:04 +04:00
|
|
|
extern void elv_merged_request(request_queue_t *, struct request *, int);
|
2005-10-20 18:23:44 +04:00
|
|
|
extern void elv_dequeue_request(request_queue_t *, struct request *);
|
2005-04-17 02:20:36 +04:00
|
|
|
extern void elv_requeue_request(request_queue_t *, struct request *);
|
|
|
|
extern int elv_queue_empty(request_queue_t *);
|
|
|
|
extern struct request *elv_next_request(struct request_queue *q);
|
|
|
|
extern struct request *elv_former_request(request_queue_t *, struct request *);
|
|
|
|
extern struct request *elv_latter_request(request_queue_t *, struct request *);
|
|
|
|
extern int elv_register_queue(request_queue_t *q);
|
|
|
|
extern void elv_unregister_queue(request_queue_t *q);
|
2005-06-27 12:55:12 +04:00
|
|
|
extern int elv_may_queue(request_queue_t *, int, struct bio *);
|
2005-04-17 02:20:36 +04:00
|
|
|
extern void elv_completed_request(request_queue_t *, struct request *);
|
2005-10-21 11:20:53 +04:00
|
|
|
extern int elv_set_request(request_queue_t *, struct request *, struct bio *, gfp_t);
|
2005-04-17 02:20:36 +04:00
|
|
|
extern void elv_put_request(request_queue_t *, struct request *);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* io scheduler registration
|
|
|
|
*/
|
|
|
|
extern int elv_register(struct elevator_type *);
|
|
|
|
extern void elv_unregister(struct elevator_type *);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* io scheduler sysfs switching
|
|
|
|
*/
|
|
|
|
extern ssize_t elv_iosched_show(request_queue_t *, char *);
|
|
|
|
extern ssize_t elv_iosched_store(request_queue_t *, const char *, size_t);
|
|
|
|
|
|
|
|
extern int elevator_init(request_queue_t *, char *);
|
|
|
|
extern void elevator_exit(elevator_t *);
|
|
|
|
extern int elv_rq_merge_ok(struct request *, struct bio *);
|
|
|
|
|
2006-07-13 13:55:04 +04:00
|
|
|
/*
|
|
|
|
* Helper functions.
|
|
|
|
*/
|
|
|
|
extern struct request *elv_rb_former_request(request_queue_t *, struct request *);
|
|
|
|
extern struct request *elv_rb_latter_request(request_queue_t *, struct request *);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* rb support functions.
|
|
|
|
*/
|
|
|
|
extern struct request *elv_rb_add(struct rb_root *, struct request *);
|
|
|
|
extern void elv_rb_del(struct rb_root *, struct request *);
|
|
|
|
extern struct request *elv_rb_find(struct rb_root *, sector_t);
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* Return values from elevator merger
|
|
|
|
*/
|
|
|
|
#define ELEVATOR_NO_MERGE 0
|
|
|
|
#define ELEVATOR_FRONT_MERGE 1
|
|
|
|
#define ELEVATOR_BACK_MERGE 2
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Insertion selection
|
|
|
|
*/
|
|
|
|
#define ELEVATOR_INSERT_FRONT 1
|
|
|
|
#define ELEVATOR_INSERT_BACK 2
|
|
|
|
#define ELEVATOR_INSERT_SORT 3
|
2006-01-06 11:51:03 +03:00
|
|
|
#define ELEVATOR_INSERT_REQUEUE 4
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* return values from elevator_may_queue_fn
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
ELV_MQUEUE_MAY,
|
|
|
|
ELV_MQUEUE_NO,
|
|
|
|
ELV_MQUEUE_MUST,
|
|
|
|
};
|
|
|
|
|
2005-10-20 18:37:00 +04:00
|
|
|
#define rq_end_sector(rq) ((rq)->sector + (rq)->nr_sectors)
|
2006-07-13 13:55:04 +04:00
|
|
|
#define rb_entry_rq(node) rb_entry((node), struct request, rb_node)
|
2005-10-20 18:37:00 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
#endif
|