Lines Matching refs:sv
187 const struct ubi_scan_volume *sv, int pnum) in validate_vid_hdr() argument
194 if (sv->leb_count != 0) { in validate_vid_hdr()
203 if (vol_id != sv->vol_id) { in validate_vid_hdr()
208 if (sv->vol_type == UBI_STATIC_VOLUME) in validate_vid_hdr()
218 if (used_ebs != sv->used_ebs) { in validate_vid_hdr()
223 if (data_pad != sv->data_pad) { in validate_vid_hdr()
234 ubi_dbg_dump_sv(sv); in validate_vid_hdr()
255 struct ubi_scan_volume *sv; in add_volume() local
263 sv = rb_entry(parent, struct ubi_scan_volume, rb); in add_volume()
265 if (vol_id == sv->vol_id) in add_volume()
266 return sv; in add_volume()
268 if (vol_id > sv->vol_id) in add_volume()
275 sv = kmalloc(sizeof(struct ubi_scan_volume), GFP_KERNEL); in add_volume()
276 if (!sv) in add_volume()
279 sv->highest_lnum = sv->leb_count = 0; in add_volume()
280 sv->vol_id = vol_id; in add_volume()
281 sv->root = RB_ROOT; in add_volume()
282 sv->used_ebs = be32_to_cpu(vid_hdr->used_ebs); in add_volume()
283 sv->data_pad = be32_to_cpu(vid_hdr->data_pad); in add_volume()
284 sv->compat = vid_hdr->compat; in add_volume()
285 sv->vol_type = vid_hdr->vol_type == UBI_VID_DYNAMIC ? UBI_DYNAMIC_VOLUME in add_volume()
290 rb_link_node(&sv->rb, parent, p); in add_volume()
291 rb_insert_color(&sv->rb, &si->volumes); in add_volume()
294 return sv; in add_volume()
453 struct ubi_scan_volume *sv; in ubi_scan_add_used() local
464 sv = add_volume(si, vol_id, pnum, vid_hdr); in ubi_scan_add_used()
465 if (IS_ERR(sv)) in ubi_scan_add_used()
466 return PTR_ERR(sv); in ubi_scan_add_used()
475 p = &sv->root.rb_node; in ubi_scan_add_used()
531 err = validate_vid_hdr(vid_hdr, sv, pnum); in ubi_scan_add_used()
546 if (sv->highest_lnum == lnum) in ubi_scan_add_used()
547 sv->last_data_size = in ubi_scan_add_used()
566 err = validate_vid_hdr(vid_hdr, sv, pnum); in ubi_scan_add_used()
581 if (sv->highest_lnum <= lnum) { in ubi_scan_add_used()
582 sv->highest_lnum = lnum; in ubi_scan_add_used()
583 sv->last_data_size = be32_to_cpu(vid_hdr->data_size); in ubi_scan_add_used()
586 sv->leb_count += 1; in ubi_scan_add_used()
588 rb_insert_color(&seb->u.rb, &sv->root); in ubi_scan_add_used()
603 struct ubi_scan_volume *sv; in ubi_scan_find_sv() local
607 sv = rb_entry(p, struct ubi_scan_volume, rb); in ubi_scan_find_sv()
609 if (vol_id == sv->vol_id) in ubi_scan_find_sv()
610 return sv; in ubi_scan_find_sv()
612 if (vol_id > sv->vol_id) in ubi_scan_find_sv()
629 struct ubi_scan_leb *ubi_scan_find_seb(const struct ubi_scan_volume *sv, in ubi_scan_find_seb() argument
633 struct rb_node *p = sv->root.rb_node; in ubi_scan_find_seb()
655 void ubi_scan_rm_volume(struct ubi_scan_info *si, struct ubi_scan_volume *sv) in ubi_scan_rm_volume() argument
660 dbg_bld("remove scanning information about volume %d", sv->vol_id); in ubi_scan_rm_volume()
662 while ((rb = rb_first(&sv->root))) { in ubi_scan_rm_volume()
664 rb_erase(&seb->u.rb, &sv->root); in ubi_scan_rm_volume()
668 rb_erase(&sv->rb, &si->volumes); in ubi_scan_rm_volume()
669 kfree(sv); in ubi_scan_rm_volume()
1154 struct ubi_scan_volume *sv; in ubi_scan() local
1206 ubi_rb_for_each_entry(rb1, sv, &si->volumes, rb) { in ubi_scan()
1207 ubi_rb_for_each_entry(rb2, seb, &sv->root, u.rb) in ubi_scan()
1253 static void destroy_sv(struct ubi_scan_info *si, struct ubi_scan_volume *sv) in destroy_sv() argument
1256 struct rb_node *this = sv->root.rb_node; in destroy_sv()
1276 kfree(sv); in destroy_sv()
1286 struct ubi_scan_volume *sv; in ubi_scan_destroy_si() local
1314 sv = rb_entry(rb, struct ubi_scan_volume, rb); in ubi_scan_destroy_si()
1318 if (rb->rb_left == &sv->rb) in ubi_scan_destroy_si()
1324 destroy_sv(si, sv); in ubi_scan_destroy_si()
1346 struct ubi_scan_volume *sv; in paranoid_check_si() local
1356 ubi_rb_for_each_entry(rb1, sv, &si->volumes, rb) { in paranoid_check_si()
1368 if (sv->vol_id < 0 || sv->highest_lnum < 0 || in paranoid_check_si()
1369 sv->leb_count < 0 || sv->vol_type < 0 || sv->used_ebs < 0 || in paranoid_check_si()
1370 sv->data_pad < 0 || sv->last_data_size < 0) { in paranoid_check_si()
1375 if (sv->vol_id >= UBI_MAX_VOLUMES && in paranoid_check_si()
1376 sv->vol_id < UBI_INTERNAL_VOL_START) { in paranoid_check_si()
1381 if (sv->vol_id > si->highest_vol_id) { in paranoid_check_si()
1383 si->highest_vol_id, sv->vol_id); in paranoid_check_si()
1387 if (sv->vol_type != UBI_DYNAMIC_VOLUME && in paranoid_check_si()
1388 sv->vol_type != UBI_STATIC_VOLUME) { in paranoid_check_si()
1393 if (sv->data_pad > ubi->leb_size / 2) { in paranoid_check_si()
1399 ubi_rb_for_each_entry(rb2, seb, &sv->root, u.rb) { in paranoid_check_si()
1428 if (sv->vol_type == UBI_STATIC_VOLUME) { in paranoid_check_si()
1429 if (seb->lnum >= sv->used_ebs) { in paranoid_check_si()
1434 if (sv->used_ebs != 0) { in paranoid_check_si()
1440 if (seb->lnum > sv->highest_lnum) { in paranoid_check_si()
1446 if (sv->leb_count != leb_count) { in paranoid_check_si()
1457 if (seb->lnum != sv->highest_lnum) { in paranoid_check_si()
1470 ubi_rb_for_each_entry(rb1, sv, &si->volumes, rb) { in paranoid_check_si()
1472 ubi_rb_for_each_entry(rb2, seb, &sv->root, u.rb) { in paranoid_check_si()
1489 if (sv->vol_type != vol_type) { in paranoid_check_si()
1499 if (sv->vol_id != be32_to_cpu(vidh->vol_id)) { in paranoid_check_si()
1500 ubi_err("bad vol_id %d", sv->vol_id); in paranoid_check_si()
1504 if (sv->compat != vidh->compat) { in paranoid_check_si()
1514 if (sv->used_ebs != be32_to_cpu(vidh->used_ebs)) { in paranoid_check_si()
1515 ubi_err("bad used_ebs %d", sv->used_ebs); in paranoid_check_si()
1519 if (sv->data_pad != be32_to_cpu(vidh->data_pad)) { in paranoid_check_si()
1520 ubi_err("bad data_pad %d", sv->data_pad); in paranoid_check_si()
1528 if (sv->highest_lnum != be32_to_cpu(vidh->lnum)) { in paranoid_check_si()
1529 ubi_err("bad highest_lnum %d", sv->highest_lnum); in paranoid_check_si()
1533 if (sv->last_data_size != be32_to_cpu(vidh->data_size)) { in paranoid_check_si()
1534 ubi_err("bad last_data_size %d", sv->last_data_size); in paranoid_check_si()
1556 ubi_rb_for_each_entry(rb1, sv, &si->volumes, rb) in paranoid_check_si()
1557 ubi_rb_for_each_entry(rb2, seb, &sv->root, u.rb) in paranoid_check_si()
1587 ubi_dbg_dump_sv(sv); in paranoid_check_si()
1591 ubi_err("bad scanning information about volume %d", sv->vol_id); in paranoid_check_si()
1592 ubi_dbg_dump_sv(sv); in paranoid_check_si()
1596 ubi_err("bad scanning information about volume %d", sv->vol_id); in paranoid_check_si()
1597 ubi_dbg_dump_sv(sv); in paranoid_check_si()