Patch from Nick Piggin This patch moves a few things around for a bit more clarity. It also merges move_to_dispatch and move_request, keeping the move_to_dispatch name as the previous scheme was a bit confusing. drivers/block/as-iosched.c | 75 ++++++++++++++++----------------------------- 1 files changed, 27 insertions(+), 48 deletions(-) diff -puN drivers/block/as-iosched.c~as-cleanup-2 drivers/block/as-iosched.c --- 25/drivers/block/as-iosched.c~as-cleanup-2 2003-02-25 00:11:28.000000000 -0800 +++ 25-akpm/drivers/block/as-iosched.c 2003-02-25 00:12:02.000000000 -0800 @@ -76,20 +76,6 @@ static unsigned long write_batch_expire */ static unsigned long antic_expire = HZ / 50; -static const int as_hash_shift = 10; -#define AS_HASH_BLOCK(sec) ((sec) >> 3) -#define AS_HASH_FN(sec) (hash_long(AS_HASH_BLOCK((sec)), as_hash_shift)) -#define AS_HASH_ENTRIES (1 << as_hash_shift) -#define rq_hash_key(rq) ((rq)->sector + (rq)->nr_sectors) -#define list_entry_hash(ptr) list_entry((ptr), struct as_rq, hash) -#define ON_HASH(arq) (arq)->hash_valid_count - -#define AS_INVALIDATE_HASH(ad) \ - do { \ - if (!++(ad)->hash_valid_count) \ - (ad)->hash_valid_count = 1; \ - } while (0) - #define ANTIC_OFF 0 /* Not anticipating (normal operation) */ #define ANTIC_WAIT 1 /* Currently anticipating a request */ #define ANTIC_FINISHED 2 /* Anticipating but have found a candidate @@ -159,21 +145,10 @@ struct as_rq { unsigned long expires; }; -static void -as_move_request(struct as_data *ad, struct as_rq *arq); - -/* - * as_update_arq must be called whenever a request (arq) is added to - * the sort_list. This function keeps caches up to date, and checks if the - * request might be one we are "anticipating" - */ -static void -as_update_arq(struct as_data *ad, struct as_rq *arq); +#define RQ_DATA(rq) ((struct as_rq *) (rq)->elevator_private) static kmem_cache_t *arq_pool; -#define RQ_DATA(rq) ((struct as_rq *) (rq)->elevator_private) - static inline unsigned long request_id(void) { return (unsigned long)current->pid; @@ -182,6 +157,20 @@ static inline unsigned long request_id(v /* * the back merge hash support functions */ +static const int as_hash_shift = 10; +#define AS_HASH_BLOCK(sec) ((sec) >> 3) +#define AS_HASH_FN(sec) (hash_long(AS_HASH_BLOCK((sec)), as_hash_shift)) +#define AS_HASH_ENTRIES (1 << as_hash_shift) +#define rq_hash_key(rq) ((rq)->sector + (rq)->nr_sectors) +#define list_entry_hash(ptr) list_entry((ptr), struct as_rq, hash) +#define ON_HASH(arq) (arq)->hash_valid_count + +#define AS_INVALIDATE_HASH(ad) \ + do { \ + if (!++(ad)->hash_valid_count) \ + (ad)->hash_valid_count = 1; \ + } while (0) + static inline void __as_del_arq_hash(struct as_rq *arq) { arq->hash_valid_count = 0; @@ -194,8 +183,7 @@ static inline void as_del_arq_hash(struc __as_del_arq_hash(arq); } -static void -as_add_arq_hash(struct as_data *ad, struct as_rq *arq) +static void as_add_arq_hash(struct as_data *ad, struct as_rq *arq) { struct request *rq = arq->request; @@ -205,8 +193,7 @@ as_add_arq_hash(struct as_data *ad, stru list_add(&arq->hash, &ad->hash[AS_HASH_FN(rq_hash_key(rq))]); } -static struct request * -as_find_arq_hash(struct as_data *ad, sector_t offset) +static struct request *as_find_arq_hash(struct as_data *ad, sector_t offset) { struct list_head *hash_list = &ad->hash[AS_HASH_FN(offset)]; struct list_head *entry, *next = hash_list->next; @@ -248,8 +235,7 @@ as_find_arq_hash(struct as_data *ad, sec * for the specified data_dir. Used to sweep back to the start of the disk * (1-way elevator) after we process the last (highest sector) request. */ -static struct as_rq * -as_find_first_arq(struct as_data *ad, int data_dir) +static struct as_rq *as_find_first_arq(struct as_data *ad, int data_dir) { struct rb_node *n = ad->sort_list[data_dir].rb_node; @@ -264,8 +250,7 @@ as_find_first_arq(struct as_data *ad, in } } -static struct as_rq * -__as_add_arq_rb(struct as_data *ad, struct as_rq *arq) +static struct as_rq *__as_add_arq_rb(struct as_data *ad, struct as_rq *arq) { struct rb_node **p = &ARQ_RB_ROOT(ad, arq)->rb_node; struct rb_node *parent = NULL; @@ -287,6 +272,9 @@ __as_add_arq_rb(struct as_data *ad, stru return 0; } +static void as_move_to_dispatch(struct as_data *ad, struct as_rq *arq); +static void as_update_arq(struct as_data *ad, struct as_rq *arq); + /* * Aad the request to the rb tree if it is unique. If there is an alias (an * existing request against the same sector), which can happen when using @@ -301,7 +289,7 @@ static void as_add_arq_rb(struct as_data arq->rb_key = rq_rb_key(rq); while ((alias = __as_add_arq_rb(ad, arq))) - as_move_request(ad, alias); + as_move_to_dispatch(ad, alias); rb_insert_color(&arq->rb_node, ARQ_RB_ROOT(ad, arq)); as_update_arq(ad, arq); @@ -516,19 +504,9 @@ as_merged_requests(request_queue_t *q, s } /* - * move request from sort list to dispatch queue. - */ -static void as_move_to_dispatch(struct as_data *ad, struct as_rq *arq) -{ - as_remove_request(ad->q, arq->request); - list_add_tail(&arq->request->queuelist, ad->dispatch); -} - - -/* * move an entry to dispatch queue */ -static void as_move_request(struct as_data *ad, struct as_rq *arq) +static void as_move_to_dispatch(struct as_data *ad, struct as_rq *arq) { const int data_dir = rq_data_dir(arq->request); @@ -545,7 +523,8 @@ static void as_move_request(struct as_da * take it off the sort and fifo list, move * to dispatch queue */ - as_move_to_dispatch(ad, arq); + as_remove_request(ad->q, arq->request); + list_add_tail(&arq->request->queuelist, ad->dispatch); } #define list_entry_fifo(ptr) list_entry((ptr), struct as_rq, fifo) @@ -1000,7 +979,7 @@ fifo_expired: * arq is the selected appropriate request. */ ad->antic_status = ANTIC_OFF; - as_move_request(ad, arq); + as_move_to_dispatch(ad, arq); return 1; } _