71 c->
lst.taken_empty_lebs;
105 if (!in_tree && valuable(c, lprops))
137 int min_space,
int pick_free,
147 for (i = 0; i < heap->
cnt; i++) {
148 lprops = heap->
arr[
i];
149 if (lprops->
free + lprops->
dirty < min_space)
165 if (lprops->
free + lprops->
dirty < min_space)
234 int min_space,
int pick_free)
236 int err = 0,
sum, exclude_index = pick_free == 2 ? 1 : 0;
243 int lebs, rsvd_idx_lebs = 0;
255 if (c->
bi.min_idx_lebs >= c->
lst.idx_lebs) {
256 rsvd_idx_lebs = c->
bi.min_idx_lebs - c->
lst.idx_lebs;
262 if (rsvd_idx_lebs < lebs) {
279 exclude_index = (c->
bi.min_idx_lebs >= c->
lst.idx_lebs);
287 if (idx_heap->
cnt && !exclude_index) {
288 idx_lp = idx_heap->
arr[0];
289 sum = idx_lp->free + idx_lp->dirty;
312 if (idx_lp->free + idx_lp->dirty >= lp->
free + lp->
dirty)
314 }
else if (idx_lp && !lp)
323 dbg_find(
"scanning LPT for a dirty LEB");
324 lp = scan_for_dirty(c, min_space, pick_free, exclude_index);
333 dbg_find(
"found LEB %d, free %d, dirty %d, flags %#x",
346 ubifs_release_lprops(c);
362 static int scan_for_free_cb(
struct ubifs_info *c,
372 if (!in_tree && valuable(c, lprops))
408 int min_space,
int pick_free,
418 if (lprops && lprops->
free >= min_space)
428 if (lprops && lprops->
free >= min_space)
433 for (i = 0; i < heap->
cnt; i++) {
434 lprops = heap->
arr[
i];
435 if (lprops->
free >= min_space)
450 if (lprops->
free >= min_space)
497 int lebs, rsvd_idx_lebs, pick_free = 0,
err,
lnum,
flags;
499 dbg_find(
"min_space %d", min_space);
504 if (c->
bi.min_idx_lebs > c->
lst.idx_lebs)
505 rsvd_idx_lebs = c->
bi.min_idx_lebs - c->
lst.idx_lebs;
509 c->
lst.taken_empty_lebs;
510 if (rsvd_idx_lebs < lebs)
515 if (c->
lst.empty_lebs - c->
lst.taken_empty_lebs > 0) {
536 c->
lst.taken_empty_lebs += 1;
540 lprops = do_find_free_space(c, min_space, pick_free, squeeze);
541 if (IS_ERR(lprops)) {
542 err = PTR_ERR(lprops);
550 if (IS_ERR(lprops)) {
551 err = PTR_ERR(lprops);
557 c->
lst.taken_empty_lebs -= 1;
562 ubifs_release_lprops(c);
583 c->
lst.taken_empty_lebs -= 1;
586 ubifs_release_lprops(c);
602 static int scan_for_idx_cb(
struct ubifs_info *c,
612 if (!in_tree && valuable(c, lprops))
692 c->
lst.empty_lebs - c->
lst.taken_empty_lebs > 0) {
694 lprops = scan_for_leb_for_idx(c);
695 if (IS_ERR(lprops)) {
696 err = PTR_ERR(lprops);
710 dbg_find(
"found LEB %d, free %d, dirty %d, flags %#x",
715 if (IS_ERR(lprops)) {
716 err = PTR_ERR(lprops);
720 ubifs_release_lprops(c);
737 ubifs_release_lprops(c);
778 (
int (*)(
const void *,
const void *))cmp_dirty_idx,
779 (
void (*)(
void *,
void *,
int))swap_dirty_idx);
782 dbg_find(
"dirtiest index LEB is %d with dirty %d and free %d",
789 ubifs_release_lprops(c);
805 static int scan_dirty_idx_cb(
struct ubifs_info *c,
815 if (!in_tree && valuable(c, lprops))
838 static int find_dirty_idx_leb(
struct ubifs_info *c)
848 for (i = 0; i < heap->
cnt; i++) {
849 lprops = heap->
arr[
i];
850 ret = scan_dirty_idx_cb(c, lprops, 1, &data);
855 ret = scan_dirty_idx_cb(c, lprops, 1, &data);
860 ret = scan_dirty_idx_cb(c, lprops, 1, &data);
877 return PTR_ERR(lprops);
883 dbg_find(
"found dirty LEB %d, free %d, dirty %d, flags %#x",
889 return PTR_ERR(lprops);
898 static int get_idx_gc_leb(
struct ubifs_info *c)
918 dbg_find(
"LEB %d, dirty %d and free %d flags %#x",
927 static int find_dirtiest_idx_leb(
struct ubifs_info *c)
973 err = find_dirtiest_idx_leb(c);
977 err = find_dirty_idx_leb(c);
981 err = get_idx_gc_leb(c);
983 ubifs_release_lprops(c);