Lines Matching refs:hdr
54 CheckCvscanState(RF_CvscanHeader_t *hdr) in CheckCvscanState() argument
59 if (hdr->left != NULL) in CheckCvscanState()
60 RF_ASSERT(hdr->left->sectorOffset < hdr->cur_block); in CheckCvscanState()
61 for (key = hdr->cur_block, i = 0, tmp = hdr->left; in CheckCvscanState()
65 && tmp->priority == hdr->nxt_priority && pri_ok(tmp->priority)); in CheckCvscanState()
66 RF_ASSERT(i == hdr->left_cnt); in CheckCvscanState()
68 for (key = hdr->cur_block, i = 0, tmp = hdr->right; in CheckCvscanState()
72 RF_ASSERT(tmp->priority == hdr->nxt_priority); in CheckCvscanState()
75 RF_ASSERT(i == hdr->right_cnt); in CheckCvscanState()
77 for (key = hdr->nxt_priority - 1, tmp = hdr->burner; in CheckCvscanState()
81 RF_ASSERT(hdr); in CheckCvscanState()
84 RF_ASSERT(tmp->priority < hdr->nxt_priority); in CheckCvscanState()
137 ReBalance(RF_CvscanHeader_t *hdr) in ReBalance() argument
140 while (hdr->right != NULL in ReBalance()
141 && hdr->right->sectorOffset < hdr->cur_block) { in ReBalance()
142 hdr->right_cnt--; in ReBalance()
143 hdr->left_cnt++; in ReBalance()
144 ReqInsert(&hdr->left, ReqDequeue(&hdr->right), rf_cvscan_LEFT); in ReBalance()
166 RealEnqueue(RF_CvscanHeader_t *hdr, RF_DiskQueueData_t *req) in RealEnqueue() argument
170 DO_CHECK_STATE(hdr); in RealEnqueue()
171 if (hdr->left_cnt == 0 && hdr->right_cnt == 0) { in RealEnqueue()
172 hdr->nxt_priority = req->priority; in RealEnqueue()
174 if (req->priority > hdr->nxt_priority) { in RealEnqueue()
178 Transfer(&hdr->burner, &hdr->left); in RealEnqueue()
179 Transfer(&hdr->burner, &hdr->right); in RealEnqueue()
180 hdr->left_cnt = 0; in RealEnqueue()
181 hdr->right_cnt = 0; in RealEnqueue()
182 hdr->nxt_priority = req->priority; in RealEnqueue()
184 if (req->priority < hdr->nxt_priority) { in RealEnqueue()
188 PriorityInsert(&hdr->burner, req); in RealEnqueue()
190 if (req->sectorOffset < hdr->cur_block) { in RealEnqueue()
192 ReqInsert(&hdr->left, req, rf_cvscan_LEFT); in RealEnqueue()
193 hdr->left_cnt++; in RealEnqueue()
196 ReqInsert(&hdr->right, req, rf_cvscan_RIGHT); in RealEnqueue()
197 hdr->right_cnt++; in RealEnqueue()
200 DO_CHECK_STATE(hdr); in RealEnqueue()
208 RF_CvscanHeader_t *hdr = (RF_CvscanHeader_t *) q_in; in rf_CvscanEnqueue() local
209 RealEnqueue(hdr, elem /* req */ ); in rf_CvscanEnqueue()
217 RF_CvscanHeader_t *hdr = (RF_CvscanHeader_t *) q_in; in rf_CvscanDequeue() local
222 DO_CHECK_STATE(hdr); in rf_CvscanDequeue()
224 if (hdr->left_cnt == 0 && hdr->right_cnt == 0) in rf_CvscanDequeue()
227 range = RF_MIN(hdr->range_for_avg, RF_MIN(hdr->left_cnt, hdr->right_cnt)); in rf_CvscanDequeue()
228 for (i = 0, tmp = hdr->left, sum_dist_left = in rf_CvscanDequeue()
229 ((hdr->direction == rf_cvscan_RIGHT) ? range * hdr->change_penalty : 0); in rf_CvscanDequeue()
232 sum_dist_left += hdr->cur_block - tmp->sectorOffset; in rf_CvscanDequeue()
234 for (i = 0, tmp = hdr->right, sum_dist_right = in rf_CvscanDequeue()
235 ((hdr->direction == rf_cvscan_LEFT) ? range * hdr->change_penalty : 0); in rf_CvscanDequeue()
238 sum_dist_right += tmp->sectorOffset - hdr->cur_block; in rf_CvscanDequeue()
241 if (hdr->right_cnt == 0 || sum_dist_left < sum_dist_right) { in rf_CvscanDequeue()
242 hdr->direction = rf_cvscan_LEFT; in rf_CvscanDequeue()
243 hdr->cur_block = hdr->left->sectorOffset + hdr->left->numSector; in rf_CvscanDequeue()
244 hdr->left_cnt = RF_MAX(hdr->left_cnt - 1, 0); in rf_CvscanDequeue()
245 tmp = hdr->left; in rf_CvscanDequeue()
246 ret = (ReqDequeue(&hdr->left)) /*->parent*/ ; in rf_CvscanDequeue()
248 hdr->direction = rf_cvscan_RIGHT; in rf_CvscanDequeue()
249 hdr->cur_block = hdr->right->sectorOffset + hdr->right->numSector; in rf_CvscanDequeue()
250 hdr->right_cnt = RF_MAX(hdr->right_cnt - 1, 0); in rf_CvscanDequeue()
251 tmp = hdr->right; in rf_CvscanDequeue()
252 ret = (ReqDequeue(&hdr->right)) /*->parent*/ ; in rf_CvscanDequeue()
254 ReBalance(hdr); in rf_CvscanDequeue()
256 if (hdr->left_cnt == 0 && hdr->right_cnt == 0 in rf_CvscanDequeue()
257 && hdr->burner != NULL) { in rf_CvscanDequeue()
261 RF_DiskQueueData_t *burner = hdr->burner; in rf_CvscanDequeue()
262 hdr->nxt_priority = burner->priority; in rf_CvscanDequeue()
264 && burner->priority == hdr->nxt_priority) { in rf_CvscanDequeue()
266 RealEnqueue(hdr, burner); in rf_CvscanDequeue()
269 hdr->burner = burner; in rf_CvscanDequeue()
271 DO_CHECK_STATE(hdr); in rf_CvscanDequeue()
287 RF_CvscanHeader_t *hdr; in rf_CvscanCreate() local
291 hdr = RF_MallocAndAdd(sizeof(*hdr), clList); in rf_CvscanCreate()
292 hdr->range_for_avg = RF_MAX(range, 1); in rf_CvscanCreate()
293 hdr->change_penalty = RF_MAX(penalty, 0); in rf_CvscanCreate()
294 hdr->direction = rf_cvscan_RIGHT; in rf_CvscanCreate()
295 hdr->cur_block = 0; in rf_CvscanCreate()
296 hdr->left_cnt = hdr->right_cnt = 0; in rf_CvscanCreate()
297 hdr->left = hdr->right = NULL; in rf_CvscanCreate()
298 hdr->burner = NULL; in rf_CvscanCreate()
299 DO_CHECK_STATE(hdr); in rf_CvscanCreate()
301 return ((void *) hdr); in rf_CvscanCreate()
309 PrintCvscanQueue(RF_CvscanHeader_t *hdr) in PrintCvscanQueue() argument
314 (int) hdr->range_for_avg, in PrintCvscanQueue()
315 (int) hdr->change_penalty, in PrintCvscanQueue()
316 (int) hdr->cur_block, in PrintCvscanQueue()
317 (hdr->direction == rf_cvscan_LEFT) ? "LEFT" : "RIGHT"); in PrintCvscanQueue()
318 printf("\tLeft(%d): ", hdr->left_cnt); in PrintCvscanQueue()
319 for (tmp = hdr->left; tmp != NULL; tmp = tmp->next) in PrintCvscanQueue()
325 printf("\tRight(%d): ", hdr->right_cnt); in PrintCvscanQueue()
326 for (tmp = hdr->right; tmp != NULL; tmp = tmp->next) in PrintCvscanQueue()
333 for (tmp = hdr->burner; tmp != NULL; tmp = tmp->next) in PrintCvscanQueue()
352 RF_CvscanHeader_t *hdr = (RF_CvscanHeader_t *) q_in; in rf_CvscanPromote() local
353 RF_DiskQueueData_t *trailer = NULL, *tmp = hdr->burner, *tlist = NULL; in rf_CvscanPromote()
356 DO_CHECK_STATE(hdr); in rf_CvscanPromote()
359 hdr->burner = tmp->next; in rf_CvscanPromote()
363 tmp = hdr->burner; in rf_CvscanPromote()
386 RealEnqueue(hdr, tlist); in rf_CvscanPromote()