Lines Matching refs:lprops
26 static int get_heap_comp_val(struct ubifs_lprops *lprops, int cat) in get_heap_comp_val() argument
30 return lprops->free; in get_heap_comp_val()
32 return lprops->free + lprops->dirty; in get_heap_comp_val()
34 return lprops->dirty; in get_heap_comp_val()
51 struct ubifs_lprops *lprops, int cat) in move_up_lpt_heap() argument
55 hpos = lprops->hpos; in move_up_lpt_heap()
58 val1 = get_heap_comp_val(lprops, cat); in move_up_lpt_heap()
69 heap->arr[ppos] = lprops; in move_up_lpt_heap()
70 lprops->hpos = ppos; in move_up_lpt_heap()
88 struct ubifs_lprops *lprops, int hpos, int cat) in adjust_lpt_heap() argument
92 val1 = get_heap_comp_val(lprops, cat); in adjust_lpt_heap()
103 heap->arr[ppos] = lprops; in adjust_lpt_heap()
104 lprops->hpos = ppos; in adjust_lpt_heap()
134 heap->arr[cpos] = lprops; in adjust_lpt_heap()
135 lprops->hpos = cpos; in adjust_lpt_heap()
148 heap->arr[cpos] = lprops; in adjust_lpt_heap()
149 lprops->hpos = cpos; in adjust_lpt_heap()
166 static int add_to_lpt_heap(struct ubifs_info *c, struct ubifs_lprops *lprops, in add_to_lpt_heap() argument
177 cpos = (((size_t)lprops >> 4) & b) + b; in add_to_lpt_heap()
182 val1 = get_heap_comp_val(lprops, cat); in add_to_lpt_heap()
191 lprops->hpos = cpos; in add_to_lpt_heap()
192 heap->arr[cpos] = lprops; in add_to_lpt_heap()
193 move_up_lpt_heap(c, heap, lprops, cat); in add_to_lpt_heap()
194 dbg_check_heap(c, heap, cat, lprops->hpos); in add_to_lpt_heap()
200 lprops->hpos = heap->cnt++; in add_to_lpt_heap()
201 heap->arr[lprops->hpos] = lprops; in add_to_lpt_heap()
202 move_up_lpt_heap(c, heap, lprops, cat); in add_to_lpt_heap()
203 dbg_check_heap(c, heap, cat, lprops->hpos); in add_to_lpt_heap()
215 struct ubifs_lprops *lprops, int cat) in remove_from_lpt_heap() argument
218 int hpos = lprops->hpos; in remove_from_lpt_heap()
222 ubifs_assert(c, heap->arr[hpos] == lprops); in remove_from_lpt_heap()
261 void ubifs_add_to_cat(struct ubifs_info *c, struct ubifs_lprops *lprops, in ubifs_add_to_cat() argument
268 if (add_to_lpt_heap(c, lprops, cat)) in ubifs_add_to_cat()
274 list_add(&lprops->list, &c->uncat_list); in ubifs_add_to_cat()
277 list_add(&lprops->list, &c->empty_list); in ubifs_add_to_cat()
280 list_add(&lprops->list, &c->freeable_list); in ubifs_add_to_cat()
284 list_add(&lprops->list, &c->frdi_idx_list); in ubifs_add_to_cat()
290 lprops->flags &= ~LPROPS_CAT_MASK; in ubifs_add_to_cat()
291 lprops->flags |= cat; in ubifs_add_to_cat()
305 struct ubifs_lprops *lprops, int cat) in ubifs_remove_from_cat() argument
311 remove_from_lpt_heap(c, lprops, cat); in ubifs_remove_from_cat()
320 ubifs_assert(c, !list_empty(&lprops->list)); in ubifs_remove_from_cat()
321 list_del(&lprops->list); in ubifs_remove_from_cat()
373 void ubifs_ensure_cat(struct ubifs_info *c, struct ubifs_lprops *lprops) in ubifs_ensure_cat() argument
375 int cat = lprops->flags & LPROPS_CAT_MASK; in ubifs_ensure_cat()
379 cat = ubifs_categorize_lprops(c, lprops); in ubifs_ensure_cat()
382 ubifs_remove_from_cat(c, lprops, LPROPS_UNCAT); in ubifs_ensure_cat()
383 ubifs_add_to_cat(c, lprops, cat); in ubifs_ensure_cat()
397 const struct ubifs_lprops *lprops) in ubifs_categorize_lprops() argument
399 if (lprops->flags & LPROPS_TAKEN) in ubifs_categorize_lprops()
402 if (lprops->free == c->leb_size) { in ubifs_categorize_lprops()
403 ubifs_assert(c, !(lprops->flags & LPROPS_INDEX)); in ubifs_categorize_lprops()
407 if (lprops->free + lprops->dirty == c->leb_size) { in ubifs_categorize_lprops()
408 if (lprops->flags & LPROPS_INDEX) in ubifs_categorize_lprops()
414 if (lprops->flags & LPROPS_INDEX) { in ubifs_categorize_lprops()
415 if (lprops->dirty + lprops->free >= c->min_idx_node_sz) in ubifs_categorize_lprops()
418 if (lprops->dirty >= c->dead_wm && in ubifs_categorize_lprops()
419 lprops->dirty > lprops->free) in ubifs_categorize_lprops()
421 if (lprops->free > 0) in ubifs_categorize_lprops()
436 static void change_category(struct ubifs_info *c, struct ubifs_lprops *lprops) in change_category() argument
438 int old_cat = lprops->flags & LPROPS_CAT_MASK; in change_category()
439 int new_cat = ubifs_categorize_lprops(c, lprops); in change_category()
448 adjust_lpt_heap(c, heap, lprops, lprops->hpos, new_cat); in change_category()
450 ubifs_remove_from_cat(c, lprops, old_cat); in change_category()
451 ubifs_add_to_cat(c, lprops, new_cat); in change_category()
490 static int is_lprops_dirty(struct ubifs_info *c, struct ubifs_lprops *lprops) in is_lprops_dirty() argument
495 pos = (lprops->lnum - c->main_first) & (UBIFS_LPT_FANOUT - 1); in is_lprops_dirty()
496 pnode = (struct ubifs_pnode *)container_of(lprops - pos, in is_lprops_dirty()
498 lprops[0]); in is_lprops_dirty()
529 struct ubifs_lprops *lprops = (struct ubifs_lprops *)lp; in ubifs_change_lp() local
532 lprops->lnum, free, dirty, flags); in ubifs_change_lp()
547 if (!is_lprops_dirty(c, lprops)) { in ubifs_change_lp()
548 lprops = ubifs_lpt_lookup_dirty(c, lprops->lnum); in ubifs_change_lp()
549 if (IS_ERR(lprops)) in ubifs_change_lp()
550 return lprops; in ubifs_change_lp()
552 ubifs_assert(c, lprops == ubifs_lpt_lookup_dirty(c, lprops->lnum)); in ubifs_change_lp()
554 ubifs_assert(c, !(lprops->free & 7) && !(lprops->dirty & 7)); in ubifs_change_lp()
557 if ((lprops->flags & LPROPS_TAKEN) && lprops->free == c->leb_size) in ubifs_change_lp()
560 if (!(lprops->flags & LPROPS_INDEX)) { in ubifs_change_lp()
563 old_spc = lprops->free + lprops->dirty; in ubifs_change_lp()
574 c->lst.total_free += free - lprops->free; in ubifs_change_lp()
578 if (lprops->free != c->leb_size) in ubifs_change_lp()
580 } else if (lprops->free == c->leb_size) in ubifs_change_lp()
582 lprops->free = free; in ubifs_change_lp()
587 c->lst.total_dirty += dirty - lprops->dirty; in ubifs_change_lp()
588 lprops->dirty = dirty; in ubifs_change_lp()
593 if ((lprops->flags & LPROPS_INDEX)) { in ubifs_change_lp()
598 lprops->flags = flags; in ubifs_change_lp()
601 if (!(lprops->flags & LPROPS_INDEX)) { in ubifs_change_lp()
604 new_spc = lprops->free + lprops->dirty; in ubifs_change_lp()
613 if ((lprops->flags & LPROPS_TAKEN) && lprops->free == c->leb_size) in ubifs_change_lp()
616 change_category(c, lprops); in ubifs_change_lp()
619 return lprops; in ubifs_change_lp()
756 struct ubifs_lprops *lprops; in ubifs_fast_find_free() local
765 lprops = heap->arr[0]; in ubifs_fast_find_free()
766 ubifs_assert(c, !(lprops->flags & LPROPS_TAKEN)); in ubifs_fast_find_free()
767 ubifs_assert(c, !(lprops->flags & LPROPS_INDEX)); in ubifs_fast_find_free()
768 return lprops; in ubifs_fast_find_free()
780 struct ubifs_lprops *lprops; in ubifs_fast_find_empty() local
787 lprops = list_entry(c->empty_list.next, struct ubifs_lprops, list); in ubifs_fast_find_empty()
788 ubifs_assert(c, !(lprops->flags & LPROPS_TAKEN)); in ubifs_fast_find_empty()
789 ubifs_assert(c, !(lprops->flags & LPROPS_INDEX)); in ubifs_fast_find_empty()
790 ubifs_assert(c, lprops->free == c->leb_size); in ubifs_fast_find_empty()
791 return lprops; in ubifs_fast_find_empty()
803 struct ubifs_lprops *lprops; in ubifs_fast_find_freeable() local
810 lprops = list_entry(c->freeable_list.next, struct ubifs_lprops, list); in ubifs_fast_find_freeable()
811 ubifs_assert(c, !(lprops->flags & LPROPS_TAKEN)); in ubifs_fast_find_freeable()
812 ubifs_assert(c, !(lprops->flags & LPROPS_INDEX)); in ubifs_fast_find_freeable()
813 ubifs_assert(c, lprops->free + lprops->dirty == c->leb_size); in ubifs_fast_find_freeable()
815 return lprops; in ubifs_fast_find_freeable()
827 struct ubifs_lprops *lprops; in ubifs_fast_find_frdi_idx() local
834 lprops = list_entry(c->frdi_idx_list.next, struct ubifs_lprops, list); in ubifs_fast_find_frdi_idx()
835 ubifs_assert(c, !(lprops->flags & LPROPS_TAKEN)); in ubifs_fast_find_frdi_idx()
836 ubifs_assert(c, (lprops->flags & LPROPS_INDEX)); in ubifs_fast_find_frdi_idx()
837 ubifs_assert(c, lprops->free + lprops->dirty == c->leb_size); in ubifs_fast_find_frdi_idx()
838 return lprops; in ubifs_fast_find_frdi_idx()
853 struct ubifs_lprops *lprops; in dbg_check_cats() local
860 list_for_each_entry(lprops, &c->empty_list, list) { in dbg_check_cats()
861 if (lprops->free != c->leb_size) { in dbg_check_cats()
863 lprops->lnum, lprops->free, lprops->dirty, in dbg_check_cats()
864 lprops->flags); in dbg_check_cats()
867 if (lprops->flags & LPROPS_TAKEN) { in dbg_check_cats()
869 lprops->lnum, lprops->free, lprops->dirty, in dbg_check_cats()
870 lprops->flags); in dbg_check_cats()
876 list_for_each_entry(lprops, &c->freeable_list, list) { in dbg_check_cats()
877 if (lprops->free + lprops->dirty != c->leb_size) { in dbg_check_cats()
879 lprops->lnum, lprops->free, lprops->dirty, in dbg_check_cats()
880 lprops->flags); in dbg_check_cats()
883 if (lprops->flags & LPROPS_TAKEN) { in dbg_check_cats()
885 lprops->lnum, lprops->free, lprops->dirty, in dbg_check_cats()
886 lprops->flags); in dbg_check_cats()
906 list_for_each_entry(lprops, &c->frdi_idx_list, list) { in dbg_check_cats()
907 if (lprops->free + lprops->dirty != c->leb_size) { in dbg_check_cats()
909 lprops->lnum, lprops->free, lprops->dirty, in dbg_check_cats()
910 lprops->flags); in dbg_check_cats()
913 if (lprops->flags & LPROPS_TAKEN) { in dbg_check_cats()
915 lprops->lnum, lprops->free, lprops->dirty, in dbg_check_cats()
916 lprops->flags); in dbg_check_cats()
919 if (!(lprops->flags & LPROPS_INDEX)) { in dbg_check_cats()
921 lprops->lnum, lprops->free, lprops->dirty, in dbg_check_cats()
922 lprops->flags); in dbg_check_cats()
931 lprops = heap->arr[i]; in dbg_check_cats()
932 if (!lprops) { in dbg_check_cats()
936 if (lprops->hpos != i) { in dbg_check_cats()
940 if (lprops->flags & LPROPS_TAKEN) { in dbg_check_cats()
959 struct ubifs_lprops *lprops = heap->arr[i]; in dbg_check_heap() local
963 if ((lprops->flags & LPROPS_CAT_MASK) != cat) { in dbg_check_heap()
967 if (lprops->hpos != i) { in dbg_check_heap()
971 lp = ubifs_lpt_lookup(c, lprops->lnum); in dbg_check_heap()
976 if (lprops != lp) { in dbg_check_heap()
978 (size_t)lprops, (size_t)lp, lprops->lnum, in dbg_check_heap()
985 if (lp == lprops) { in dbg_check_heap()
989 if (lp->lnum == lprops->lnum) { in dbg_check_heap()
1053 struct ubifs_lprops *lprops; in scan_check_cb() local
1056 list_for_each_entry(lprops, list, list) { in scan_check_cb()
1057 if (lprops == lp) { in scan_check_cb()