Lines Matching refs:lprops

28  * @lprops: LEB properties
31 static int get_heap_comp_val(struct ubifs_lprops *lprops, int cat)
35 return lprops->free;
37 return lprops->free + lprops->dirty;
39 return lprops->dirty;
47 * @lprops: LEB properties to move
56 struct ubifs_lprops *lprops, int cat)
60 hpos = lprops->hpos;
63 val1 = get_heap_comp_val(lprops, cat);
74 heap->arr[ppos] = lprops;
75 lprops->hpos = ppos;
84 * @lprops: LEB properties to move
85 * @hpos: heap position of @lprops
93 struct ubifs_lprops *lprops, int hpos, int cat)
97 val1 = get_heap_comp_val(lprops, cat);
108 heap->arr[ppos] = lprops;
109 lprops->hpos = ppos;
139 heap->arr[cpos] = lprops;
140 lprops->hpos = cpos;
153 heap->arr[cpos] = lprops;
154 lprops->hpos = cpos;
165 * @lprops: LEB properties to add
168 * This function returns %1 if @lprops is added to the heap for LEB category
171 static int add_to_lpt_heap(struct ubifs_info *c, struct ubifs_lprops *lprops,
182 cpos = (((size_t)lprops >> 4) & b) + b;
187 val1 = get_heap_comp_val(lprops, cat);
196 lprops->hpos = cpos;
197 heap->arr[cpos] = lprops;
198 move_up_lpt_heap(c, heap, lprops, cat);
199 dbg_check_heap(c, heap, cat, lprops->hpos);
205 lprops->hpos = heap->cnt++;
206 heap->arr[lprops->hpos] = lprops;
207 move_up_lpt_heap(c, heap, lprops, cat);
208 dbg_check_heap(c, heap, cat, lprops->hpos);
216 * @lprops: LEB properties to remove
220 struct ubifs_lprops *lprops, int cat)
223 int hpos = lprops->hpos;
227 ubifs_assert(heap->arr[hpos] == lprops);
238 * lpt_heap_replace - replace lprops in a category heap.
245 * and the lprops that the pnode contains. When that happens, references in
246 * the category heaps to those lprops must be updated to point to the new
247 * lprops. This function does that.
263 * @lprops: LEB properties to add
268 void ubifs_add_to_cat(struct ubifs_info *c, struct ubifs_lprops *lprops,
275 if (add_to_lpt_heap(c, lprops, cat))
281 list_add(&lprops->list, &c->uncat_list);
284 list_add(&lprops->list, &c->empty_list);
287 list_add(&lprops->list, &c->freeable_list);
291 list_add(&lprops->list, &c->frdi_idx_list);
297 lprops->flags &= ~LPROPS_CAT_MASK;
298 lprops->flags |= cat;
306 * @lprops: LEB properties to remove
312 struct ubifs_lprops *lprops, int cat)
318 remove_from_lpt_heap(c, lprops, cat);
327 ubifs_assert(!list_empty(&lprops->list));
328 list_del(&lprops->list);
339 * ubifs_replace_cat - replace lprops in a category list or heap.
345 * and the lprops that the pnode contains. When that happens, references in
374 * @lprops: LEB properties
380 void ubifs_ensure_cat(struct ubifs_info *c, struct ubifs_lprops *lprops)
382 int cat = lprops->flags & LPROPS_CAT_MASK;
386 cat = ubifs_categorize_lprops(c, lprops);
389 ubifs_remove_from_cat(c, lprops, LPROPS_UNCAT);
390 ubifs_add_to_cat(c, lprops, cat);
396 * @lprops: LEB properties to categorize
404 const struct ubifs_lprops *lprops)
406 if (lprops->flags & LPROPS_TAKEN)
409 if (lprops->free == c->leb_size) {
410 ubifs_assert(!(lprops->flags & LPROPS_INDEX));
414 if (lprops->free + lprops->dirty == c->leb_size) {
415 if (lprops->flags & LPROPS_INDEX)
421 if (lprops->flags & LPROPS_INDEX) {
422 if (lprops->dirty + lprops->free >= c->min_idx_node_sz)
425 if (lprops->dirty >= c->dead_wm &&
426 lprops->dirty > lprops->free)
428 if (lprops->free > 0)
438 * @lprops: LEB properties to re-categorize
443 static void change_category(struct ubifs_info *c, struct ubifs_lprops *lprops)
445 int old_cat = lprops->flags & LPROPS_CAT_MASK;
446 int new_cat = ubifs_categorize_lprops(c, lprops);
451 /* lprops on a heap now must be moved up or down */
455 adjust_lpt_heap(c, heap, lprops, lprops->hpos, new_cat);
457 ubifs_remove_from_cat(c, lprops, old_cat);
458 ubifs_add_to_cat(c, lprops, new_cat);
495 * @lprops: LEB properties to test
497 static int is_lprops_dirty(struct ubifs_info *c, struct ubifs_lprops *lprops)
502 pos = (lprops->lnum - c->main_first) & (UBIFS_LPT_FANOUT - 1);
503 pnode = (struct ubifs_pnode *)container_of(lprops - pos,
505 lprops[0]);
533 * This is the only function that is allowed to change lprops, so we
536 struct ubifs_lprops *lprops = (struct ubifs_lprops *)lp;
539 lprops->lnum, free, dirty, flags);
554 if (!is_lprops_dirty(c, lprops)) {
555 lprops = ubifs_lpt_lookup_dirty(c, lprops->lnum);
556 if (IS_ERR(lprops))
557 return lprops;
559 ubifs_assert(lprops == ubifs_lpt_lookup_dirty(c, lprops->lnum));
561 ubifs_assert(!(lprops->free & 7) && !(lprops->dirty & 7));
564 if ((lprops->flags & LPROPS_TAKEN) && lprops->free == c->leb_size)
567 if (!(lprops->flags & LPROPS_INDEX)) {
570 old_spc = lprops->free + lprops->dirty;
581 c->lst.total_free += free - lprops->free;
585 if (lprops->free != c->leb_size)
587 } else if (lprops->free == c->leb_size)
589 lprops->free = free;
594 c->lst.total_dirty += dirty - lprops->dirty;
595 lprops->dirty = dirty;
600 if ((lprops->flags & LPROPS_INDEX)) {
605 lprops->flags = flags;
608 if (!(lprops->flags & LPROPS_INDEX)) {
611 new_spc = lprops->free + lprops->dirty;
620 if ((lprops->flags & LPROPS_TAKEN) && lprops->free == c->leb_size)
623 change_category(c, lprops);
626 return lprops;
630 * ubifs_get_lp_stats - get lprops statistics.
652 * 'ubifs_change_lp()' which hides lprops get/release. The arguments are the
763 struct ubifs_lprops *lprops;
772 lprops = heap->arr[0];
773 ubifs_assert(!(lprops->flags & LPROPS_TAKEN));
774 ubifs_assert(!(lprops->flags & LPROPS_INDEX));
775 return lprops;
787 struct ubifs_lprops *lprops;
794 lprops = list_entry(c->empty_list.next, struct ubifs_lprops, list);
795 ubifs_assert(!(lprops->flags & LPROPS_TAKEN));
796 ubifs_assert(!(lprops->flags & LPROPS_INDEX));
797 ubifs_assert(lprops->free == c->leb_size);
798 return lprops;
810 struct ubifs_lprops *lprops;
817 lprops = list_entry(c->freeable_list.next, struct ubifs_lprops, list);
818 ubifs_assert(!(lprops->flags & LPROPS_TAKEN));
819 ubifs_assert(!(lprops->flags & LPROPS_INDEX));
820 ubifs_assert(lprops->free + lprops->dirty == c->leb_size);
822 return lprops;
834 struct ubifs_lprops *lprops;
841 lprops = list_entry(c->frdi_idx_list.next, struct ubifs_lprops, list);
842 ubifs_assert(!(lprops->flags & LPROPS_TAKEN));
843 ubifs_assert((lprops->flags & LPROPS_INDEX));
844 ubifs_assert(lprops->free + lprops->dirty == c->leb_size);
845 return lprops;
860 struct ubifs_lprops *lprops;
867 list_for_each_entry(lprops, &c->empty_list, list) {
868 if (lprops->free != c->leb_size) {
870 lprops->lnum, lprops->free, lprops->dirty,
871 lprops->flags);
874 if (lprops->flags & LPROPS_TAKEN) {
876 lprops->lnum, lprops->free, lprops->dirty,
877 lprops->flags);
883 list_for_each_entry(lprops, &c->freeable_list, list) {
884 if (lprops->free + lprops->dirty != c->leb_size) {
886 lprops->lnum, lprops->free, lprops->dirty,
887 lprops->flags);
890 if (lprops->flags & LPROPS_TAKEN) {
892 lprops->lnum, lprops->free, lprops->dirty,
893 lprops->flags);
913 list_for_each_entry(lprops, &c->frdi_idx_list, list) {
914 if (lprops->free + lprops->dirty != c->leb_size) {
916 lprops->lnum, lprops->free, lprops->dirty,
917 lprops->flags);
920 if (lprops->flags & LPROPS_TAKEN) {
922 lprops->lnum, lprops->free, lprops->dirty,
923 lprops->flags);
926 if (!(lprops->flags & LPROPS_INDEX)) {
928 lprops->lnum, lprops->free, lprops->dirty,
929 lprops->flags);
938 lprops = heap->arr[i];
939 if (!lprops) {
943 if (lprops->hpos != i) {
947 if (lprops->flags & LPROPS_TAKEN) {
966 struct ubifs_lprops *lprops = heap->arr[i];
970 if ((lprops->flags & LPROPS_CAT_MASK) != cat) {
974 if (lprops->hpos != i) {
978 lp = ubifs_lpt_lookup(c, lprops->lnum);
983 if (lprops != lp) {
984 ubifs_err(c, "lprops %zx lp %zx lprops->lnum %d lp->lnum %d",
985 (size_t)lprops, (size_t)lp, lprops->lnum,
992 if (lp == lprops) {
996 if (lp->lnum == lprops->lnum) {
1015 * @lst: lprops statistics to update
1060 struct ubifs_lprops *lprops;
1063 list_for_each_entry(lprops, list, list) {
1064 if (lprops == lp) {
1181 * amount of free space than the value recorded by lprops. That
1293 ubifs_err(c, "read from lprops: empty_lebs %d, idx_lebs %d, total_free %lld, total_dirty %lld, total_used %lld",
1305 ubifs_err(c, "read from lprops: total_dead %lld, total_dark %lld",