aboutsummaryrefslogtreecommitdiffstats
path: root/block/cfq-iosched.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@suse.de>2006-06-21 03:36:18 -0400
committerJens Axboe <axboe@nelson.home.kernel.dk>2006-06-23 11:10:39 -0400
commitdd67d051529387f6e44d22d1d5540ef281965fdd (patch)
tree80457f9a2ad3e562b179e40f5c8d51b4f24d6d9e /block/cfq-iosched.c
parent9e94cd4fd1812bab45237f998b3c6fa1b24023fd (diff)
[PATCH] rbtree: support functions used by the io schedulers
They all duplicate macros to check for empty root and/or node, and clearing a node. So put those in rbtree.h. Signed-off-by: Jens Axboe <axboe@suse.de>
Diffstat (limited to 'block/cfq-iosched.c')
-rw-r--r--block/cfq-iosched.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index 940364edf2b9..e25223e147a2 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -60,11 +60,6 @@ static DEFINE_SPINLOCK(cfq_exit_lock);
60/* 60/*
61 * rb-tree defines 61 * rb-tree defines
62 */ 62 */
63#define RB_EMPTY(node) ((node)->rb_node == NULL)
64#define RB_CLEAR(node) do { \
65 memset(node, 0, sizeof(*node)); \
66} while (0)
67#define RB_CLEAR_ROOT(root) ((root)->rb_node = NULL)
68#define rb_entry_crq(node) rb_entry((node), struct cfq_rq, rb_node) 63#define rb_entry_crq(node) rb_entry((node), struct cfq_rq, rb_node)
69#define rq_rb_key(rq) (rq)->sector 64#define rq_rb_key(rq) (rq)->sector
70 65
@@ -559,7 +554,7 @@ static inline void cfq_del_crq_rb(struct cfq_rq *crq)
559 554
560 rb_erase(&crq->rb_node, &cfqq->sort_list); 555 rb_erase(&crq->rb_node, &cfqq->sort_list);
561 556
562 if (cfq_cfqq_on_rr(cfqq) && RB_EMPTY(&cfqq->sort_list)) 557 if (cfq_cfqq_on_rr(cfqq) && RB_EMPTY_ROOT(&cfqq->sort_list))
563 cfq_del_cfqq_rr(cfqd, cfqq); 558 cfq_del_cfqq_rr(cfqd, cfqq);
564} 559}
565 560
@@ -914,7 +909,7 @@ static int cfq_arm_slice_timer(struct cfq_data *cfqd, struct cfq_queue *cfqq)
914 struct cfq_io_context *cic; 909 struct cfq_io_context *cic;
915 unsigned long sl; 910 unsigned long sl;
916 911
917 WARN_ON(!RB_EMPTY(&cfqq->sort_list)); 912 WARN_ON(!RB_EMPTY_ROOT(&cfqq->sort_list));
918 WARN_ON(cfqq != cfqd->active_queue); 913 WARN_ON(cfqq != cfqd->active_queue);
919 914
920 /* 915 /*
@@ -1042,7 +1037,7 @@ static struct cfq_queue *cfq_select_queue(struct cfq_data *cfqd)
1042 * if queue has requests, dispatch one. if not, check if 1037 * if queue has requests, dispatch one. if not, check if
1043 * enough slice is left to wait for one 1038 * enough slice is left to wait for one
1044 */ 1039 */
1045 if (!RB_EMPTY(&cfqq->sort_list)) 1040 if (!RB_EMPTY_ROOT(&cfqq->sort_list))
1046 goto keep_queue; 1041 goto keep_queue;
1047 else if (cfq_cfqq_dispatched(cfqq)) { 1042 else if (cfq_cfqq_dispatched(cfqq)) {
1048 cfqq = NULL; 1043 cfqq = NULL;
@@ -1066,7 +1061,7 @@ __cfq_dispatch_requests(struct cfq_data *cfqd, struct cfq_queue *cfqq,
1066{ 1061{
1067 int dispatched = 0; 1062 int dispatched = 0;
1068 1063
1069 BUG_ON(RB_EMPTY(&cfqq->sort_list)); 1064 BUG_ON(RB_EMPTY_ROOT(&cfqq->sort_list));
1070 1065
1071 do { 1066 do {
1072 struct cfq_rq *crq; 1067 struct cfq_rq *crq;
@@ -1090,7 +1085,7 @@ __cfq_dispatch_requests(struct cfq_data *cfqd, struct cfq_queue *cfqq,
1090 cfqd->active_cic = crq->io_context; 1085 cfqd->active_cic = crq->io_context;
1091 } 1086 }
1092 1087
1093 if (RB_EMPTY(&cfqq->sort_list)) 1088 if (RB_EMPTY_ROOT(&cfqq->sort_list))
1094 break; 1089 break;
1095 1090
1096 } while (dispatched < max_dispatch); 1091 } while (dispatched < max_dispatch);
@@ -1480,7 +1475,6 @@ retry:
1480 1475
1481 INIT_HLIST_NODE(&cfqq->cfq_hash); 1476 INIT_HLIST_NODE(&cfqq->cfq_hash);
1482 INIT_LIST_HEAD(&cfqq->cfq_list); 1477 INIT_LIST_HEAD(&cfqq->cfq_list);
1483 RB_CLEAR_ROOT(&cfqq->sort_list);
1484 INIT_LIST_HEAD(&cfqq->fifo); 1478 INIT_LIST_HEAD(&cfqq->fifo);
1485 1479
1486 cfqq->key = key; 1480 cfqq->key = key;
@@ -1873,7 +1867,7 @@ static void cfq_completed_request(request_queue_t *q, struct request *rq)
1873 if (cfqd->active_queue == cfqq) { 1867 if (cfqd->active_queue == cfqq) {
1874 if (time_after(now, cfqq->slice_end)) 1868 if (time_after(now, cfqq->slice_end))
1875 cfq_slice_expired(cfqd, 0); 1869 cfq_slice_expired(cfqd, 0);
1876 else if (sync && RB_EMPTY(&cfqq->sort_list)) { 1870 else if (sync && RB_EMPTY_ROOT(&cfqq->sort_list)) {
1877 if (!cfq_arm_slice_timer(cfqd, cfqq)) 1871 if (!cfq_arm_slice_timer(cfqd, cfqq))
1878 cfq_schedule_dispatch(cfqd); 1872 cfq_schedule_dispatch(cfqd);
1879 } 1873 }
@@ -2059,7 +2053,7 @@ cfq_set_request(request_queue_t *q, struct request *rq, struct bio *bio,
2059 2053
2060 crq = mempool_alloc(cfqd->crq_pool, gfp_mask); 2054 crq = mempool_alloc(cfqd->crq_pool, gfp_mask);
2061 if (crq) { 2055 if (crq) {
2062 RB_CLEAR(&crq->rb_node); 2056 RB_CLEAR_NODE(&crq->rb_node);
2063 crq->rb_key = 0; 2057 crq->rb_key = 0;
2064 crq->request = rq; 2058 crq->request = rq;
2065 INIT_HLIST_NODE(&crq->hash); 2059 INIT_HLIST_NODE(&crq->hash);
@@ -2151,7 +2145,7 @@ static void cfq_idle_slice_timer(unsigned long data)
2151 /* 2145 /*
2152 * not expired and it has a request pending, let it dispatch 2146 * not expired and it has a request pending, let it dispatch
2153 */ 2147 */
2154 if (!RB_EMPTY(&cfqq->sort_list)) { 2148 if (!RB_EMPTY_ROOT(&cfqq->sort_list)) {
2155 cfq_mark_cfqq_must_dispatch(cfqq); 2149 cfq_mark_cfqq_must_dispatch(cfqq);
2156 goto out_kick; 2150 goto out_kick;
2157 } 2151 }