Lines Matching refs:ai

141 static int add_aeb(struct ubi_attach_info *ai, struct list_head *list,  in add_aeb()  argument
146 aeb = kmem_cache_alloc(ai->aeb_slab_cache, GFP_KERNEL); in add_aeb()
156 ai->ec_sum += aeb->ec; in add_aeb()
157 ai->ec_count++; in add_aeb()
159 if (ai->max_ec < aeb->ec) in add_aeb()
160 ai->max_ec = aeb->ec; in add_aeb()
162 if (ai->min_ec > aeb->ec) in add_aeb()
163 ai->min_ec = aeb->ec; in add_aeb()
182 static struct ubi_ainf_volume *add_vol(struct ubi_attach_info *ai, int vol_id, in add_vol() argument
187 struct rb_node **p = &ai->volumes.rb_node, *parent = NULL; in add_vol()
218 rb_insert_color(&av->rb, &ai->volumes); in add_vol()
231 static void assign_aeb_to_av(struct ubi_attach_info *ai, in assign_aeb_to_av() argument
236 struct rb_node **p = &ai->volumes.rb_node, *parent = NULL; in assign_aeb_to_av()
271 static int update_vol(struct ubi_device *ubi, struct ubi_attach_info *ai, in update_vol() argument
298 kmem_cache_free(ai->aeb_slab_cache, new_aeb); in update_vol()
309 victim = kmem_cache_alloc(ai->aeb_slab_cache, in update_vol()
316 list_add_tail(&victim->u.list, &ai->erase); in update_vol()
329 kmem_cache_free(ai->aeb_slab_cache, new_aeb); in update_vol()
335 list_add_tail(&new_aeb->u.list, &ai->erase); in update_vol()
367 static int process_pool_aeb(struct ubi_device *ubi, struct ubi_attach_info *ai, in process_pool_aeb() argument
372 struct rb_node **p = &ai->volumes.rb_node, *parent = NULL; in process_pool_aeb()
377 kmem_cache_free(ai->aeb_slab_cache, new_aeb); in process_pool_aeb()
401 kmem_cache_free(ai->aeb_slab_cache, new_aeb); in process_pool_aeb()
407 return update_vol(ubi, ai, av, new_vh, new_aeb); in process_pool_aeb()
418 static void unmap_peb(struct ubi_attach_info *ai, int pnum) in unmap_peb() argument
424 for (node = rb_first(&ai->volumes); node; node = rb_next(node)) { in unmap_peb()
433 kmem_cache_free(ai->aeb_slab_cache, aeb); in unmap_peb()
452 static int scan_pool(struct ubi_device *ubi, struct ubi_attach_info *ai, in scan_pool() argument
514 unmap_peb(ai, pnum); in scan_pool()
517 add_aeb(ai, free, pnum, ec, 1); in scan_pool()
519 add_aeb(ai, free, pnum, ec, 0); in scan_pool()
527 new_aeb = kmem_cache_alloc(ai->aeb_slab_cache, in scan_pool()
544 err = process_pool_aeb(ubi, ai, vh, new_aeb); in scan_pool()
568 static int count_fastmap_pebs(struct ubi_attach_info *ai) in count_fastmap_pebs() argument
575 list_for_each_entry(aeb, &ai->erase, u.list) in count_fastmap_pebs()
578 list_for_each_entry(aeb, &ai->free, u.list) in count_fastmap_pebs()
581 ubi_rb_for_each_entry(rb1, av, &ai->volumes, rb) in count_fastmap_pebs()
598 struct ubi_attach_info *ai, in ubi_attach_fastmap() argument
617 ai->min_ec = UBI_MAX_ERASECOUNTER; in ubi_attach_fastmap()
620 ai->max_sqnum = fmsb->sqnum; in ubi_attach_fastmap()
692 add_aeb(ai, &ai->free, be32_to_cpu(fmec->pnum), in ubi_attach_fastmap()
703 add_aeb(ai, &used, be32_to_cpu(fmec->pnum), in ubi_attach_fastmap()
714 add_aeb(ai, &used, be32_to_cpu(fmec->pnum), in ubi_attach_fastmap()
725 add_aeb(ai, &ai->erase, be32_to_cpu(fmec->pnum), in ubi_attach_fastmap()
729 ai->mean_ec = div_u64(ai->ec_sum, ai->ec_count); in ubi_attach_fastmap()
730 ai->bad_peb_count = be32_to_cpu(fmhdr->bad_peb_count); in ubi_attach_fastmap()
745 av = add_vol(ai, be32_to_cpu(fmvhdr->vol_id), in ubi_attach_fastmap()
759 ai->vols_found++; in ubi_attach_fastmap()
760 if (ai->highest_vol_id < be32_to_cpu(fmvhdr->vol_id)) in ubi_attach_fastmap()
761 ai->highest_vol_id = be32_to_cpu(fmvhdr->vol_id); in ubi_attach_fastmap()
799 assign_aeb_to_av(ai, aeb, av); in ubi_attach_fastmap()
806 ret = scan_pool(ubi, ai, fmpl->pebs, pool_size, &max_sqnum, &free); in ubi_attach_fastmap()
810 ret = scan_pool(ubi, ai, fmpl_wl->pebs, wl_pool_size, &max_sqnum, &free); in ubi_attach_fastmap()
814 if (max_sqnum > ai->max_sqnum) in ubi_attach_fastmap()
815 ai->max_sqnum = max_sqnum; in ubi_attach_fastmap()
818 list_move_tail(&tmp_aeb->u.list, &ai->free); in ubi_attach_fastmap()
821 list_move_tail(&tmp_aeb->u.list, &ai->erase); in ubi_attach_fastmap()
831 if (WARN_ON(count_fastmap_pebs(ai) != ubi->peb_count - in ubi_attach_fastmap()
832 ai->bad_peb_count - fm->used_blocks)) in ubi_attach_fastmap()
842 kmem_cache_free(ai->aeb_slab_cache, tmp_aeb); in ubi_attach_fastmap()
846 kmem_cache_free(ai->aeb_slab_cache, tmp_aeb); in ubi_attach_fastmap()
862 int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai, in ubi_scan_fastmap() argument
1029 ret = ubi_attach_fastmap(ubi, ai, fm); in ubi_scan_fastmap()