Lines Matching defs:lprops

23  * @lprops: LEB properties
26 static int get_heap_comp_val(struct ubifs_lprops *lprops, int cat)
30 return lprops->free;
32 return lprops->free + lprops->dirty;
34 return lprops->dirty;
42 * @lprops: LEB properties to move
51 struct ubifs_lprops *lprops, int cat)
55 hpos = lprops->hpos;
58 val1 = get_heap_comp_val(lprops, cat);
69 heap->arr[ppos] = lprops;
70 lprops->hpos = ppos;
79 * @lprops: LEB properties to move
80 * @hpos: heap position of @lprops
88 struct ubifs_lprops *lprops, int hpos, int cat)
92 val1 = get_heap_comp_val(lprops, cat);
103 heap->arr[ppos] = lprops;
104 lprops->hpos = ppos;
134 heap->arr[cpos] = lprops;
135 lprops->hpos = cpos;
148 heap->arr[cpos] = lprops;
149 lprops->hpos = cpos;
160 * @lprops: LEB properties to add
163 * This function returns %1 if @lprops is added to the heap for LEB category
166 static int add_to_lpt_heap(struct ubifs_info *c, struct ubifs_lprops *lprops,
177 cpos = (((size_t)lprops >> 4) & b) + b;
182 val1 = get_heap_comp_val(lprops, cat);
191 lprops->hpos = cpos;
192 heap->arr[cpos] = lprops;
193 move_up_lpt_heap(c, heap, lprops, cat);
194 dbg_check_heap(c, heap, cat, lprops->hpos);
200 lprops->hpos = heap->cnt++;
201 heap->arr[lprops->hpos] = lprops;
202 move_up_lpt_heap(c, heap, lprops, cat);
203 dbg_check_heap(c, heap, cat, lprops->hpos);
211 * @lprops: LEB properties to remove
215 struct ubifs_lprops *lprops, int cat)
218 int hpos = lprops->hpos;
222 ubifs_assert(c, heap->arr[hpos] == lprops);
233 * lpt_heap_replace - replace lprops in a category heap.
239 * and the lprops that the pnode contains. When that happens, references in
240 * the category heaps to those lprops must be updated to point to the new
241 * lprops. This function does that.
256 * @lprops: LEB properties to add
261 void ubifs_add_to_cat(struct ubifs_info *c, struct ubifs_lprops *lprops,
268 if (add_to_lpt_heap(c, lprops, cat))
274 list_add(&lprops->list, &c->uncat_list);
277 list_add(&lprops->list, &c->empty_list);
280 list_add(&lprops->list, &c->freeable_list);
284 list_add(&lprops->list, &c->frdi_idx_list);
290 lprops->flags &= ~LPROPS_CAT_MASK;
291 lprops->flags |= cat;
299 * @lprops: LEB properties to remove
305 struct ubifs_lprops *lprops, int cat)
311 remove_from_lpt_heap(c, lprops, cat);
320 ubifs_assert(c, !list_empty(&lprops->list));
321 list_del(&lprops->list);
332 * ubifs_replace_cat - replace lprops in a category list or heap.
338 * and the lprops that the pnode contains. When that happens, references in
367 * @lprops: LEB properties
373 void ubifs_ensure_cat(struct ubifs_info *c, struct ubifs_lprops *lprops)
375 int cat = lprops->flags & LPROPS_CAT_MASK;
379 cat = ubifs_categorize_lprops(c, lprops);
382 ubifs_remove_from_cat(c, lprops, LPROPS_UNCAT);
383 ubifs_add_to_cat(c, lprops, cat);
389 * @lprops: LEB properties to categorize
397 const struct ubifs_lprops *lprops)
399 if (lprops->flags & LPROPS_TAKEN)
402 if (lprops->free == c->leb_size) {
403 ubifs_assert(c, !(lprops->flags & LPROPS_INDEX));
407 if (lprops->free + lprops->dirty == c->leb_size) {
408 if (lprops->flags & LPROPS_INDEX)
414 if (lprops->flags & LPROPS_INDEX) {
415 if (lprops->dirty + lprops->free >= c->min_idx_node_sz)
418 if (lprops->dirty >= c->dead_wm &&
419 lprops->dirty > lprops->free)
421 if (lprops->free > 0)
431 * @lprops: LEB properties to re-categorize
436 static void change_category(struct ubifs_info *c, struct ubifs_lprops *lprops)
438 int old_cat = lprops->flags & LPROPS_CAT_MASK;
439 int new_cat = ubifs_categorize_lprops(c, lprops);
444 /* lprops on a heap now must be moved up or down */
448 adjust_lpt_heap(c, heap, lprops, lprops->hpos, new_cat);
450 ubifs_remove_from_cat(c, lprops, old_cat);
451 ubifs_add_to_cat(c, lprops, new_cat);
488 * @lprops: LEB properties to test
490 static int is_lprops_dirty(struct ubifs_info *c, struct ubifs_lprops *lprops)
495 pos = (lprops->lnum - c->main_first) & (UBIFS_LPT_FANOUT - 1);
496 pnode = (struct ubifs_pnode *)container_of(lprops - pos,
498 lprops[0]);
526 * This is the only function that is allowed to change lprops, so we
529 struct ubifs_lprops *lprops = (struct ubifs_lprops *)lp;
532 lprops->lnum, free, dirty, flags);
547 if (!is_lprops_dirty(c, lprops)) {
548 lprops = ubifs_lpt_lookup_dirty(c, lprops->lnum);
549 if (IS_ERR(lprops))
550 return lprops;
552 ubifs_assert(c, lprops == ubifs_lpt_lookup_dirty(c, lprops->lnum));
554 ubifs_assert(c, !(lprops->free & 7) && !(lprops->dirty & 7));
557 if ((lprops->flags & LPROPS_TAKEN) && lprops->free == c->leb_size)
560 if (!(lprops->flags & LPROPS_INDEX)) {
563 old_spc = lprops->free + lprops->dirty;
574 c->lst.total_free += free - lprops->free;
578 if (lprops->free != c->leb_size)
580 } else if (lprops->free == c->leb_size)
582 lprops->free = free;
587 c->lst.total_dirty += dirty - lprops->dirty;
588 lprops->dirty = dirty;
593 if ((lprops->flags & LPROPS_INDEX)) {
598 lprops->flags = flags;
601 if (!(lprops->flags & LPROPS_INDEX)) {
604 new_spc = lprops->free + lprops->dirty;
613 if ((lprops->flags & LPROPS_TAKEN) && lprops->free == c->leb_size)
616 change_category(c, lprops);
619 return lprops;
623 * ubifs_get_lp_stats - get lprops statistics.
645 * 'ubifs_change_lp()' which hides lprops get/release. The arguments are the
756 struct ubifs_lprops *lprops;
765 lprops = heap->arr[0];
766 ubifs_assert(c, !(lprops->flags & LPROPS_TAKEN));
767 ubifs_assert(c, !(lprops->flags & LPROPS_INDEX));
768 return lprops;
780 struct ubifs_lprops *lprops;
787 lprops = list_entry(c->empty_list.next, struct ubifs_lprops, list);
788 ubifs_assert(c, !(lprops->flags & LPROPS_TAKEN));
789 ubifs_assert(c, !(lprops->flags & LPROPS_INDEX));
790 ubifs_assert(c, lprops->free == c->leb_size);
791 return lprops;
803 struct ubifs_lprops *lprops;
810 lprops = list_entry(c->freeable_list.next, struct ubifs_lprops, list);
811 ubifs_assert(c, !(lprops->flags & LPROPS_TAKEN));
812 ubifs_assert(c, !(lprops->flags & LPROPS_INDEX));
813 ubifs_assert(c, lprops->free + lprops->dirty == c->leb_size);
815 return lprops;
827 struct ubifs_lprops *lprops;
834 lprops = list_entry(c->frdi_idx_list.next, struct ubifs_lprops, list);
835 ubifs_assert(c, !(lprops->flags & LPROPS_TAKEN));
836 ubifs_assert(c, (lprops->flags & LPROPS_INDEX));
837 ubifs_assert(c, lprops->free + lprops->dirty == c->leb_size);
838 return lprops;
853 struct ubifs_lprops *lprops;
860 list_for_each_entry(lprops, &c->empty_list, list) {
861 if (lprops->free != c->leb_size) {
863 lprops->lnum, lprops->free, lprops->dirty,
864 lprops->flags);
867 if (lprops->flags & LPROPS_TAKEN) {
869 lprops->lnum, lprops->free, lprops->dirty,
870 lprops->flags);
876 list_for_each_entry(lprops, &c->freeable_list, list) {
877 if (lprops->free + lprops->dirty != c->leb_size) {
879 lprops->lnum, lprops->free, lprops->dirty,
880 lprops->flags);
883 if (lprops->flags & LPROPS_TAKEN) {
885 lprops->lnum, lprops->free, lprops->dirty,
886 lprops->flags);
906 list_for_each_entry(lprops, &c->frdi_idx_list, list) {
907 if (lprops->free + lprops->dirty != c->leb_size) {
909 lprops->lnum, lprops->free, lprops->dirty,
910 lprops->flags);
913 if (lprops->flags & LPROPS_TAKEN) {
915 lprops->lnum, lprops->free, lprops->dirty,
916 lprops->flags);
919 if (!(lprops->flags & LPROPS_INDEX)) {
921 lprops->lnum, lprops->free, lprops->dirty,
922 lprops->flags);
931 lprops = heap->arr[i];
932 if (!lprops) {
936 if (lprops->hpos != i) {
940 if (lprops->flags & LPROPS_TAKEN) {
959 struct ubifs_lprops *lprops = heap->arr[i];
963 if ((lprops->flags & LPROPS_CAT_MASK) != cat) {
967 if (lprops->hpos != i) {
971 lp = ubifs_lpt_lookup(c, lprops->lnum);
976 if (lprops != lp) {
977 ubifs_err(c, "lprops %zx lp %zx lprops->lnum %d lp->lnum %d",
978 (size_t)lprops, (size_t)lp, lprops->lnum,
985 if (lp == lprops) {
989 if (lp->lnum == lprops->lnum) {
1008 * @lst: lprops statistics to update
1053 struct ubifs_lprops *lprops;
1056 list_for_each_entry(lprops, list, list) {
1057 if (lprops == lp) {
1174 * amount of free space than the value recorded by lprops. That
1286 ubifs_err(c, "read from lprops: empty_lebs %d, idx_lebs %d, total_free %lld, total_dirty %lld, total_used %lld",
1298 ubifs_err(c, "read from lprops: total_dead %lld, total_dark %lld",