Lines Matching refs:ai
142 static int add_aeb(struct ubi_attach_info *ai, struct list_head *list, in add_aeb() argument
147 aeb = kmem_cache_alloc(ai->aeb_slab_cache, GFP_KERNEL); in add_aeb()
157 ai->ec_sum += aeb->ec; in add_aeb()
158 ai->ec_count++; in add_aeb()
160 if (ai->max_ec < aeb->ec) in add_aeb()
161 ai->max_ec = aeb->ec; in add_aeb()
163 if (ai->min_ec > aeb->ec) in add_aeb()
164 ai->min_ec = aeb->ec; in add_aeb()
183 static struct ubi_ainf_volume *add_vol(struct ubi_attach_info *ai, int vol_id, in add_vol() argument
188 struct rb_node **p = &ai->volumes.rb_node, *parent = NULL; in add_vol()
219 rb_insert_color(&av->rb, &ai->volumes); in add_vol()
232 static void assign_aeb_to_av(struct ubi_attach_info *ai, in assign_aeb_to_av() argument
237 struct rb_node **p = &ai->volumes.rb_node, *parent = NULL; in assign_aeb_to_av()
272 static int update_vol(struct ubi_device *ubi, struct ubi_attach_info *ai, in update_vol() argument
299 kmem_cache_free(ai->aeb_slab_cache, new_aeb); in update_vol()
310 victim = kmem_cache_alloc(ai->aeb_slab_cache, in update_vol()
317 list_add_tail(&victim->u.list, &ai->erase); in update_vol()
330 kmem_cache_free(ai->aeb_slab_cache, new_aeb); in update_vol()
336 list_add_tail(&new_aeb->u.list, &ai->erase); in update_vol()
368 static int process_pool_aeb(struct ubi_device *ubi, struct ubi_attach_info *ai, in process_pool_aeb() argument
373 struct rb_node **p = &ai->volumes.rb_node, *parent = NULL; in process_pool_aeb()
378 kmem_cache_free(ai->aeb_slab_cache, new_aeb); in process_pool_aeb()
402 kmem_cache_free(ai->aeb_slab_cache, new_aeb); in process_pool_aeb()
408 return update_vol(ubi, ai, av, new_vh, new_aeb); in process_pool_aeb()
419 static void unmap_peb(struct ubi_attach_info *ai, int pnum) in unmap_peb() argument
425 for (node = rb_first(&ai->volumes); node; node = rb_next(node)) { in unmap_peb()
434 kmem_cache_free(ai->aeb_slab_cache, aeb); in unmap_peb()
454 static int scan_pool(struct ubi_device *ubi, struct ubi_attach_info *ai, in scan_pool() argument
458 static int scan_pool(struct ubi_device *ubi, struct ubi_attach_info *ai, in scan_pool()
521 unmap_peb(ai, pnum); in scan_pool()
524 add_aeb(ai, free, pnum, ec, 1); in scan_pool()
526 add_aeb(ai, free, pnum, ec, 0); in scan_pool()
534 new_aeb = kmem_cache_alloc(ai->aeb_slab_cache, in scan_pool()
551 err = process_pool_aeb(ubi, ai, vh, new_aeb); in scan_pool()
575 static int count_fastmap_pebs(struct ubi_attach_info *ai) in count_fastmap_pebs() argument
582 list_for_each_entry(aeb, &ai->erase, u.list) in count_fastmap_pebs()
585 list_for_each_entry(aeb, &ai->free, u.list) in count_fastmap_pebs()
588 ubi_rb_for_each_entry(rb1, av, &ai->volumes, rb) in count_fastmap_pebs()
605 struct ubi_attach_info *ai, in ubi_attach_fastmap() argument
624 ai->min_ec = UBI_MAX_ERASECOUNTER; in ubi_attach_fastmap()
627 ai->max_sqnum = fmsb->sqnum; in ubi_attach_fastmap()
699 add_aeb(ai, &ai->free, be32_to_cpu(fmec->pnum), in ubi_attach_fastmap()
710 add_aeb(ai, &used, be32_to_cpu(fmec->pnum), in ubi_attach_fastmap()
721 add_aeb(ai, &used, be32_to_cpu(fmec->pnum), in ubi_attach_fastmap()
732 add_aeb(ai, &ai->erase, be32_to_cpu(fmec->pnum), in ubi_attach_fastmap()
736 ai->mean_ec = div_u64(ai->ec_sum, ai->ec_count); in ubi_attach_fastmap()
737 ai->bad_peb_count = be32_to_cpu(fmhdr->bad_peb_count); in ubi_attach_fastmap()
752 av = add_vol(ai, be32_to_cpu(fmvhdr->vol_id), in ubi_attach_fastmap()
766 ai->vols_found++; in ubi_attach_fastmap()
767 if (ai->highest_vol_id < be32_to_cpu(fmvhdr->vol_id)) in ubi_attach_fastmap()
768 ai->highest_vol_id = be32_to_cpu(fmvhdr->vol_id); in ubi_attach_fastmap()
806 assign_aeb_to_av(ai, aeb, av); in ubi_attach_fastmap()
813 ret = scan_pool(ubi, ai, fmpl->pebs, pool_size, &max_sqnum, &free); in ubi_attach_fastmap()
817 ret = scan_pool(ubi, ai, fmpl_wl->pebs, wl_pool_size, &max_sqnum, &free); in ubi_attach_fastmap()
821 if (max_sqnum > ai->max_sqnum) in ubi_attach_fastmap()
822 ai->max_sqnum = max_sqnum; in ubi_attach_fastmap()
825 list_move_tail(&tmp_aeb->u.list, &ai->free); in ubi_attach_fastmap()
828 list_move_tail(&tmp_aeb->u.list, &ai->erase); in ubi_attach_fastmap()
839 if (WARN_ON(count_fastmap_pebs(ai) != ubi->peb_count - in ubi_attach_fastmap()
840 ai->bad_peb_count - fm->used_blocks)) in ubi_attach_fastmap()
843 if (count_fastmap_pebs(ai) != ubi->peb_count - in ubi_attach_fastmap()
844 ai->bad_peb_count - fm->used_blocks) { in ubi_attach_fastmap()
857 kmem_cache_free(ai->aeb_slab_cache, tmp_aeb); in ubi_attach_fastmap()
861 kmem_cache_free(ai->aeb_slab_cache, tmp_aeb); in ubi_attach_fastmap()
877 int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai, in ubi_scan_fastmap() argument
1044 ret = ubi_attach_fastmap(ubi, ai, fm); in ubi_scan_fastmap()