aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2007-06-18 09:29:30 -0400
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2007-07-18 09:56:05 -0400
commitb89044bfa06e8a9a82094fda031cc6d4e8d4a0b0 (patch)
tree596493157a385142b71c9da111d841b8a14150bc /drivers/mtd
parent94784d916458d51043ba76849b9beaf330baef2f (diff)
UBI: fix debugging stuff
Do not check volumes which are currently in use because thay may be in inconsistent state. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/ubi/vmt.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c
index a0c6e1e6d465..d62dac90e108 100644
--- a/drivers/mtd/ubi/vmt.c
+++ b/drivers/mtd/ubi/vmt.c
@@ -644,21 +644,33 @@ void ubi_free_volume(struct ubi_device *ubi, int vol_id)
644 * @ubi: UBI device description object 644 * @ubi: UBI device description object
645 * @vol_id: volume ID 645 * @vol_id: volume ID
646 */ 646 */
647static void paranoid_check_volume(const struct ubi_device *ubi, int vol_id) 647static void paranoid_check_volume(struct ubi_device *ubi, int vol_id)
648{ 648{
649 int idx = vol_id2idx(ubi, vol_id); 649 int idx = vol_id2idx(ubi, vol_id);
650 int reserved_pebs, alignment, data_pad, vol_type, name_len, upd_marker; 650 int reserved_pebs, alignment, data_pad, vol_type, name_len, upd_marker;
651 const struct ubi_volume *vol = ubi->volumes[idx]; 651 const struct ubi_volume *vol;
652 long long n; 652 long long n;
653 const char *name; 653 const char *name;
654 654
655 spin_lock(&ubi->volumes_lock);
655 reserved_pebs = be32_to_cpu(ubi->vtbl[vol_id].reserved_pebs); 656 reserved_pebs = be32_to_cpu(ubi->vtbl[vol_id].reserved_pebs);
657 vol = ubi->volumes[idx];
656 658
657 if (!vol) { 659 if (!vol) {
658 if (reserved_pebs) { 660 if (reserved_pebs) {
659 ubi_err("no volume info, but volume exists"); 661 ubi_err("no volume info, but volume exists");
660 goto fail; 662 goto fail;
661 } 663 }
664 spin_unlock(&ubi->volumes_lock);
665 return;
666 }
667
668 if (vol->exclusive) {
669 /*
670 * The volume may be being created at the moment, do not check
671 * it (e.g., it may be in the middle of ubi_create_volume().
672 */
673 spin_unlock(&ubi->volumes_lock);
662 return; 674 return;
663 } 675 }
664 676
@@ -783,12 +795,14 @@ static void paranoid_check_volume(const struct ubi_device *ubi, int vol_id)
783 goto fail; 795 goto fail;
784 } 796 }
785 797
798 spin_unlock(&ubi->volumes_lock);
786 return; 799 return;
787 800
788fail: 801fail:
789 ubi_err("paranoid check failed for volume %d", vol_id); 802 ubi_err("paranoid check failed for volume %d", vol_id);
790 ubi_dbg_dump_vol_info(vol); 803 ubi_dbg_dump_vol_info(vol);
791 ubi_dbg_dump_vtbl_record(&ubi->vtbl[vol_id], vol_id); 804 ubi_dbg_dump_vtbl_record(&ubi->vtbl[vol_id], vol_id);
805 spin_unlock(&ubi->volumes_lock);
792 BUG(); 806 BUG();
793} 807}
794 808
@@ -801,10 +815,8 @@ static void paranoid_check_volumes(struct ubi_device *ubi)
801 int i; 815 int i;
802 816
803 mutex_lock(&ubi->vtbl_mutex); 817 mutex_lock(&ubi->vtbl_mutex);
804 spin_lock(&ubi->volumes_lock);
805 for (i = 0; i < ubi->vtbl_slots; i++) 818 for (i = 0; i < ubi->vtbl_slots; i++)
806 paranoid_check_volume(ubi, i); 819 paranoid_check_volume(ubi, i);
807 spin_unlock(&ubi->volumes_lock);
808 mutex_unlock(&ubi->vtbl_mutex); 820 mutex_unlock(&ubi->vtbl_mutex);
809} 821}
810#endif 822#endif