diff options
author | Tanya Brokhman <tlinder@codeaurora.org> | 2014-10-20 12:57:00 -0400 |
---|---|---|
committer | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2014-11-07 05:08:51 -0500 |
commit | 326087033108e7806e24974f2c8271f95cddaf3a (patch) | |
tree | 3da326fd5be824e035f2ffcbddb896892e070039 /drivers/mtd/ubi/vmt.c | |
parent | 789c89935cef776ab5e8b8c5120d9c29a88ab40e (diff) |
UBI: Extend UBI layer debug/messaging capabilities
If there is more then one UBI device mounted, there is no way to
distinguish between messages from different UBI devices.
Add device number to all ubi layer message types.
The R/O block driver messages were replaced by pr_* since
ubi_device structure is not used by it.
Amended a bit by Artem.
Signed-off-by: Tanya Brokhman <tlinder@codeaurora.org>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Diffstat (limited to 'drivers/mtd/ubi/vmt.c')
-rw-r--r-- | drivers/mtd/ubi/vmt.c | 69 |
1 files changed, 36 insertions, 33 deletions
diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c index 8330703c098f..ff4d97848d1c 100644 --- a/drivers/mtd/ubi/vmt.c +++ b/drivers/mtd/ubi/vmt.c | |||
@@ -223,7 +223,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req) | |||
223 | } | 223 | } |
224 | 224 | ||
225 | if (vol_id == UBI_VOL_NUM_AUTO) { | 225 | if (vol_id == UBI_VOL_NUM_AUTO) { |
226 | ubi_err("out of volume IDs"); | 226 | ubi_err(ubi, "out of volume IDs"); |
227 | err = -ENFILE; | 227 | err = -ENFILE; |
228 | goto out_unlock; | 228 | goto out_unlock; |
229 | } | 229 | } |
@@ -237,7 +237,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req) | |||
237 | /* Ensure that this volume does not exist */ | 237 | /* Ensure that this volume does not exist */ |
238 | err = -EEXIST; | 238 | err = -EEXIST; |
239 | if (ubi->volumes[vol_id]) { | 239 | if (ubi->volumes[vol_id]) { |
240 | ubi_err("volume %d already exists", vol_id); | 240 | ubi_err(ubi, "volume %d already exists", vol_id); |
241 | goto out_unlock; | 241 | goto out_unlock; |
242 | } | 242 | } |
243 | 243 | ||
@@ -246,7 +246,8 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req) | |||
246 | if (ubi->volumes[i] && | 246 | if (ubi->volumes[i] && |
247 | ubi->volumes[i]->name_len == req->name_len && | 247 | ubi->volumes[i]->name_len == req->name_len && |
248 | !strcmp(ubi->volumes[i]->name, req->name)) { | 248 | !strcmp(ubi->volumes[i]->name, req->name)) { |
249 | ubi_err("volume \"%s\" exists (ID %d)", req->name, i); | 249 | ubi_err(ubi, "volume \"%s\" exists (ID %d)", |
250 | req->name, i); | ||
250 | goto out_unlock; | 251 | goto out_unlock; |
251 | } | 252 | } |
252 | 253 | ||
@@ -257,9 +258,10 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req) | |||
257 | 258 | ||
258 | /* Reserve physical eraseblocks */ | 259 | /* Reserve physical eraseblocks */ |
259 | if (vol->reserved_pebs > ubi->avail_pebs) { | 260 | if (vol->reserved_pebs > ubi->avail_pebs) { |
260 | ubi_err("not enough PEBs, only %d available", ubi->avail_pebs); | 261 | ubi_err(ubi, "not enough PEBs, only %d available", |
262 | ubi->avail_pebs); | ||
261 | if (ubi->corr_peb_count) | 263 | if (ubi->corr_peb_count) |
262 | ubi_err("%d PEBs are corrupted and not used", | 264 | ubi_err(ubi, "%d PEBs are corrupted and not used", |
263 | ubi->corr_peb_count); | 265 | ubi->corr_peb_count); |
264 | err = -ENOSPC; | 266 | err = -ENOSPC; |
265 | goto out_unlock; | 267 | goto out_unlock; |
@@ -314,7 +316,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req) | |||
314 | dev = MKDEV(MAJOR(ubi->cdev.dev), vol_id + 1); | 316 | dev = MKDEV(MAJOR(ubi->cdev.dev), vol_id + 1); |
315 | err = cdev_add(&vol->cdev, dev, 1); | 317 | err = cdev_add(&vol->cdev, dev, 1); |
316 | if (err) { | 318 | if (err) { |
317 | ubi_err("cannot add character device"); | 319 | ubi_err(ubi, "cannot add character device"); |
318 | goto out_mapping; | 320 | goto out_mapping; |
319 | } | 321 | } |
320 | 322 | ||
@@ -326,7 +328,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req) | |||
326 | dev_set_name(&vol->dev, "%s_%d", ubi->ubi_name, vol->vol_id); | 328 | dev_set_name(&vol->dev, "%s_%d", ubi->ubi_name, vol->vol_id); |
327 | err = device_register(&vol->dev); | 329 | err = device_register(&vol->dev); |
328 | if (err) { | 330 | if (err) { |
329 | ubi_err("cannot register device"); | 331 | ubi_err(ubi, "cannot register device"); |
330 | goto out_cdev; | 332 | goto out_cdev; |
331 | } | 333 | } |
332 | 334 | ||
@@ -386,7 +388,7 @@ out_unlock: | |||
386 | kfree(vol); | 388 | kfree(vol); |
387 | else | 389 | else |
388 | put_device(&vol->dev); | 390 | put_device(&vol->dev); |
389 | ubi_err("cannot create volume %d, error %d", vol_id, err); | 391 | ubi_err(ubi, "cannot create volume %d, error %d", vol_id, err); |
390 | return err; | 392 | return err; |
391 | } | 393 | } |
392 | 394 | ||
@@ -454,7 +456,7 @@ int ubi_remove_volume(struct ubi_volume_desc *desc, int no_vtbl) | |||
454 | return err; | 456 | return err; |
455 | 457 | ||
456 | out_err: | 458 | out_err: |
457 | ubi_err("cannot remove volume %d, error %d", vol_id, err); | 459 | ubi_err(ubi, "cannot remove volume %d, error %d", vol_id, err); |
458 | spin_lock(&ubi->volumes_lock); | 460 | spin_lock(&ubi->volumes_lock); |
459 | ubi->volumes[vol_id] = vol; | 461 | ubi->volumes[vol_id] = vol; |
460 | out_unlock: | 462 | out_unlock: |
@@ -487,7 +489,7 @@ int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs) | |||
487 | 489 | ||
488 | if (vol->vol_type == UBI_STATIC_VOLUME && | 490 | if (vol->vol_type == UBI_STATIC_VOLUME && |
489 | reserved_pebs < vol->used_ebs) { | 491 | reserved_pebs < vol->used_ebs) { |
490 | ubi_err("too small size %d, %d LEBs contain data", | 492 | ubi_err(ubi, "too small size %d, %d LEBs contain data", |
491 | reserved_pebs, vol->used_ebs); | 493 | reserved_pebs, vol->used_ebs); |
492 | return -EINVAL; | 494 | return -EINVAL; |
493 | } | 495 | } |
@@ -516,10 +518,10 @@ int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs) | |||
516 | if (pebs > 0) { | 518 | if (pebs > 0) { |
517 | spin_lock(&ubi->volumes_lock); | 519 | spin_lock(&ubi->volumes_lock); |
518 | if (pebs > ubi->avail_pebs) { | 520 | if (pebs > ubi->avail_pebs) { |
519 | ubi_err("not enough PEBs: requested %d, available %d", | 521 | ubi_err(ubi, "not enough PEBs: requested %d, available %d", |
520 | pebs, ubi->avail_pebs); | 522 | pebs, ubi->avail_pebs); |
521 | if (ubi->corr_peb_count) | 523 | if (ubi->corr_peb_count) |
522 | ubi_err("%d PEBs are corrupted and not used", | 524 | ubi_err(ubi, "%d PEBs are corrupted and not used", |
523 | ubi->corr_peb_count); | 525 | ubi->corr_peb_count); |
524 | spin_unlock(&ubi->volumes_lock); | 526 | spin_unlock(&ubi->volumes_lock); |
525 | err = -ENOSPC; | 527 | err = -ENOSPC; |
@@ -643,7 +645,7 @@ int ubi_add_volume(struct ubi_device *ubi, struct ubi_volume *vol) | |||
643 | dev = MKDEV(MAJOR(ubi->cdev.dev), vol->vol_id + 1); | 645 | dev = MKDEV(MAJOR(ubi->cdev.dev), vol->vol_id + 1); |
644 | err = cdev_add(&vol->cdev, dev, 1); | 646 | err = cdev_add(&vol->cdev, dev, 1); |
645 | if (err) { | 647 | if (err) { |
646 | ubi_err("cannot add character device for volume %d, error %d", | 648 | ubi_err(ubi, "cannot add character device for volume %d, error %d", |
647 | vol_id, err); | 649 | vol_id, err); |
648 | return err; | 650 | return err; |
649 | } | 651 | } |
@@ -710,7 +712,7 @@ static int self_check_volume(struct ubi_device *ubi, int vol_id) | |||
710 | 712 | ||
711 | if (!vol) { | 713 | if (!vol) { |
712 | if (reserved_pebs) { | 714 | if (reserved_pebs) { |
713 | ubi_err("no volume info, but volume exists"); | 715 | ubi_err(ubi, "no volume info, but volume exists"); |
714 | goto fail; | 716 | goto fail; |
715 | } | 717 | } |
716 | spin_unlock(&ubi->volumes_lock); | 718 | spin_unlock(&ubi->volumes_lock); |
@@ -719,90 +721,91 @@ static int self_check_volume(struct ubi_device *ubi, int vol_id) | |||
719 | 721 | ||
720 | if (vol->reserved_pebs < 0 || vol->alignment < 0 || vol->data_pad < 0 || | 722 | if (vol->reserved_pebs < 0 || vol->alignment < 0 || vol->data_pad < 0 || |
721 | vol->name_len < 0) { | 723 | vol->name_len < 0) { |
722 | ubi_err("negative values"); | 724 | ubi_err(ubi, "negative values"); |
723 | goto fail; | 725 | goto fail; |
724 | } | 726 | } |
725 | if (vol->alignment > ubi->leb_size || vol->alignment == 0) { | 727 | if (vol->alignment > ubi->leb_size || vol->alignment == 0) { |
726 | ubi_err("bad alignment"); | 728 | ubi_err(ubi, "bad alignment"); |
727 | goto fail; | 729 | goto fail; |
728 | } | 730 | } |
729 | 731 | ||
730 | n = vol->alignment & (ubi->min_io_size - 1); | 732 | n = vol->alignment & (ubi->min_io_size - 1); |
731 | if (vol->alignment != 1 && n) { | 733 | if (vol->alignment != 1 && n) { |
732 | ubi_err("alignment is not multiple of min I/O unit"); | 734 | ubi_err(ubi, "alignment is not multiple of min I/O unit"); |
733 | goto fail; | 735 | goto fail; |
734 | } | 736 | } |
735 | 737 | ||
736 | n = ubi->leb_size % vol->alignment; | 738 | n = ubi->leb_size % vol->alignment; |
737 | if (vol->data_pad != n) { | 739 | if (vol->data_pad != n) { |
738 | ubi_err("bad data_pad, has to be %lld", n); | 740 | ubi_err(ubi, "bad data_pad, has to be %lld", n); |
739 | goto fail; | 741 | goto fail; |
740 | } | 742 | } |
741 | 743 | ||
742 | if (vol->vol_type != UBI_DYNAMIC_VOLUME && | 744 | if (vol->vol_type != UBI_DYNAMIC_VOLUME && |
743 | vol->vol_type != UBI_STATIC_VOLUME) { | 745 | vol->vol_type != UBI_STATIC_VOLUME) { |
744 | ubi_err("bad vol_type"); | 746 | ubi_err(ubi, "bad vol_type"); |
745 | goto fail; | 747 | goto fail; |
746 | } | 748 | } |
747 | 749 | ||
748 | if (vol->upd_marker && vol->corrupted) { | 750 | if (vol->upd_marker && vol->corrupted) { |
749 | ubi_err("update marker and corrupted simultaneously"); | 751 | ubi_err(ubi, "update marker and corrupted simultaneously"); |
750 | goto fail; | 752 | goto fail; |
751 | } | 753 | } |
752 | 754 | ||
753 | if (vol->reserved_pebs > ubi->good_peb_count) { | 755 | if (vol->reserved_pebs > ubi->good_peb_count) { |
754 | ubi_err("too large reserved_pebs"); | 756 | ubi_err(ubi, "too large reserved_pebs"); |
755 | goto fail; | 757 | goto fail; |
756 | } | 758 | } |
757 | 759 | ||
758 | n = ubi->leb_size - vol->data_pad; | 760 | n = ubi->leb_size - vol->data_pad; |
759 | if (vol->usable_leb_size != ubi->leb_size - vol->data_pad) { | 761 | if (vol->usable_leb_size != ubi->leb_size - vol->data_pad) { |
760 | ubi_err("bad usable_leb_size, has to be %lld", n); | 762 | ubi_err(ubi, "bad usable_leb_size, has to be %lld", n); |
761 | goto fail; | 763 | goto fail; |
762 | } | 764 | } |
763 | 765 | ||
764 | if (vol->name_len > UBI_VOL_NAME_MAX) { | 766 | if (vol->name_len > UBI_VOL_NAME_MAX) { |
765 | ubi_err("too long volume name, max is %d", UBI_VOL_NAME_MAX); | 767 | ubi_err(ubi, "too long volume name, max is %d", |
768 | UBI_VOL_NAME_MAX); | ||
766 | goto fail; | 769 | goto fail; |
767 | } | 770 | } |
768 | 771 | ||
769 | n = strnlen(vol->name, vol->name_len + 1); | 772 | n = strnlen(vol->name, vol->name_len + 1); |
770 | if (n != vol->name_len) { | 773 | if (n != vol->name_len) { |
771 | ubi_err("bad name_len %lld", n); | 774 | ubi_err(ubi, "bad name_len %lld", n); |
772 | goto fail; | 775 | goto fail; |
773 | } | 776 | } |
774 | 777 | ||
775 | n = (long long)vol->used_ebs * vol->usable_leb_size; | 778 | n = (long long)vol->used_ebs * vol->usable_leb_size; |
776 | if (vol->vol_type == UBI_DYNAMIC_VOLUME) { | 779 | if (vol->vol_type == UBI_DYNAMIC_VOLUME) { |
777 | if (vol->corrupted) { | 780 | if (vol->corrupted) { |
778 | ubi_err("corrupted dynamic volume"); | 781 | ubi_err(ubi, "corrupted dynamic volume"); |
779 | goto fail; | 782 | goto fail; |
780 | } | 783 | } |
781 | if (vol->used_ebs != vol->reserved_pebs) { | 784 | if (vol->used_ebs != vol->reserved_pebs) { |
782 | ubi_err("bad used_ebs"); | 785 | ubi_err(ubi, "bad used_ebs"); |
783 | goto fail; | 786 | goto fail; |
784 | } | 787 | } |
785 | if (vol->last_eb_bytes != vol->usable_leb_size) { | 788 | if (vol->last_eb_bytes != vol->usable_leb_size) { |
786 | ubi_err("bad last_eb_bytes"); | 789 | ubi_err(ubi, "bad last_eb_bytes"); |
787 | goto fail; | 790 | goto fail; |
788 | } | 791 | } |
789 | if (vol->used_bytes != n) { | 792 | if (vol->used_bytes != n) { |
790 | ubi_err("bad used_bytes"); | 793 | ubi_err(ubi, "bad used_bytes"); |
791 | goto fail; | 794 | goto fail; |
792 | } | 795 | } |
793 | } else { | 796 | } else { |
794 | if (vol->used_ebs < 0 || vol->used_ebs > vol->reserved_pebs) { | 797 | if (vol->used_ebs < 0 || vol->used_ebs > vol->reserved_pebs) { |
795 | ubi_err("bad used_ebs"); | 798 | ubi_err(ubi, "bad used_ebs"); |
796 | goto fail; | 799 | goto fail; |
797 | } | 800 | } |
798 | if (vol->last_eb_bytes < 0 || | 801 | if (vol->last_eb_bytes < 0 || |
799 | vol->last_eb_bytes > vol->usable_leb_size) { | 802 | vol->last_eb_bytes > vol->usable_leb_size) { |
800 | ubi_err("bad last_eb_bytes"); | 803 | ubi_err(ubi, "bad last_eb_bytes"); |
801 | goto fail; | 804 | goto fail; |
802 | } | 805 | } |
803 | if (vol->used_bytes < 0 || vol->used_bytes > n || | 806 | if (vol->used_bytes < 0 || vol->used_bytes > n || |
804 | vol->used_bytes < n - vol->usable_leb_size) { | 807 | vol->used_bytes < n - vol->usable_leb_size) { |
805 | ubi_err("bad used_bytes"); | 808 | ubi_err(ubi, "bad used_bytes"); |
806 | goto fail; | 809 | goto fail; |
807 | } | 810 | } |
808 | } | 811 | } |
@@ -820,7 +823,7 @@ static int self_check_volume(struct ubi_device *ubi, int vol_id) | |||
820 | if (alignment != vol->alignment || data_pad != vol->data_pad || | 823 | if (alignment != vol->alignment || data_pad != vol->data_pad || |
821 | upd_marker != vol->upd_marker || vol_type != vol->vol_type || | 824 | upd_marker != vol->upd_marker || vol_type != vol->vol_type || |
822 | name_len != vol->name_len || strncmp(name, vol->name, name_len)) { | 825 | name_len != vol->name_len || strncmp(name, vol->name, name_len)) { |
823 | ubi_err("volume info is different"); | 826 | ubi_err(ubi, "volume info is different"); |
824 | goto fail; | 827 | goto fail; |
825 | } | 828 | } |
826 | 829 | ||
@@ -828,7 +831,7 @@ static int self_check_volume(struct ubi_device *ubi, int vol_id) | |||
828 | return 0; | 831 | return 0; |
829 | 832 | ||
830 | fail: | 833 | fail: |
831 | ubi_err("self-check failed for volume %d", vol_id); | 834 | ubi_err(ubi, "self-check failed for volume %d", vol_id); |
832 | if (vol) | 835 | if (vol) |
833 | ubi_dump_vol_info(vol); | 836 | ubi_dump_vol_info(vol); |
834 | ubi_dump_vtbl_record(&ubi->vtbl[vol_id], vol_id); | 837 | ubi_dump_vtbl_record(&ubi->vtbl[vol_id], vol_id); |