Lines Matching refs:lprops
30 static int get_heap_comp_val(struct ubifs_lprops *lprops, int cat) in get_heap_comp_val() argument
34 return lprops->free; in get_heap_comp_val()
36 return lprops->free + lprops->dirty; in get_heap_comp_val()
38 return lprops->dirty; in get_heap_comp_val()
55 struct ubifs_lprops *lprops, int cat) in move_up_lpt_heap() argument
59 hpos = lprops->hpos; in move_up_lpt_heap()
62 val1 = get_heap_comp_val(lprops, cat); in move_up_lpt_heap()
73 heap->arr[ppos] = lprops; in move_up_lpt_heap()
74 lprops->hpos = ppos; in move_up_lpt_heap()
92 struct ubifs_lprops *lprops, int hpos, int cat) in adjust_lpt_heap() argument
96 val1 = get_heap_comp_val(lprops, cat); in adjust_lpt_heap()
107 heap->arr[ppos] = lprops; in adjust_lpt_heap()
108 lprops->hpos = ppos; in adjust_lpt_heap()
138 heap->arr[cpos] = lprops; in adjust_lpt_heap()
139 lprops->hpos = cpos; in adjust_lpt_heap()
152 heap->arr[cpos] = lprops; in adjust_lpt_heap()
153 lprops->hpos = cpos; in adjust_lpt_heap()
170 static int add_to_lpt_heap(struct ubifs_info *c, struct ubifs_lprops *lprops, in add_to_lpt_heap() argument
181 cpos = (((size_t)lprops >> 4) & b) + b; in add_to_lpt_heap()
186 val1 = get_heap_comp_val(lprops, cat); in add_to_lpt_heap()
195 lprops->hpos = cpos; in add_to_lpt_heap()
196 heap->arr[cpos] = lprops; in add_to_lpt_heap()
197 move_up_lpt_heap(c, heap, lprops, cat); in add_to_lpt_heap()
198 dbg_check_heap(c, heap, cat, lprops->hpos); in add_to_lpt_heap()
204 lprops->hpos = heap->cnt++; in add_to_lpt_heap()
205 heap->arr[lprops->hpos] = lprops; in add_to_lpt_heap()
206 move_up_lpt_heap(c, heap, lprops, cat); in add_to_lpt_heap()
207 dbg_check_heap(c, heap, cat, lprops->hpos); in add_to_lpt_heap()
219 struct ubifs_lprops *lprops, int cat) in remove_from_lpt_heap() argument
222 int hpos = lprops->hpos; in remove_from_lpt_heap()
226 ubifs_assert(heap->arr[hpos] == lprops); in remove_from_lpt_heap()
267 void ubifs_add_to_cat(struct ubifs_info *c, struct ubifs_lprops *lprops, in ubifs_add_to_cat() argument
274 if (add_to_lpt_heap(c, lprops, cat)) in ubifs_add_to_cat()
280 list_add(&lprops->list, &c->uncat_list); in ubifs_add_to_cat()
283 list_add(&lprops->list, &c->empty_list); in ubifs_add_to_cat()
286 list_add(&lprops->list, &c->freeable_list); in ubifs_add_to_cat()
290 list_add(&lprops->list, &c->frdi_idx_list); in ubifs_add_to_cat()
296 lprops->flags &= ~LPROPS_CAT_MASK; in ubifs_add_to_cat()
297 lprops->flags |= cat; in ubifs_add_to_cat()
311 struct ubifs_lprops *lprops, int cat) in ubifs_remove_from_cat() argument
317 remove_from_lpt_heap(c, lprops, cat); in ubifs_remove_from_cat()
326 ubifs_assert(!list_empty(&lprops->list)); in ubifs_remove_from_cat()
327 list_del(&lprops->list); in ubifs_remove_from_cat()
379 void ubifs_ensure_cat(struct ubifs_info *c, struct ubifs_lprops *lprops) in ubifs_ensure_cat() argument
381 int cat = lprops->flags & LPROPS_CAT_MASK; in ubifs_ensure_cat()
385 cat = ubifs_categorize_lprops(c, lprops); in ubifs_ensure_cat()
388 ubifs_remove_from_cat(c, lprops, LPROPS_UNCAT); in ubifs_ensure_cat()
389 ubifs_add_to_cat(c, lprops, cat); in ubifs_ensure_cat()
403 const struct ubifs_lprops *lprops) in ubifs_categorize_lprops() argument
405 if (lprops->flags & LPROPS_TAKEN) in ubifs_categorize_lprops()
408 if (lprops->free == c->leb_size) { in ubifs_categorize_lprops()
409 ubifs_assert(!(lprops->flags & LPROPS_INDEX)); in ubifs_categorize_lprops()
413 if (lprops->free + lprops->dirty == c->leb_size) { in ubifs_categorize_lprops()
414 if (lprops->flags & LPROPS_INDEX) in ubifs_categorize_lprops()
420 if (lprops->flags & LPROPS_INDEX) { in ubifs_categorize_lprops()
421 if (lprops->dirty + lprops->free >= c->min_idx_node_sz) in ubifs_categorize_lprops()
424 if (lprops->dirty >= c->dead_wm && in ubifs_categorize_lprops()
425 lprops->dirty > lprops->free) in ubifs_categorize_lprops()
427 if (lprops->free > 0) in ubifs_categorize_lprops()
442 static void change_category(struct ubifs_info *c, struct ubifs_lprops *lprops) in change_category() argument
444 int old_cat = lprops->flags & LPROPS_CAT_MASK; in change_category()
445 int new_cat = ubifs_categorize_lprops(c, lprops); in change_category()
454 adjust_lpt_heap(c, heap, lprops, lprops->hpos, new_cat); in change_category()
456 ubifs_remove_from_cat(c, lprops, old_cat); in change_category()
457 ubifs_add_to_cat(c, lprops, new_cat); in change_category()
496 static int is_lprops_dirty(struct ubifs_info *c, struct ubifs_lprops *lprops) in is_lprops_dirty() argument
501 pos = (lprops->lnum - c->main_first) & (UBIFS_LPT_FANOUT - 1); in is_lprops_dirty()
502 pnode = (struct ubifs_pnode *)container_of(lprops - pos, in is_lprops_dirty()
504 lprops[0]); in is_lprops_dirty()
535 struct ubifs_lprops *lprops = (struct ubifs_lprops *)lp; in ubifs_change_lp() local
538 lprops->lnum, free, dirty, flags); in ubifs_change_lp()
553 if (!is_lprops_dirty(c, lprops)) { in ubifs_change_lp()
554 lprops = ubifs_lpt_lookup_dirty(c, lprops->lnum); in ubifs_change_lp()
555 if (IS_ERR(lprops)) in ubifs_change_lp()
556 return lprops; in ubifs_change_lp()
558 ubifs_assert(lprops == ubifs_lpt_lookup_dirty(c, lprops->lnum)); in ubifs_change_lp()
560 ubifs_assert(!(lprops->free & 7) && !(lprops->dirty & 7)); in ubifs_change_lp()
563 if ((lprops->flags & LPROPS_TAKEN) && lprops->free == c->leb_size) in ubifs_change_lp()
566 if (!(lprops->flags & LPROPS_INDEX)) { in ubifs_change_lp()
569 old_spc = lprops->free + lprops->dirty; in ubifs_change_lp()
580 c->lst.total_free += free - lprops->free; in ubifs_change_lp()
584 if (lprops->free != c->leb_size) in ubifs_change_lp()
586 } else if (lprops->free == c->leb_size) in ubifs_change_lp()
588 lprops->free = free; in ubifs_change_lp()
593 c->lst.total_dirty += dirty - lprops->dirty; in ubifs_change_lp()
594 lprops->dirty = dirty; in ubifs_change_lp()
599 if ((lprops->flags & LPROPS_INDEX)) { in ubifs_change_lp()
604 lprops->flags = flags; in ubifs_change_lp()
607 if (!(lprops->flags & LPROPS_INDEX)) { in ubifs_change_lp()
610 new_spc = lprops->free + lprops->dirty; in ubifs_change_lp()
619 if ((lprops->flags & LPROPS_TAKEN) && lprops->free == c->leb_size) in ubifs_change_lp()
622 change_category(c, lprops); in ubifs_change_lp()
625 return lprops; in ubifs_change_lp()
762 struct ubifs_lprops *lprops; in ubifs_fast_find_free() local
771 lprops = heap->arr[0]; in ubifs_fast_find_free()
772 ubifs_assert(!(lprops->flags & LPROPS_TAKEN)); in ubifs_fast_find_free()
773 ubifs_assert(!(lprops->flags & LPROPS_INDEX)); in ubifs_fast_find_free()
774 return lprops; in ubifs_fast_find_free()
786 struct ubifs_lprops *lprops; in ubifs_fast_find_empty() local
793 lprops = list_entry(c->empty_list.next, struct ubifs_lprops, list); in ubifs_fast_find_empty()
794 ubifs_assert(!(lprops->flags & LPROPS_TAKEN)); in ubifs_fast_find_empty()
795 ubifs_assert(!(lprops->flags & LPROPS_INDEX)); in ubifs_fast_find_empty()
796 ubifs_assert(lprops->free == c->leb_size); in ubifs_fast_find_empty()
797 return lprops; in ubifs_fast_find_empty()
809 struct ubifs_lprops *lprops; in ubifs_fast_find_freeable() local
816 lprops = list_entry(c->freeable_list.next, struct ubifs_lprops, list); in ubifs_fast_find_freeable()
817 ubifs_assert(!(lprops->flags & LPROPS_TAKEN)); in ubifs_fast_find_freeable()
818 ubifs_assert(!(lprops->flags & LPROPS_INDEX)); in ubifs_fast_find_freeable()
819 ubifs_assert(lprops->free + lprops->dirty == c->leb_size); in ubifs_fast_find_freeable()
821 return lprops; in ubifs_fast_find_freeable()
833 struct ubifs_lprops *lprops; in ubifs_fast_find_frdi_idx() local
840 lprops = list_entry(c->frdi_idx_list.next, struct ubifs_lprops, list); in ubifs_fast_find_frdi_idx()
841 ubifs_assert(!(lprops->flags & LPROPS_TAKEN)); in ubifs_fast_find_frdi_idx()
842 ubifs_assert((lprops->flags & LPROPS_INDEX)); in ubifs_fast_find_frdi_idx()
843 ubifs_assert(lprops->free + lprops->dirty == c->leb_size); in ubifs_fast_find_frdi_idx()
844 return lprops; in ubifs_fast_find_frdi_idx()
859 struct ubifs_lprops *lprops; in dbg_check_cats() local
866 list_for_each_entry(lprops, &c->empty_list, list) { in dbg_check_cats()
867 if (lprops->free != c->leb_size) { in dbg_check_cats()
869 lprops->lnum, lprops->free, lprops->dirty, in dbg_check_cats()
870 lprops->flags); in dbg_check_cats()
873 if (lprops->flags & LPROPS_TAKEN) { in dbg_check_cats()
875 lprops->lnum, lprops->free, lprops->dirty, in dbg_check_cats()
876 lprops->flags); in dbg_check_cats()
882 list_for_each_entry(lprops, &c->freeable_list, list) { in dbg_check_cats()
883 if (lprops->free + lprops->dirty != c->leb_size) { in dbg_check_cats()
885 lprops->lnum, lprops->free, lprops->dirty, in dbg_check_cats()
886 lprops->flags); in dbg_check_cats()
889 if (lprops->flags & LPROPS_TAKEN) { in dbg_check_cats()
891 lprops->lnum, lprops->free, lprops->dirty, in dbg_check_cats()
892 lprops->flags); in dbg_check_cats()
912 list_for_each_entry(lprops, &c->frdi_idx_list, list) { in dbg_check_cats()
913 if (lprops->free + lprops->dirty != c->leb_size) { 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_TAKEN) { in dbg_check_cats()
921 lprops->lnum, lprops->free, lprops->dirty, in dbg_check_cats()
922 lprops->flags); in dbg_check_cats()
925 if (!(lprops->flags & LPROPS_INDEX)) { in dbg_check_cats()
927 lprops->lnum, lprops->free, lprops->dirty, in dbg_check_cats()
928 lprops->flags); in dbg_check_cats()
937 lprops = heap->arr[i]; in dbg_check_cats()
938 if (!lprops) { in dbg_check_cats()
942 if (lprops->hpos != i) { in dbg_check_cats()
946 if (lprops->flags & LPROPS_TAKEN) { in dbg_check_cats()
965 struct ubifs_lprops *lprops = heap->arr[i]; in dbg_check_heap() local
969 if ((lprops->flags & LPROPS_CAT_MASK) != cat) { in dbg_check_heap()
973 if (lprops->hpos != i) { in dbg_check_heap()
977 lp = ubifs_lpt_lookup(c, lprops->lnum); in dbg_check_heap()
982 if (lprops != lp) { in dbg_check_heap()
984 (size_t)lprops, (size_t)lp, lprops->lnum, in dbg_check_heap()
991 if (lp == lprops) { in dbg_check_heap()
995 if (lp->lnum == lprops->lnum) { in dbg_check_heap()
1059 struct ubifs_lprops *lprops; in scan_check_cb() local
1062 list_for_each_entry(lprops, list, list) { in scan_check_cb()
1063 if (lprops == lp) { in scan_check_cb()