• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/drivers/mtd/ubi/

Lines Matching refs:vol

74 	struct ubi_volume *vol = container_of(dev, struct ubi_volume, dev);
77 ubi = ubi_get_device(vol->ubi->ubi_num);
82 if (!ubi->volumes[vol->vol_id]) {
88 vol->ref_count += 1;
92 ret = sprintf(buf, "%d\n", vol->reserved_pebs);
96 if (vol->vol_type == UBI_DYNAMIC_VOLUME)
102 ret = sprintf(buf, "%s\n", vol->name);
104 ret = sprintf(buf, "%d\n", vol->corrupted);
106 ret = sprintf(buf, "%d\n", vol->alignment);
108 ret = sprintf(buf, "%d\n", vol->usable_leb_size);
110 ret = sprintf(buf, "%lld\n", vol->used_bytes);
112 ret = sprintf(buf, "%d\n", vol->upd_marker);
119 vol->ref_count -= 1;
120 ubi_assert(vol->ref_count >= 0);
129 struct ubi_volume *vol = container_of(dev, struct ubi_volume, dev);
131 kfree(vol->eba_tbl);
132 kfree(vol);
138 * @vol: volume description object
147 static int volume_sysfs_init(struct ubi_device *ubi, struct ubi_volume *vol)
151 err = device_create_file(&vol->dev, &attr_vol_reserved_ebs);
154 err = device_create_file(&vol->dev, &attr_vol_type);
157 err = device_create_file(&vol->dev, &attr_vol_name);
160 err = device_create_file(&vol->dev, &attr_vol_corrupted);
163 err = device_create_file(&vol->dev, &attr_vol_alignment);
166 err = device_create_file(&vol->dev, &attr_vol_usable_eb_size);
169 err = device_create_file(&vol->dev, &attr_vol_data_bytes);
172 err = device_create_file(&vol->dev, &attr_vol_upd_marker);
178 * @vol: volume description object
180 static void volume_sysfs_close(struct ubi_volume *vol)
182 device_remove_file(&vol->dev, &attr_vol_upd_marker);
183 device_remove_file(&vol->dev, &attr_vol_data_bytes);
184 device_remove_file(&vol->dev, &attr_vol_usable_eb_size);
185 device_remove_file(&vol->dev, &attr_vol_alignment);
186 device_remove_file(&vol->dev, &attr_vol_corrupted);
187 device_remove_file(&vol->dev, &attr_vol_name);
188 device_remove_file(&vol->dev, &attr_vol_type);
189 device_remove_file(&vol->dev, &attr_vol_reserved_ebs);
190 device_unregister(&vol->dev);
207 struct ubi_volume *vol;
214 vol = kzalloc(sizeof(struct ubi_volume), GFP_KERNEL);
215 if (!vol)
257 vol->usable_leb_size = ubi->leb_size - ubi->leb_size % req->alignment;
258 vol->reserved_pebs += div_u64(req->bytes + vol->usable_leb_size - 1,
259 vol->usable_leb_size);
262 if (vol->reserved_pebs > ubi->avail_pebs) {
267 ubi->avail_pebs -= vol->reserved_pebs;
268 ubi->rsvd_pebs += vol->reserved_pebs;
271 vol->vol_id = vol_id;
272 vol->alignment = req->alignment;
273 vol->data_pad = ubi->leb_size % vol->alignment;
274 vol->vol_type = req->vol_type;
275 vol->name_len = req->name_len;
276 memcpy(vol->name, req->name, vol->name_len);
277 vol->ubi = ubi;
287 vol->eba_tbl = kmalloc(vol->reserved_pebs * sizeof(int), GFP_KERNEL);
288 if (!vol->eba_tbl) {
293 for (i = 0; i < vol->reserved_pebs; i++)
294 vol->eba_tbl[i] = UBI_LEB_UNMAPPED;
296 if (vol->vol_type == UBI_DYNAMIC_VOLUME) {
297 vol->used_ebs = vol->reserved_pebs;
298 vol->last_eb_bytes = vol->usable_leb_size;
299 vol->used_bytes =
300 (long long)vol->used_ebs * vol->usable_leb_size;
302 vol->used_ebs = div_u64_rem(vol->used_bytes,
303 vol->usable_leb_size,
304 &vol->last_eb_bytes);
305 if (vol->last_eb_bytes != 0)
306 vol->used_ebs += 1;
308 vol->last_eb_bytes = vol->usable_leb_size;
312 cdev_init(&vol->cdev, &ubi_vol_cdev_operations);
313 vol->cdev.owner = THIS_MODULE;
315 err = cdev_add(&vol->cdev, dev, 1);
321 vol->dev.release = vol_release;
322 vol->dev.parent = &ubi->dev;
323 vol->dev.devt = dev;
324 vol->dev.class = ubi_class;
326 dev_set_name(&vol->dev, "%s_%d", ubi->ubi_name, vol->vol_id);
327 err = device_register(&vol->dev);
333 err = volume_sysfs_init(ubi, vol);
339 vtbl_rec.reserved_pebs = cpu_to_be32(vol->reserved_pebs);
340 vtbl_rec.alignment = cpu_to_be32(vol->alignment);
341 vtbl_rec.data_pad = cpu_to_be32(vol->data_pad);
342 vtbl_rec.name_len = cpu_to_be16(vol->name_len);
343 if (vol->vol_type == UBI_DYNAMIC_VOLUME)
347 memcpy(vtbl_rec.name, vol->name, vol->name_len);
354 ubi->volumes[vol_id] = vol;
358 ubi_volume_notify(ubi, vol, UBI_VOLUME_ADDED);
373 get_device(&vol->dev);
374 volume_sysfs_close(vol);
376 cdev_del(&vol->cdev);
379 kfree(vol->eba_tbl);
382 ubi->rsvd_pebs -= vol->reserved_pebs;
383 ubi->avail_pebs += vol->reserved_pebs;
387 kfree(vol);
389 put_device(&vol->dev);
406 struct ubi_volume *vol = desc->vol;
407 struct ubi_device *ubi = vol->ubi;
408 int i, err, vol_id = vol->vol_id, reserved_pebs = vol->reserved_pebs;
412 ubi_assert(vol == ubi->volumes[vol_id]);
418 if (vol->ref_count > 1) {
435 for (i = 0; i < vol->reserved_pebs; i++) {
436 err = ubi_eba_unmap_leb(ubi, vol, i);
441 cdev_del(&vol->cdev);
442 volume_sysfs_close(vol);
459 ubi_volume_notify(ubi, vol, UBI_VOLUME_REMOVED);
468 ubi->volumes[vol_id] = vol;
486 struct ubi_volume *vol = desc->vol;
487 struct ubi_device *ubi = vol->ubi;
489 int vol_id = vol->vol_id;
495 ubi->ubi_num, vol_id, vol->reserved_pebs, reserved_pebs);
497 if (vol->vol_type == UBI_STATIC_VOLUME &&
498 reserved_pebs < vol->used_ebs) {
500 reserved_pebs, vol->used_ebs);
505 if (reserved_pebs == vol->reserved_pebs)
516 if (vol->ref_count > 1) {
524 pebs = reserved_pebs - vol->reserved_pebs;
536 for (i = 0; i < vol->reserved_pebs; i++)
537 new_mapping[i] = vol->eba_tbl[i];
538 kfree(vol->eba_tbl);
539 vol->eba_tbl = new_mapping;
552 err = ubi_eba_unmap_leb(ubi, vol, reserved_pebs + i);
569 new_mapping[i] = vol->eba_tbl[i];
570 kfree(vol->eba_tbl);
571 vol->eba_tbl = new_mapping;
575 vol->reserved_pebs = reserved_pebs;
576 if (vol->vol_type == UBI_DYNAMIC_VOLUME) {
577 vol->used_ebs = reserved_pebs;
578 vol->last_eb_bytes = vol->usable_leb_size;
579 vol->used_bytes =
580 (long long)vol->used_ebs * vol->usable_leb_size;
583 ubi_volume_notify(ubi, vol, UBI_VOLUME_RESIZED);
624 struct ubi_volume *vol = re->desc->vol;
627 vol->name_len = re->new_name_len;
628 memcpy(vol->name, re->new_name, re->new_name_len + 1);
630 ubi_volume_notify(ubi, vol, UBI_VOLUME_RENAMED);
642 * @vol: volume description object
648 int ubi_add_volume(struct ubi_device *ubi, struct ubi_volume *vol)
650 int err, vol_id = vol->vol_id;
656 cdev_init(&vol->cdev, &ubi_vol_cdev_operations);
657 vol->cdev.owner = THIS_MODULE;
658 dev = MKDEV(MAJOR(ubi->cdev.dev), vol->vol_id + 1);
659 err = cdev_add(&vol->cdev, dev, 1);
666 vol->dev.release = vol_release;
667 vol->dev.parent = &ubi->dev;
668 vol->dev.devt = dev;
669 vol->dev.class = ubi_class;
670 dev_set_name(&vol->dev, "%s_%d", ubi->ubi_name, vol->vol_id);
671 err = device_register(&vol->dev);
675 err = volume_sysfs_init(ubi, vol);
677 cdev_del(&vol->cdev);
678 volume_sysfs_close(vol);
687 cdev_del(&vol->cdev);
694 * @vol: volume description object
696 * This function frees all resources for volume @vol but does not remove it.
699 void ubi_free_volume(struct ubi_device *ubi, struct ubi_volume *vol)
701 dbg_gen("free volume %d", vol->vol_id);
703 ubi->volumes[vol->vol_id] = NULL;
704 cdev_del(&vol->cdev);
705 volume_sysfs_close(vol);
721 const struct ubi_volume *vol;
727 vol = ubi->volumes[idx];
729 if (!vol) {
738 if (vol->reserved_pebs < 0 || vol->alignment < 0 || vol->data_pad < 0 ||
739 vol->name_len < 0) {
743 if (vol->alignment > ubi->leb_size || vol->alignment == 0) {
748 n = vol->alignment & (ubi->min_io_size - 1);
749 if (vol->alignment != 1 && n) {
754 n = ubi->leb_size % vol->alignment;
755 if (vol->data_pad != n) {
760 if (vol->vol_type != UBI_DYNAMIC_VOLUME &&
761 vol->vol_type != UBI_STATIC_VOLUME) {
766 if (vol->upd_marker && vol->corrupted) {
771 if (vol->reserved_pebs > ubi->good_peb_count) {
776 n = ubi->leb_size - vol->data_pad;
777 if (vol->usable_leb_size != ubi->leb_size - vol->data_pad) {
782 if (vol->name_len > UBI_VOL_NAME_MAX) {
787 if (!vol->name) {
792 n = strnlen(vol->name, vol->name_len + 1);
793 if (n != vol->name_len) {
798 n = (long long)vol->used_ebs * vol->usable_leb_size;
799 if (vol->vol_type == UBI_DYNAMIC_VOLUME) {
800 if (vol->corrupted) {
804 if (vol->used_ebs != vol->reserved_pebs) {
808 if (vol->last_eb_bytes != vol->usable_leb_size) {
812 if (vol->used_bytes != n) {
817 if (vol->used_ebs < 0 || vol->used_ebs > vol->reserved_pebs) {
821 if (vol->last_eb_bytes < 0 ||
822 vol->last_eb_bytes > vol->usable_leb_size) {
826 if (vol->used_bytes < 0 || vol->used_bytes > n ||
827 vol->used_bytes < n - vol->usable_leb_size) {
843 if (alignment != vol->alignment || data_pad != vol->data_pad ||
844 upd_marker != vol->upd_marker || vol_type != vol->vol_type ||
845 name_len != vol->name_len || strncmp(name, vol->name, name_len)) {
855 if (vol)
856 ubi_dbg_dump_vol_info(vol);