• Home
  • Raw
  • Download

Lines Matching refs:vol

58 	struct ubi_volume *vol = container_of(dev, struct ubi_volume, dev);  in vol_attribute_show()  local
59 struct ubi_device *ubi = vol->ubi; in vol_attribute_show()
62 if (!ubi->volumes[vol->vol_id]) { in vol_attribute_show()
67 vol->ref_count += 1; in vol_attribute_show()
71 ret = sprintf(buf, "%d\n", vol->reserved_pebs); in vol_attribute_show()
75 if (vol->vol_type == UBI_DYNAMIC_VOLUME) in vol_attribute_show()
81 ret = sprintf(buf, "%s\n", vol->name); in vol_attribute_show()
83 ret = sprintf(buf, "%d\n", vol->corrupted); in vol_attribute_show()
85 ret = sprintf(buf, "%d\n", vol->alignment); in vol_attribute_show()
87 ret = sprintf(buf, "%d\n", vol->usable_leb_size); in vol_attribute_show()
89 ret = sprintf(buf, "%lld\n", vol->used_bytes); in vol_attribute_show()
91 ret = sprintf(buf, "%d\n", vol->upd_marker); in vol_attribute_show()
98 vol->ref_count -= 1; in vol_attribute_show()
99 ubi_assert(vol->ref_count >= 0); in vol_attribute_show()
120 struct ubi_volume *vol = container_of(dev, struct ubi_volume, dev); in vol_release() local
122 ubi_eba_replace_table(vol, NULL); in vol_release()
123 ubi_fastmap_destroy_checkmap(vol); in vol_release()
124 kfree(vol); in vol_release()
141 struct ubi_volume *vol; in ubi_create_volume() local
148 vol = kzalloc(sizeof(struct ubi_volume), GFP_KERNEL); in ubi_create_volume()
149 if (!vol) in ubi_create_volume()
152 device_initialize(&vol->dev); in ubi_create_volume()
153 vol->dev.release = vol_release; in ubi_create_volume()
154 vol->dev.parent = &ubi->dev; in ubi_create_volume()
155 vol->dev.class = &ubi_class; in ubi_create_volume()
156 vol->dev.groups = volume_dev_groups; in ubi_create_volume()
159 vol->skip_check = 1; in ubi_create_volume()
201 vol->usable_leb_size = ubi->leb_size - ubi->leb_size % req->alignment; in ubi_create_volume()
202 vol->reserved_pebs = div_u64(req->bytes + vol->usable_leb_size - 1, in ubi_create_volume()
203 vol->usable_leb_size); in ubi_create_volume()
206 if (vol->reserved_pebs > ubi->avail_pebs) { in ubi_create_volume()
215 ubi->avail_pebs -= vol->reserved_pebs; in ubi_create_volume()
216 ubi->rsvd_pebs += vol->reserved_pebs; in ubi_create_volume()
219 vol->vol_id = vol_id; in ubi_create_volume()
220 vol->alignment = req->alignment; in ubi_create_volume()
221 vol->data_pad = ubi->leb_size % vol->alignment; in ubi_create_volume()
222 vol->vol_type = req->vol_type; in ubi_create_volume()
223 vol->name_len = req->name_len; in ubi_create_volume()
224 memcpy(vol->name, req->name, vol->name_len); in ubi_create_volume()
225 vol->ubi = ubi; in ubi_create_volume()
235 eba_tbl = ubi_eba_create_table(vol, vol->reserved_pebs); in ubi_create_volume()
241 ubi_eba_replace_table(vol, eba_tbl); in ubi_create_volume()
243 if (vol->vol_type == UBI_DYNAMIC_VOLUME) { in ubi_create_volume()
244 vol->used_ebs = vol->reserved_pebs; in ubi_create_volume()
245 vol->last_eb_bytes = vol->usable_leb_size; in ubi_create_volume()
246 vol->used_bytes = in ubi_create_volume()
247 (long long)vol->used_ebs * vol->usable_leb_size; in ubi_create_volume()
249 vol->used_ebs = div_u64_rem(vol->used_bytes, in ubi_create_volume()
250 vol->usable_leb_size, in ubi_create_volume()
251 &vol->last_eb_bytes); in ubi_create_volume()
252 if (vol->last_eb_bytes != 0) in ubi_create_volume()
253 vol->used_ebs += 1; in ubi_create_volume()
255 vol->last_eb_bytes = vol->usable_leb_size; in ubi_create_volume()
260 ubi->volumes[vol_id] = vol; in ubi_create_volume()
265 cdev_init(&vol->cdev, &ubi_vol_cdev_operations); in ubi_create_volume()
266 vol->cdev.owner = THIS_MODULE; in ubi_create_volume()
268 vol->dev.devt = MKDEV(MAJOR(ubi->cdev.dev), vol_id + 1); in ubi_create_volume()
269 dev_set_name(&vol->dev, "%s_%d", ubi->ubi_name, vol->vol_id); in ubi_create_volume()
270 err = cdev_device_add(&vol->cdev, &vol->dev); in ubi_create_volume()
278 vtbl_rec.reserved_pebs = cpu_to_be32(vol->reserved_pebs); in ubi_create_volume()
279 vtbl_rec.alignment = cpu_to_be32(vol->alignment); in ubi_create_volume()
280 vtbl_rec.data_pad = cpu_to_be32(vol->data_pad); in ubi_create_volume()
281 vtbl_rec.name_len = cpu_to_be16(vol->name_len); in ubi_create_volume()
282 if (vol->vol_type == UBI_DYNAMIC_VOLUME) in ubi_create_volume()
287 if (vol->skip_check) in ubi_create_volume()
290 memcpy(vtbl_rec.name, vol->name, vol->name_len); in ubi_create_volume()
296 ubi_volume_notify(ubi, vol, UBI_VOLUME_ADDED); in ubi_create_volume()
306 cdev_device_del(&vol->cdev, &vol->dev); in ubi_create_volume()
315 ubi->rsvd_pebs -= vol->reserved_pebs; in ubi_create_volume()
316 ubi->avail_pebs += vol->reserved_pebs; in ubi_create_volume()
319 put_device(&vol->dev); in ubi_create_volume()
336 struct ubi_volume *vol = desc->vol; in ubi_remove_volume() local
337 struct ubi_device *ubi = vol->ubi; in ubi_remove_volume()
338 int i, err, vol_id = vol->vol_id, reserved_pebs = vol->reserved_pebs; in ubi_remove_volume()
342 ubi_assert(vol == ubi->volumes[vol_id]); in ubi_remove_volume()
348 if (vol->ref_count > 1) { in ubi_remove_volume()
365 for (i = 0; i < vol->reserved_pebs; i++) { in ubi_remove_volume()
366 err = ubi_eba_unmap_leb(ubi, vol, i); in ubi_remove_volume()
371 cdev_device_del(&vol->cdev, &vol->dev); in ubi_remove_volume()
372 put_device(&vol->dev); in ubi_remove_volume()
381 ubi_volume_notify(ubi, vol, UBI_VOLUME_REMOVED); in ubi_remove_volume()
390 ubi->volumes[vol_id] = vol; in ubi_remove_volume()
408 struct ubi_volume *vol = desc->vol; in ubi_resize_volume() local
409 struct ubi_device *ubi = vol->ubi; in ubi_resize_volume()
413 int vol_id = vol->vol_id; in ubi_resize_volume()
419 ubi->ubi_num, vol_id, vol->reserved_pebs, reserved_pebs); in ubi_resize_volume()
421 if (vol->vol_type == UBI_STATIC_VOLUME && in ubi_resize_volume()
422 reserved_pebs < vol->used_ebs) { in ubi_resize_volume()
424 reserved_pebs, vol->used_ebs); in ubi_resize_volume()
429 if (reserved_pebs == vol->reserved_pebs) in ubi_resize_volume()
432 new_eba_tbl = ubi_eba_create_table(vol, reserved_pebs); in ubi_resize_volume()
437 if (vol->ref_count > 1) { in ubi_resize_volume()
445 pebs = reserved_pebs - vol->reserved_pebs; in ubi_resize_volume()
461 ubi_eba_copy_table(vol, new_eba_tbl, vol->reserved_pebs); in ubi_resize_volume()
462 old_eba_tbl = vol->eba_tbl; in ubi_resize_volume()
463 vol->eba_tbl = new_eba_tbl; in ubi_resize_volume()
464 vol->reserved_pebs = reserved_pebs; in ubi_resize_volume()
470 err = ubi_eba_unmap_leb(ubi, vol, reserved_pebs + i); in ubi_resize_volume()
478 ubi_eba_copy_table(vol, new_eba_tbl, reserved_pebs); in ubi_resize_volume()
479 old_eba_tbl = vol->eba_tbl; in ubi_resize_volume()
480 vol->eba_tbl = new_eba_tbl; in ubi_resize_volume()
481 vol->reserved_pebs = reserved_pebs; in ubi_resize_volume()
503 if (vol->vol_type == UBI_DYNAMIC_VOLUME) { in ubi_resize_volume()
504 vol->used_ebs = reserved_pebs; in ubi_resize_volume()
505 vol->last_eb_bytes = vol->usable_leb_size; in ubi_resize_volume()
506 vol->used_bytes = in ubi_resize_volume()
507 (long long)vol->used_ebs * vol->usable_leb_size; in ubi_resize_volume()
511 ubi_volume_notify(ubi, vol, UBI_VOLUME_RESIZED); in ubi_resize_volume()
517 vol->reserved_pebs = reserved_pebs - pebs; in ubi_resize_volume()
521 ubi_eba_copy_table(vol, old_eba_tbl, vol->reserved_pebs); in ubi_resize_volume()
523 ubi_eba_copy_table(vol, old_eba_tbl, reserved_pebs); in ubi_resize_volume()
525 vol->eba_tbl = old_eba_tbl; in ubi_resize_volume()
556 struct ubi_volume *vol = re->desc->vol; in ubi_rename_volumes() local
559 vol->name_len = re->new_name_len; in ubi_rename_volumes()
560 memcpy(vol->name, re->new_name, re->new_name_len + 1); in ubi_rename_volumes()
562 ubi_volume_notify(ubi, vol, UBI_VOLUME_RENAMED); in ubi_rename_volumes()
580 int ubi_add_volume(struct ubi_device *ubi, struct ubi_volume *vol) in ubi_add_volume() argument
582 int err, vol_id = vol->vol_id; in ubi_add_volume()
588 cdev_init(&vol->cdev, &ubi_vol_cdev_operations); in ubi_add_volume()
589 vol->cdev.owner = THIS_MODULE; in ubi_add_volume()
590 dev = MKDEV(MAJOR(ubi->cdev.dev), vol->vol_id + 1); in ubi_add_volume()
591 err = cdev_add(&vol->cdev, dev, 1); in ubi_add_volume()
598 vol->dev.release = vol_release; in ubi_add_volume()
599 vol->dev.parent = &ubi->dev; in ubi_add_volume()
600 vol->dev.devt = dev; in ubi_add_volume()
601 vol->dev.class = &ubi_class; in ubi_add_volume()
602 vol->dev.groups = volume_dev_groups; in ubi_add_volume()
603 dev_set_name(&vol->dev, "%s_%d", ubi->ubi_name, vol->vol_id); in ubi_add_volume()
604 err = device_register(&vol->dev); in ubi_add_volume()
612 cdev_del(&vol->cdev); in ubi_add_volume()
624 void ubi_free_volume(struct ubi_device *ubi, struct ubi_volume *vol) in ubi_free_volume() argument
626 dbg_gen("free volume %d", vol->vol_id); in ubi_free_volume()
628 ubi->volumes[vol->vol_id] = NULL; in ubi_free_volume()
629 cdev_del(&vol->cdev); in ubi_free_volume()
630 device_unregister(&vol->dev); in ubi_free_volume()
644 const struct ubi_volume *vol; in self_check_volume() local
650 vol = ubi->volumes[idx]; in self_check_volume()
652 if (!vol) { in self_check_volume()
661 if (vol->reserved_pebs < 0 || vol->alignment < 0 || vol->data_pad < 0 || in self_check_volume()
662 vol->name_len < 0) { in self_check_volume()
666 if (vol->alignment > ubi->leb_size || vol->alignment == 0) { in self_check_volume()
671 n = vol->alignment & (ubi->min_io_size - 1); in self_check_volume()
672 if (vol->alignment != 1 && n) { in self_check_volume()
677 n = ubi->leb_size % vol->alignment; in self_check_volume()
678 if (vol->data_pad != n) { in self_check_volume()
683 if (vol->vol_type != UBI_DYNAMIC_VOLUME && in self_check_volume()
684 vol->vol_type != UBI_STATIC_VOLUME) { in self_check_volume()
689 if (vol->upd_marker && vol->corrupted) { in self_check_volume()
694 if (vol->reserved_pebs > ubi->good_peb_count) { in self_check_volume()
699 n = ubi->leb_size - vol->data_pad; in self_check_volume()
700 if (vol->usable_leb_size != ubi->leb_size - vol->data_pad) { in self_check_volume()
705 if (vol->name_len > UBI_VOL_NAME_MAX) { in self_check_volume()
711 n = strnlen(vol->name, vol->name_len + 1); in self_check_volume()
712 if (n != vol->name_len) { in self_check_volume()
717 n = (long long)vol->used_ebs * vol->usable_leb_size; in self_check_volume()
718 if (vol->vol_type == UBI_DYNAMIC_VOLUME) { in self_check_volume()
719 if (vol->corrupted) { in self_check_volume()
723 if (vol->used_ebs != vol->reserved_pebs) { in self_check_volume()
727 if (vol->last_eb_bytes != vol->usable_leb_size) { in self_check_volume()
731 if (vol->used_bytes != n) { in self_check_volume()
736 if (vol->skip_check) { in self_check_volume()
741 if (vol->used_ebs < 0 || vol->used_ebs > vol->reserved_pebs) { in self_check_volume()
745 if (vol->last_eb_bytes < 0 || in self_check_volume()
746 vol->last_eb_bytes > vol->usable_leb_size) { in self_check_volume()
750 if (vol->used_bytes < 0 || vol->used_bytes > n || in self_check_volume()
751 vol->used_bytes < n - vol->usable_leb_size) { in self_check_volume()
767 if (alignment != vol->alignment || data_pad != vol->data_pad || in self_check_volume()
768 upd_marker != vol->upd_marker || vol_type != vol->vol_type || in self_check_volume()
769 name_len != vol->name_len || strncmp(name, vol->name, name_len)) { in self_check_volume()
779 if (vol) in self_check_volume()
780 ubi_dump_vol_info(vol); in self_check_volume()