diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-07-16 10:40:22 -0400 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-07-24 06:34:45 -0400 |
commit | c8566350a3229ca505b84313c65d1403b4d0cbfc (patch) | |
tree | 156309b71de9779948fdab03a2831b41fe6ca159 /drivers/mtd/ubi/vmt.c | |
parent | 85c6e6e28259e9b58b8984db536c45bc3161f40c (diff) |
UBI: fix and re-work debugging stuff
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers/mtd/ubi/vmt.c')
-rw-r--r-- | drivers/mtd/ubi/vmt.c | 73 |
1 files changed, 37 insertions, 36 deletions
diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c index bfa7c5d2e064..2cd886a5adac 100644 --- a/drivers/mtd/ubi/vmt.c +++ b/drivers/mtd/ubi/vmt.c | |||
@@ -28,9 +28,9 @@ | |||
28 | #include "ubi.h" | 28 | #include "ubi.h" |
29 | 29 | ||
30 | #ifdef CONFIG_MTD_UBI_DEBUG_PARANOID | 30 | #ifdef CONFIG_MTD_UBI_DEBUG_PARANOID |
31 | static void paranoid_check_volumes(struct ubi_device *ubi); | 31 | static int paranoid_check_volumes(struct ubi_device *ubi); |
32 | #else | 32 | #else |
33 | #define paranoid_check_volumes(ubi) | 33 | #define paranoid_check_volumes(ubi) 0 |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | static ssize_t vol_attribute_show(struct device *dev, | 36 | static ssize_t vol_attribute_show(struct device *dev, |
@@ -218,7 +218,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req) | |||
218 | spin_lock(&ubi->volumes_lock); | 218 | spin_lock(&ubi->volumes_lock); |
219 | if (vol_id == UBI_VOL_NUM_AUTO) { | 219 | if (vol_id == UBI_VOL_NUM_AUTO) { |
220 | /* Find unused volume ID */ | 220 | /* Find unused volume ID */ |
221 | dbg_msg("search for vacant volume ID"); | 221 | dbg_gen("search for vacant volume ID"); |
222 | for (i = 0; i < ubi->vtbl_slots; i++) | 222 | for (i = 0; i < ubi->vtbl_slots; i++) |
223 | if (!ubi->volumes[i]) { | 223 | if (!ubi->volumes[i]) { |
224 | vol_id = i; | 224 | vol_id = i; |
@@ -233,7 +233,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req) | |||
233 | req->vol_id = vol_id; | 233 | req->vol_id = vol_id; |
234 | } | 234 | } |
235 | 235 | ||
236 | dbg_msg("volume ID %d, %llu bytes, type %d, name %s", | 236 | dbg_gen("volume ID %d, %llu bytes, type %d, name %s", |
237 | vol_id, (unsigned long long)req->bytes, | 237 | vol_id, (unsigned long long)req->bytes, |
238 | (int)req->vol_type, req->name); | 238 | (int)req->vol_type, req->name); |
239 | 239 | ||
@@ -361,8 +361,8 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req) | |||
361 | ubi->vol_count += 1; | 361 | ubi->vol_count += 1; |
362 | spin_unlock(&ubi->volumes_lock); | 362 | spin_unlock(&ubi->volumes_lock); |
363 | 363 | ||
364 | paranoid_check_volumes(ubi); | 364 | err = paranoid_check_volumes(ubi); |
365 | return 0; | 365 | return err; |
366 | 366 | ||
367 | out_sysfs: | 367 | out_sysfs: |
368 | /* | 368 | /* |
@@ -414,7 +414,7 @@ int ubi_remove_volume(struct ubi_volume_desc *desc) | |||
414 | struct ubi_device *ubi = vol->ubi; | 414 | struct ubi_device *ubi = vol->ubi; |
415 | int i, err, vol_id = vol->vol_id, reserved_pebs = vol->reserved_pebs; | 415 | int i, err, vol_id = vol->vol_id, reserved_pebs = vol->reserved_pebs; |
416 | 416 | ||
417 | dbg_msg("remove UBI volume %d", vol_id); | 417 | dbg_gen("remove UBI volume %d", vol_id); |
418 | ubi_assert(desc->mode == UBI_EXCLUSIVE); | 418 | ubi_assert(desc->mode == UBI_EXCLUSIVE); |
419 | ubi_assert(vol == ubi->volumes[vol_id]); | 419 | ubi_assert(vol == ubi->volumes[vol_id]); |
420 | 420 | ||
@@ -465,8 +465,8 @@ int ubi_remove_volume(struct ubi_volume_desc *desc) | |||
465 | ubi->vol_count -= 1; | 465 | ubi->vol_count -= 1; |
466 | spin_unlock(&ubi->volumes_lock); | 466 | spin_unlock(&ubi->volumes_lock); |
467 | 467 | ||
468 | paranoid_check_volumes(ubi); | 468 | err = paranoid_check_volumes(ubi); |
469 | return 0; | 469 | return err; |
470 | 470 | ||
471 | out_err: | 471 | out_err: |
472 | ubi_err("cannot remove volume %d, error %d", vol_id, err); | 472 | ubi_err("cannot remove volume %d, error %d", vol_id, err); |
@@ -497,7 +497,7 @@ int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs) | |||
497 | if (ubi->ro_mode) | 497 | if (ubi->ro_mode) |
498 | return -EROFS; | 498 | return -EROFS; |
499 | 499 | ||
500 | dbg_msg("re-size volume %d to from %d to %d PEBs", | 500 | dbg_gen("re-size volume %d to from %d to %d PEBs", |
501 | vol_id, vol->reserved_pebs, reserved_pebs); | 501 | vol_id, vol->reserved_pebs, reserved_pebs); |
502 | 502 | ||
503 | if (vol->vol_type == UBI_STATIC_VOLUME && | 503 | if (vol->vol_type == UBI_STATIC_VOLUME && |
@@ -586,8 +586,8 @@ int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs) | |||
586 | (long long)vol->used_ebs * vol->usable_leb_size; | 586 | (long long)vol->used_ebs * vol->usable_leb_size; |
587 | } | 587 | } |
588 | 588 | ||
589 | paranoid_check_volumes(ubi); | 589 | err = paranoid_check_volumes(ubi); |
590 | return 0; | 590 | return err; |
591 | 591 | ||
592 | out_acc: | 592 | out_acc: |
593 | if (pebs > 0) { | 593 | if (pebs > 0) { |
@@ -615,8 +615,7 @@ int ubi_add_volume(struct ubi_device *ubi, struct ubi_volume *vol) | |||
615 | int err, vol_id = vol->vol_id; | 615 | int err, vol_id = vol->vol_id; |
616 | dev_t dev; | 616 | dev_t dev; |
617 | 617 | ||
618 | dbg_msg("add volume %d", vol_id); | 618 | dbg_gen("add volume %d", vol_id); |
619 | ubi_dbg_dump_vol_info(vol); | ||
620 | 619 | ||
621 | /* Register character device for the volume */ | 620 | /* Register character device for the volume */ |
622 | cdev_init(&vol->cdev, &ubi_vol_cdev_operations); | 621 | cdev_init(&vol->cdev, &ubi_vol_cdev_operations); |
@@ -650,8 +649,8 @@ int ubi_add_volume(struct ubi_device *ubi, struct ubi_volume *vol) | |||
650 | return err; | 649 | return err; |
651 | } | 650 | } |
652 | 651 | ||
653 | paranoid_check_volumes(ubi); | 652 | err = paranoid_check_volumes(ubi); |
654 | return 0; | 653 | return err; |
655 | 654 | ||
656 | out_gluebi: | 655 | out_gluebi: |
657 | err = ubi_destroy_gluebi(vol); | 656 | err = ubi_destroy_gluebi(vol); |
@@ -672,7 +671,7 @@ void ubi_free_volume(struct ubi_device *ubi, struct ubi_volume *vol) | |||
672 | { | 671 | { |
673 | int err; | 672 | int err; |
674 | 673 | ||
675 | dbg_msg("free volume %d", vol->vol_id); | 674 | dbg_gen("free volume %d", vol->vol_id); |
676 | 675 | ||
677 | ubi->volumes[vol->vol_id] = NULL; | 676 | ubi->volumes[vol->vol_id] = NULL; |
678 | err = ubi_destroy_gluebi(vol); | 677 | err = ubi_destroy_gluebi(vol); |
@@ -686,8 +685,10 @@ void ubi_free_volume(struct ubi_device *ubi, struct ubi_volume *vol) | |||
686 | * paranoid_check_volume - check volume information. | 685 | * paranoid_check_volume - check volume information. |
687 | * @ubi: UBI device description object | 686 | * @ubi: UBI device description object |
688 | * @vol_id: volume ID | 687 | * @vol_id: volume ID |
688 | * | ||
689 | * Returns zero if volume is all right and a a negative error code if not. | ||
689 | */ | 690 | */ |
690 | static void paranoid_check_volume(struct ubi_device *ubi, int vol_id) | 691 | static int paranoid_check_volume(struct ubi_device *ubi, int vol_id) |
691 | { | 692 | { |
692 | int idx = vol_id2idx(ubi, vol_id); | 693 | int idx = vol_id2idx(ubi, vol_id); |
693 | int reserved_pebs, alignment, data_pad, vol_type, name_len, upd_marker; | 694 | int reserved_pebs, alignment, data_pad, vol_type, name_len, upd_marker; |
@@ -705,16 +706,7 @@ static void paranoid_check_volume(struct ubi_device *ubi, int vol_id) | |||
705 | goto fail; | 706 | goto fail; |
706 | } | 707 | } |
707 | spin_unlock(&ubi->volumes_lock); | 708 | spin_unlock(&ubi->volumes_lock); |
708 | return; | 709 | return 0; |
709 | } | ||
710 | |||
711 | if (vol->exclusive) { | ||
712 | /* | ||
713 | * The volume may be being created at the moment, do not check | ||
714 | * it (e.g., it may be in the middle of ubi_create_volume(). | ||
715 | */ | ||
716 | spin_unlock(&ubi->volumes_lock); | ||
717 | return; | ||
718 | } | 710 | } |
719 | 711 | ||
720 | if (vol->reserved_pebs < 0 || vol->alignment < 0 || vol->data_pad < 0 || | 712 | if (vol->reserved_pebs < 0 || vol->alignment < 0 || vol->data_pad < 0 || |
@@ -830,25 +822,34 @@ static void paranoid_check_volume(struct ubi_device *ubi, int vol_id) | |||
830 | } | 822 | } |
831 | 823 | ||
832 | spin_unlock(&ubi->volumes_lock); | 824 | spin_unlock(&ubi->volumes_lock); |
833 | return; | 825 | return 0; |
834 | 826 | ||
835 | fail: | 827 | fail: |
836 | ubi_err("paranoid check failed for volume %d", vol_id); | 828 | ubi_err("paranoid check failed for volume %d", vol_id); |
837 | ubi_dbg_dump_vol_info(vol); | 829 | if (vol) { |
838 | ubi_dbg_dump_vtbl_record(&ubi->vtbl[vol_id], vol_id); | 830 | ubi_dbg_dump_vol_info(vol); |
831 | ubi_dbg_dump_vtbl_record(&ubi->vtbl[vol_id], vol_id); | ||
832 | } | ||
839 | spin_unlock(&ubi->volumes_lock); | 833 | spin_unlock(&ubi->volumes_lock); |
840 | BUG(); | 834 | return -EINVAL; |
841 | } | 835 | } |
842 | 836 | ||
843 | /** | 837 | /** |
844 | * paranoid_check_volumes - check information about all volumes. | 838 | * paranoid_check_volumes - check information about all volumes. |
845 | * @ubi: UBI device description object | 839 | * @ubi: UBI device description object |
840 | * | ||
841 | * Returns zero if volumes are all right and a a negative error code if not. | ||
846 | */ | 842 | */ |
847 | static void paranoid_check_volumes(struct ubi_device *ubi) | 843 | static int paranoid_check_volumes(struct ubi_device *ubi) |
848 | { | 844 | { |
849 | int i; | 845 | int i, err = 0; |
850 | 846 | ||
851 | for (i = 0; i < ubi->vtbl_slots; i++) | 847 | for (i = 0; i < ubi->vtbl_slots; i++) { |
852 | paranoid_check_volume(ubi, i); | 848 | err = paranoid_check_volume(ubi, i); |
849 | if (err) | ||
850 | break; | ||
851 | } | ||
852 | |||
853 | return err; | ||
853 | } | 854 | } |
854 | #endif | 855 | #endif |