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()
216 rb_insert_color(&av->rb, &ai->volumes); in add_vol()
229 static void assign_aeb_to_av(struct ubi_attach_info *ai, in assign_aeb_to_av() argument
234 struct rb_node **p = &ai->volumes.rb_node, *parent = NULL; in assign_aeb_to_av()
269 static int update_vol(struct ubi_device *ubi, struct ubi_attach_info *ai, in update_vol() argument
296 kmem_cache_free(ai->aeb_slab_cache, new_aeb); in update_vol()
307 victim = kmem_cache_alloc(ai->aeb_slab_cache, in update_vol()
314 list_add_tail(&victim->u.list, &ai->erase); in update_vol()
327 kmem_cache_free(ai->aeb_slab_cache, new_aeb); in update_vol()
333 list_add_tail(&new_aeb->u.list, &ai->erase); in update_vol()
365 static int process_pool_aeb(struct ubi_device *ubi, struct ubi_attach_info *ai, in process_pool_aeb() argument
370 struct rb_node **p = &ai->volumes.rb_node, *parent = NULL; in process_pool_aeb()
375 kmem_cache_free(ai->aeb_slab_cache, new_aeb); in process_pool_aeb()
399 kmem_cache_free(ai->aeb_slab_cache, new_aeb); in process_pool_aeb()
405 return update_vol(ubi, ai, av, new_vh, new_aeb); in process_pool_aeb()
416 static void unmap_peb(struct ubi_attach_info *ai, int pnum) in unmap_peb() argument
422 for (node = rb_first(&ai->volumes); node; node = rb_next(node)) { in unmap_peb()
431 kmem_cache_free(ai->aeb_slab_cache, aeb); in unmap_peb()
450 static int scan_pool(struct ubi_device *ubi, struct ubi_attach_info *ai, in scan_pool() argument
512 unmap_peb(ai, pnum); in scan_pool()
515 add_aeb(ai, free, pnum, ec, 1); in scan_pool()
517 add_aeb(ai, free, pnum, ec, 0); in scan_pool()
525 new_aeb = kmem_cache_alloc(ai->aeb_slab_cache, in scan_pool()
542 err = process_pool_aeb(ubi, ai, vh, new_aeb); in scan_pool()
566 static int count_fastmap_pebs(struct ubi_attach_info *ai) in count_fastmap_pebs() argument
573 list_for_each_entry(aeb, &ai->erase, u.list) in count_fastmap_pebs()
576 list_for_each_entry(aeb, &ai->free, u.list) in count_fastmap_pebs()
579 ubi_rb_for_each_entry(rb1, av, &ai->volumes, rb) in count_fastmap_pebs()
596 struct ubi_attach_info *ai, in ubi_attach_fastmap() argument
615 ai->min_ec = UBI_MAX_ERASECOUNTER; in ubi_attach_fastmap()
618 ai->max_sqnum = fmsb->sqnum; in ubi_attach_fastmap()
690 add_aeb(ai, &ai->free, be32_to_cpu(fmec->pnum), in ubi_attach_fastmap()
701 add_aeb(ai, &used, be32_to_cpu(fmec->pnum), in ubi_attach_fastmap()
712 add_aeb(ai, &used, be32_to_cpu(fmec->pnum), in ubi_attach_fastmap()
723 add_aeb(ai, &ai->erase, be32_to_cpu(fmec->pnum), in ubi_attach_fastmap()
727 ai->mean_ec = div_u64(ai->ec_sum, ai->ec_count); in ubi_attach_fastmap()
728 ai->bad_peb_count = be32_to_cpu(fmhdr->bad_peb_count); in ubi_attach_fastmap()
743 av = add_vol(ai, be32_to_cpu(fmvhdr->vol_id), in ubi_attach_fastmap()
752 ai->vols_found++; in ubi_attach_fastmap()
753 if (ai->highest_vol_id < be32_to_cpu(fmvhdr->vol_id)) in ubi_attach_fastmap()
754 ai->highest_vol_id = be32_to_cpu(fmvhdr->vol_id); in ubi_attach_fastmap()
792 assign_aeb_to_av(ai, aeb, av); in ubi_attach_fastmap()
799 ret = scan_pool(ubi, ai, fmpl1->pebs, pool_size, &max_sqnum, &free); in ubi_attach_fastmap()
803 ret = scan_pool(ubi, ai, fmpl2->pebs, wl_pool_size, &max_sqnum, &free); in ubi_attach_fastmap()
807 if (max_sqnum > ai->max_sqnum) in ubi_attach_fastmap()
808 ai->max_sqnum = max_sqnum; in ubi_attach_fastmap()
811 list_move_tail(&tmp_aeb->u.list, &ai->free); in ubi_attach_fastmap()
814 list_move_tail(&tmp_aeb->u.list, &ai->erase); in ubi_attach_fastmap()
824 if (WARN_ON(count_fastmap_pebs(ai) != ubi->peb_count - in ubi_attach_fastmap()
825 ai->bad_peb_count - fm->used_blocks)) in ubi_attach_fastmap()
835 kmem_cache_free(ai->aeb_slab_cache, tmp_aeb); in ubi_attach_fastmap()
839 kmem_cache_free(ai->aeb_slab_cache, tmp_aeb); in ubi_attach_fastmap()
855 int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai, in ubi_scan_fastmap() argument
1022 ret = ubi_attach_fastmap(ubi, ai, fm); in ubi_scan_fastmap()