• Home
  • Raw
  • Download

Lines Matching refs:ubi

54 static void self_vtbl_check(const struct ubi_device *ubi);
63 static int ubi_update_layout_vol(struct ubi_device *ubi) in ubi_update_layout_vol() argument
68 layout_vol = ubi->volumes[vol_id2idx(ubi, UBI_LAYOUT_VOLUME_ID)]; in ubi_update_layout_vol()
70 err = ubi_eba_atomic_leb_change(ubi, layout_vol, i, ubi->vtbl, in ubi_update_layout_vol()
71 ubi->vtbl_size); in ubi_update_layout_vol()
90 int ubi_change_vtbl_record(struct ubi_device *ubi, int idx, in ubi_change_vtbl_record() argument
96 ubi_assert(idx >= 0 && idx < ubi->vtbl_slots); in ubi_change_vtbl_record()
105 memcpy(&ubi->vtbl[idx], vtbl_rec, sizeof(struct ubi_vtbl_record)); in ubi_change_vtbl_record()
106 err = ubi_update_layout_vol(ubi); in ubi_change_vtbl_record()
108 self_vtbl_check(ubi); in ubi_change_vtbl_record()
121 int ubi_vtbl_rename_volumes(struct ubi_device *ubi, in ubi_vtbl_rename_volumes() argument
129 struct ubi_vtbl_record *vtbl_rec = &ubi->vtbl[vol->vol_id]; in ubi_vtbl_rename_volumes()
146 return ubi_update_layout_vol(ubi); in ubi_vtbl_rename_volumes()
157 static int vtbl_check(const struct ubi_device *ubi, in vtbl_check() argument
165 for (i = 0; i < ubi->vtbl_slots; i++) { in vtbl_check()
178 ubi_err(ubi, "bad CRC at record %u: %#08x, not %#08x", in vtbl_check()
199 if (alignment > ubi->leb_size || alignment == 0) { in vtbl_check()
204 n = alignment & (ubi->min_io_size - 1); in vtbl_check()
210 n = ubi->leb_size % alignment; in vtbl_check()
212 ubi_err(ubi, "bad data_pad, has to be %d", n); in vtbl_check()
227 if (reserved_pebs > ubi->good_peb_count) { in vtbl_check()
228 ubi_err(ubi, "too large reserved_pebs %d, good PEBs %d", in vtbl_check()
229 reserved_pebs, ubi->good_peb_count); in vtbl_check()
251 for (i = 0; i < ubi->vtbl_slots - 1; i++) { in vtbl_check()
252 for (n = i + 1; n < ubi->vtbl_slots; n++) { in vtbl_check()
258 ubi_err(ubi, "volumes %d and %d have the same name \"%s\"", in vtbl_check()
270 ubi_err(ubi, "volume table check failed: record %d, error %d", i, err); in vtbl_check()
285 static int create_vtbl(struct ubi_device *ubi, struct ubi_attach_info *ai, in create_vtbl() argument
295 vidb = ubi_alloc_vid_buf(ubi, GFP_KERNEL); in create_vtbl()
302 new_aeb = ubi_early_get_peb(ubi, ai); in create_vtbl()
317 err = ubi_io_write_vid_hdr(ubi, new_aeb->pnum, vidb); in create_vtbl()
322 err = ubi_io_write_data(ubi, vtbl, new_aeb->pnum, 0, ubi->vtbl_size); in create_vtbl()
330 err = ubi_add_to_av(ubi, ai, new_aeb->pnum, new_aeb->ec, vid_hdr, 0); in create_vtbl()
361 static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, in process_lvol() argument
400 leb[aeb->lnum] = vzalloc(ubi->vtbl_size); in process_lvol()
406 err = ubi_io_read_data(ubi, leb[aeb->lnum], aeb->pnum, 0, in process_lvol()
407 ubi->vtbl_size); in process_lvol()
426 leb_corrupted[0] = vtbl_check(ubi, leb[0]); in process_lvol()
435 ubi->vtbl_size); in process_lvol()
437 ubi_warn(ubi, "volume table copy #2 is corrupted"); in process_lvol()
438 err = create_vtbl(ubi, ai, 1, leb[0]); in process_lvol()
441 ubi_msg(ubi, "volume table was restored"); in process_lvol()
450 leb_corrupted[1] = vtbl_check(ubi, leb[1]); in process_lvol()
456 ubi_err(ubi, "both volume tables are corrupted"); in process_lvol()
460 ubi_warn(ubi, "volume table copy #1 is corrupted"); in process_lvol()
461 err = create_vtbl(ubi, ai, 0, leb[1]); in process_lvol()
464 ubi_msg(ubi, "volume table was restored"); in process_lvol()
484 static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi, in create_empty_lvol() argument
490 vtbl = vzalloc(ubi->vtbl_size); in create_empty_lvol()
494 for (i = 0; i < ubi->vtbl_slots; i++) in create_empty_lvol()
500 err = create_vtbl(ubi, ai, i, vtbl); in create_empty_lvol()
520 static int init_volumes(struct ubi_device *ubi, in init_volumes() argument
528 for (i = 0; i < ubi->vtbl_slots; i++) { in init_volumes()
545 vol->usable_leb_size = ubi->leb_size - vol->data_pad; in init_volumes()
555 if (ubi->autoresize_vol_id != -1) { in init_volumes()
556 ubi_err(ubi, "more than one auto-resize volume (%d and %d)", in init_volumes()
557 ubi->autoresize_vol_id, i); in init_volumes()
562 ubi->autoresize_vol_id = i; in init_volumes()
565 ubi_assert(!ubi->volumes[i]); in init_volumes()
566 ubi->volumes[i] = vol; in init_volumes()
567 ubi->vol_count += 1; in init_volumes()
568 vol->ubi = ubi; in init_volumes()
577 err = ubi_fastmap_init_checkmap(vol, ubi->peb_count); in init_volumes()
612 ubi_warn(ubi, "static volume %d misses %d LEBs - corrupted", in init_volumes()
635 vol->usable_leb_size = ubi->leb_size; in init_volumes()
639 (long long)vol->used_ebs * (ubi->leb_size - vol->data_pad); in init_volumes()
643 ubi_assert(!ubi->volumes[i]); in init_volumes()
644 ubi->volumes[vol_id2idx(ubi, vol->vol_id)] = vol; in init_volumes()
646 ubi->vol_count += 1; in init_volumes()
647 vol->ubi = ubi; in init_volumes()
652 if (reserved_pebs > ubi->avail_pebs) { in init_volumes()
653 ubi_err(ubi, "not enough PEBs, required %d, available %d", in init_volumes()
654 reserved_pebs, ubi->avail_pebs); in init_volumes()
655 if (ubi->corr_peb_count) in init_volumes()
656 ubi_err(ubi, "%d PEBs are corrupted and not used", in init_volumes()
657 ubi->corr_peb_count); in init_volumes()
660 ubi->rsvd_pebs += reserved_pebs; in init_volumes()
661 ubi->avail_pebs -= reserved_pebs; in init_volumes()
702 ubi_err(vol->ubi, "bad attaching information, error %d", err); in check_av()
718 static int check_attaching_info(const struct ubi_device *ubi, in check_attaching_info() argument
725 if (ai->vols_found > UBI_INT_VOL_COUNT + ubi->vtbl_slots) { in check_attaching_info()
726 ubi_err(ubi, "found %d volumes while attaching, maximum is %d + %d", in check_attaching_info()
727 ai->vols_found, UBI_INT_VOL_COUNT, ubi->vtbl_slots); in check_attaching_info()
731 if (ai->highest_vol_id >= ubi->vtbl_slots + UBI_INT_VOL_COUNT && in check_attaching_info()
733 ubi_err(ubi, "too large volume ID %d found", in check_attaching_info()
738 for (i = 0; i < ubi->vtbl_slots + UBI_INT_VOL_COUNT; i++) { in check_attaching_info()
742 vol = ubi->volumes[i]; in check_attaching_info()
750 ubi_assert(i < ubi->vtbl_slots); in check_attaching_info()
762 ubi_msg(ubi, "finish volume %d removal", av->vol_id); in check_attaching_info()
783 int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai) in ubi_read_volume_table() argument
794 ubi->vtbl_slots = ubi->leb_size / UBI_VTBL_RECORD_SIZE; in ubi_read_volume_table()
795 if (ubi->vtbl_slots > UBI_MAX_VOLUMES) in ubi_read_volume_table()
796 ubi->vtbl_slots = UBI_MAX_VOLUMES; in ubi_read_volume_table()
798 ubi->vtbl_size = ubi->vtbl_slots * UBI_VTBL_RECORD_SIZE; in ubi_read_volume_table()
799 ubi->vtbl_size = ALIGN(ubi->vtbl_size, ubi->min_io_size); in ubi_read_volume_table()
812 ubi->vtbl = create_empty_lvol(ubi, ai); in ubi_read_volume_table()
813 if (IS_ERR(ubi->vtbl)) in ubi_read_volume_table()
814 return PTR_ERR(ubi->vtbl); in ubi_read_volume_table()
816 ubi_err(ubi, "the layout volume was not found"); in ubi_read_volume_table()
822 ubi_err(ubi, "too many LEBs (%d) in layout volume", in ubi_read_volume_table()
827 ubi->vtbl = process_lvol(ubi, ai, av); in ubi_read_volume_table()
828 if (IS_ERR(ubi->vtbl)) in ubi_read_volume_table()
829 return PTR_ERR(ubi->vtbl); in ubi_read_volume_table()
832 ubi->avail_pebs = ubi->good_peb_count - ubi->corr_peb_count; in ubi_read_volume_table()
838 err = init_volumes(ubi, ai, ubi->vtbl); in ubi_read_volume_table()
846 err = check_attaching_info(ubi, ai); in ubi_read_volume_table()
853 vfree(ubi->vtbl); in ubi_read_volume_table()
854 ubi_free_all_volumes(ubi); in ubi_read_volume_table()
862 static void self_vtbl_check(const struct ubi_device *ubi) in self_vtbl_check() argument
864 if (!ubi_dbg_chk_gen(ubi)) in self_vtbl_check()
867 if (vtbl_check(ubi, ubi->vtbl)) { in self_vtbl_check()
868 ubi_err(ubi, "self-check failed"); in self_vtbl_check()