Lines Matching full:ai
128 * @ai: UBI attach info object
136 static int add_aeb(struct ubi_attach_info *ai, struct list_head *list, in add_aeb() argument
141 aeb = ubi_alloc_aeb(ai, pnum, ec); in add_aeb()
149 ai->ec_sum += aeb->ec; in add_aeb()
150 ai->ec_count++; in add_aeb()
152 if (ai->max_ec < aeb->ec) in add_aeb()
153 ai->max_ec = aeb->ec; in add_aeb()
155 if (ai->min_ec > aeb->ec) in add_aeb()
156 ai->min_ec = aeb->ec; in add_aeb()
165 * @ai: ubi_attach_info object
175 static struct ubi_ainf_volume *add_vol(struct ubi_attach_info *ai, int vol_id, in add_vol() argument
181 av = ubi_add_av(ai, vol_id); in add_vol()
199 * @ai: ubi_attach_info object
203 static void assign_aeb_to_av(struct ubi_attach_info *ai, in assign_aeb_to_av() argument
235 * @ai: attach info object
242 static int update_vol(struct ubi_device *ubi, struct ubi_attach_info *ai, in update_vol() argument
269 ubi_free_aeb(ai, new_aeb); in update_vol()
280 victim = ubi_alloc_aeb(ai, aeb->pnum, aeb->ec); in update_vol()
284 list_add_tail(&victim->u.list, &ai->erase); in update_vol()
298 ubi_free_aeb(ai, new_aeb); in update_vol()
304 list_add_tail(&new_aeb->u.list, &ai->erase); in update_vol()
330 * @ai: attach info object
336 static int process_pool_aeb(struct ubi_device *ubi, struct ubi_attach_info *ai, in process_pool_aeb() argument
344 ubi_free_aeb(ai, new_aeb); in process_pool_aeb()
350 av = ubi_find_av(ai, vol_id); in process_pool_aeb()
353 ubi_free_aeb(ai, new_aeb); in process_pool_aeb()
359 return update_vol(ubi, ai, av, new_vh, new_aeb); in process_pool_aeb()
367 * @ai: UBI attach info object
370 static void unmap_peb(struct ubi_attach_info *ai, int pnum) in unmap_peb() argument
376 ubi_rb_for_each_entry(node, av, &ai->volumes, rb) { in unmap_peb()
381 ubi_free_aeb(ai, aeb); in unmap_peb()
391 * @ai: attach info object
395 * @free: list of PEBs which are most likely free (and go into @ai->free)
400 static int scan_pool(struct ubi_device *ubi, struct ubi_attach_info *ai, in scan_pool() argument
465 unmap_peb(ai, pnum); in scan_pool()
471 ret = add_aeb(ai, free, pnum, ec, scrub); in scan_pool()
481 new_aeb = ubi_alloc_aeb(ai, pnum, be64_to_cpu(ech->ec)); in scan_pool()
495 err = process_pool_aeb(ubi, ai, vh, new_aeb); in scan_pool()
517 * @ai: The UBI attach info object
519 static int count_fastmap_pebs(struct ubi_attach_info *ai) in count_fastmap_pebs() argument
526 list_for_each_entry(aeb, &ai->erase, u.list) in count_fastmap_pebs()
529 list_for_each_entry(aeb, &ai->free, u.list) in count_fastmap_pebs()
532 ubi_rb_for_each_entry(rb1, av, &ai->volumes, rb) in count_fastmap_pebs()
542 * @ai: UBI attach info object
549 struct ubi_attach_info *ai, in ubi_attach_fastmap() argument
568 ai->min_ec = UBI_MAX_ERASECOUNTER; in ubi_attach_fastmap()
571 ai->max_sqnum = fmsb->sqnum; in ubi_attach_fastmap()
643 ret = add_aeb(ai, &ai->free, be32_to_cpu(fmec->pnum), in ubi_attach_fastmap()
656 ret = add_aeb(ai, &used, be32_to_cpu(fmec->pnum), in ubi_attach_fastmap()
669 ret = add_aeb(ai, &used, be32_to_cpu(fmec->pnum), in ubi_attach_fastmap()
682 ret = add_aeb(ai, &ai->erase, be32_to_cpu(fmec->pnum), in ubi_attach_fastmap()
688 ai->mean_ec = div_u64(ai->ec_sum, ai->ec_count); in ubi_attach_fastmap()
689 ai->bad_peb_count = be32_to_cpu(fmhdr->bad_peb_count); in ubi_attach_fastmap()
704 av = add_vol(ai, be32_to_cpu(fmvhdr->vol_id), in ubi_attach_fastmap()
718 ai->vols_found++; in ubi_attach_fastmap()
719 if (ai->highest_vol_id < be32_to_cpu(fmvhdr->vol_id)) in ubi_attach_fastmap()
720 ai->highest_vol_id = be32_to_cpu(fmvhdr->vol_id); in ubi_attach_fastmap()
758 assign_aeb_to_av(ai, aeb, av); in ubi_attach_fastmap()
765 ret = scan_pool(ubi, ai, fmpl->pebs, pool_size, &max_sqnum, &free); in ubi_attach_fastmap()
769 ret = scan_pool(ubi, ai, fmpl_wl->pebs, wl_pool_size, &max_sqnum, &free); in ubi_attach_fastmap()
773 if (max_sqnum > ai->max_sqnum) in ubi_attach_fastmap()
774 ai->max_sqnum = max_sqnum; in ubi_attach_fastmap()
777 list_move_tail(&tmp_aeb->u.list, &ai->free); in ubi_attach_fastmap()
780 list_move_tail(&tmp_aeb->u.list, &ai->erase); in ubi_attach_fastmap()
790 if (WARN_ON(count_fastmap_pebs(ai) != ubi->peb_count - in ubi_attach_fastmap()
791 ai->bad_peb_count - fm->used_blocks)) in ubi_attach_fastmap()
801 ubi_free_aeb(ai, tmp_aeb); in ubi_attach_fastmap()
805 ubi_free_aeb(ai, tmp_aeb); in ubi_attach_fastmap()
813 * @ai: UBI attach info to be filled
815 static int find_fm_anchor(struct ubi_attach_info *ai) in find_fm_anchor() argument
821 list_for_each_entry(aeb, &ai->fastmap, u.list) { in find_fm_anchor()
831 static struct ubi_ainf_peb *clone_aeb(struct ubi_attach_info *ai, in clone_aeb() argument
836 new = ubi_alloc_aeb(ai, old->pnum, old->ec); in clone_aeb()
852 * @ai: UBI attach info to be filled
860 int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai, in ubi_scan_fastmap() argument
882 new = clone_aeb(ai, aeb); in ubi_scan_fastmap()
886 list_add(&new->u.list, &ai->fastmap); in ubi_scan_fastmap()
1053 ret = ubi_attach_fastmap(ubi, ai, fm); in ubi_scan_fastmap()