Lines Matching refs:cand
182 static struct gc_candidate *add_list(struct gc_candidate *cand, in add_list() argument
190 cand->list = list; in add_list()
196 comp = cand->erase_count < cur->erase_count; in add_list()
198 comp = cand->valid < cur->valid; in add_list()
205 rb_link_node(&cand->rb_node, parent, p); in add_list()
206 rb_insert_color(&cand->rb_node, &list->rb_tree); in add_list()
212 cand = rb_entry(rb_last(&list->rb_tree), struct gc_candidate, rb_node); in add_list()
213 rb_erase(&cand->rb_node, &list->rb_tree); in add_list()
214 cand->list = NULL; in add_list()
215 return cand; in add_list()
218 static void remove_from_list(struct gc_candidate *cand) in remove_from_list() argument
220 struct candidate_list *list = cand->list; in remove_from_list()
222 rb_erase(&cand->rb_node, &list->rb_tree); in remove_from_list()
226 static void free_candidate(struct super_block *sb, struct gc_candidate *cand) in free_candidate() argument
230 btree_remove32(&super->s_cand_tree, cand->segno); in free_candidate()
231 kfree(cand); in free_candidate()
236 struct gc_candidate *cand; in get_best_cand() local
241 cand = rb_entry(rb_first(&list->rb_tree), struct gc_candidate, rb_node); in get_best_cand()
242 remove_from_list(cand); in get_best_cand()
243 segno = cand->segno; in get_best_cand()
245 *ec = cand->erase_count; in get_best_cand()
246 free_candidate(sb, cand); in get_best_cand()
268 static void __add_candidate(struct super_block *sb, struct gc_candidate *cand) in __add_candidate() argument
273 if (cand->valid == 0) { in __add_candidate()
276 cand->segno, cand->erase_count, in __add_candidate()
277 dev_ofs(sb, cand->segno, 0)); in __add_candidate()
278 cand = add_list(cand, &super->s_reserve_list); in __add_candidate()
279 if (cand) { in __add_candidate()
281 cand->segno, cand->erase_count, in __add_candidate()
282 dev_ofs(sb, cand->segno, 0)); in __add_candidate()
283 cand = add_list(cand, &super->s_free_list); in __add_candidate()
287 if (cand->valid < full) in __add_candidate()
288 cand = add_list(cand, &super->s_low_list[cand->dist]); in __add_candidate()
291 if (cand) in __add_candidate()
292 cand = add_list(cand, &super->s_ec_list); in __add_candidate()
294 if (cand) in __add_candidate()
295 free_candidate(sb, cand); in __add_candidate()
302 struct gc_candidate *cand; in add_candidate() local
304 cand = kmalloc(sizeof(*cand), GFP_NOFS); in add_candidate()
305 if (!cand) in add_candidate()
308 cand->segno = segno; in add_candidate()
309 cand->valid = valid; in add_candidate()
310 cand->erase_count = ec; in add_candidate()
311 cand->dist = dist; in add_candidate()
313 btree_insert32(&super->s_cand_tree, segno, cand, GFP_NOFS); in add_candidate()
314 __add_candidate(sb, cand); in add_candidate()
321 struct gc_candidate *cand; in remove_segment_from_lists() local
323 cand = btree_lookup32(&super->s_cand_tree, segno); in remove_segment_from_lists()
324 if (cand) { in remove_segment_from_lists()
325 remove_from_list(cand); in remove_segment_from_lists()
326 free_candidate(sb, cand); in remove_segment_from_lists()
368 struct gc_candidate *cand = NULL, *this; in get_candidate() local
376 if (!cand) in get_candidate()
377 cand = this; in get_candidate()
378 if (this->valid + LOGFS_MAX_OBJECTSIZE <= cand->valid) in get_candidate()
379 cand = this; in get_candidate()
381 return cand; in get_candidate()
384 static int __logfs_gc_once(struct super_block *sb, struct gc_candidate *cand) in __logfs_gc_once() argument
391 if (!cand) { in __logfs_gc_once()
396 segno = cand->segno; in __logfs_gc_once()
397 dist = cand->dist; in __logfs_gc_once()
399 free_candidate(sb, cand); in __logfs_gc_once()
413 struct gc_candidate *cand; in logfs_gc_once() local
415 cand = get_candidate(sb); in logfs_gc_once()
416 if (cand) in logfs_gc_once()
417 remove_from_list(cand); in logfs_gc_once()
418 return __logfs_gc_once(sb, cand); in logfs_gc_once()
581 struct gc_candidate *cand; in logfs_journal_wl_pass() local
597 cand = rb_entry(rb_first(&super->s_free_list.rb_tree), in logfs_journal_wl_pass()
599 max_reserve_ec = cand->erase_count; in logfs_journal_wl_pass()
702 struct gc_candidate *cand; in logfs_cleanup_list() local
705 cand = rb_entry(list->rb_tree.rb_node, struct gc_candidate, in logfs_cleanup_list()
707 remove_from_list(cand); in logfs_cleanup_list()
708 free_candidate(sb, cand); in logfs_cleanup_list()