aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/vtbl.c
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/mtd/ubi/vtbl.c
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'drivers/mtd/ubi/vtbl.c')
-rw-r--r--drivers/mtd/ubi/vtbl.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
index 14c10bed94ee..fd3bf770f518 100644
--- a/drivers/mtd/ubi/vtbl.c
+++ b/drivers/mtd/ubi/vtbl.c
@@ -62,7 +62,7 @@
62#include <asm/div64.h> 62#include <asm/div64.h>
63#include "ubi.h" 63#include "ubi.h"
64 64
65#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID 65#ifdef CONFIG_MTD_UBI_DEBUG
66static void paranoid_vtbl_check(const struct ubi_device *ubi); 66static void paranoid_vtbl_check(const struct ubi_device *ubi);
67#else 67#else
68#define paranoid_vtbl_check(ubi) 68#define paranoid_vtbl_check(ubi)
@@ -366,7 +366,7 @@ write_error:
366 * Probably this physical eraseblock went bad, try to pick 366 * Probably this physical eraseblock went bad, try to pick
367 * another one. 367 * another one.
368 */ 368 */
369 list_add_tail(&new_seb->u.list, &si->corr); 369 list_add(&new_seb->u.list, &si->erase);
370 goto retry; 370 goto retry;
371 } 371 }
372 kfree(new_seb); 372 kfree(new_seb);
@@ -425,12 +425,11 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi,
425 425
426 /* Read both LEB 0 and LEB 1 into memory */ 426 /* Read both LEB 0 and LEB 1 into memory */
427 ubi_rb_for_each_entry(rb, seb, &sv->root, u.rb) { 427 ubi_rb_for_each_entry(rb, seb, &sv->root, u.rb) {
428 leb[seb->lnum] = vmalloc(ubi->vtbl_size); 428 leb[seb->lnum] = vzalloc(ubi->vtbl_size);
429 if (!leb[seb->lnum]) { 429 if (!leb[seb->lnum]) {
430 err = -ENOMEM; 430 err = -ENOMEM;
431 goto out_free; 431 goto out_free;
432 } 432 }
433 memset(leb[seb->lnum], 0, ubi->vtbl_size);
434 433
435 err = ubi_io_read_data(ubi, leb[seb->lnum], seb->pnum, 0, 434 err = ubi_io_read_data(ubi, leb[seb->lnum], seb->pnum, 0,
436 ubi->vtbl_size); 435 ubi->vtbl_size);
@@ -516,10 +515,9 @@ static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi,
516 int i; 515 int i;
517 struct ubi_vtbl_record *vtbl; 516 struct ubi_vtbl_record *vtbl;
518 517
519 vtbl = vmalloc(ubi->vtbl_size); 518 vtbl = vzalloc(ubi->vtbl_size);
520 if (!vtbl) 519 if (!vtbl)
521 return ERR_PTR(-ENOMEM); 520 return ERR_PTR(-ENOMEM);
522 memset(vtbl, 0, ubi->vtbl_size);
523 521
524 for (i = 0; i < ubi->vtbl_slots; i++) 522 for (i = 0; i < ubi->vtbl_slots; i++)
525 memcpy(&vtbl[i], &empty_vtbl_record, UBI_VTBL_RECORD_SIZE); 523 memcpy(&vtbl[i], &empty_vtbl_record, UBI_VTBL_RECORD_SIZE);
@@ -662,9 +660,13 @@ static int init_volumes(struct ubi_device *ubi, const struct ubi_scan_info *si,
662 ubi->vol_count += 1; 660 ubi->vol_count += 1;
663 vol->ubi = ubi; 661 vol->ubi = ubi;
664 662
665 if (reserved_pebs > ubi->avail_pebs) 663 if (reserved_pebs > ubi->avail_pebs) {
666 ubi_err("not enough PEBs, required %d, available %d", 664 ubi_err("not enough PEBs, required %d, available %d",
667 reserved_pebs, ubi->avail_pebs); 665 reserved_pebs, ubi->avail_pebs);
666 if (ubi->corr_peb_count)
667 ubi_err("%d PEBs are corrupted and not used",
668 ubi->corr_peb_count);
669 }
668 ubi->rsvd_pebs += reserved_pebs; 670 ubi->rsvd_pebs += reserved_pebs;
669 ubi->avail_pebs -= reserved_pebs; 671 ubi->avail_pebs -= reserved_pebs;
670 672
@@ -837,7 +839,7 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_scan_info *si)
837 return PTR_ERR(ubi->vtbl); 839 return PTR_ERR(ubi->vtbl);
838 } 840 }
839 841
840 ubi->avail_pebs = ubi->good_peb_count; 842 ubi->avail_pebs = ubi->good_peb_count - ubi->corr_peb_count;
841 843
842 /* 844 /*
843 * The layout volume is OK, initialize the corresponding in-RAM data 845 * The layout volume is OK, initialize the corresponding in-RAM data
@@ -866,7 +868,7 @@ out_free:
866 return err; 868 return err;
867} 869}
868 870
869#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID 871#ifdef CONFIG_MTD_UBI_DEBUG
870 872
871/** 873/**
872 * paranoid_vtbl_check - check volume table. 874 * paranoid_vtbl_check - check volume table.
@@ -874,10 +876,13 @@ out_free:
874 */ 876 */
875static void paranoid_vtbl_check(const struct ubi_device *ubi) 877static void paranoid_vtbl_check(const struct ubi_device *ubi)
876{ 878{
879 if (!(ubi_chk_flags & UBI_CHK_GEN))
880 return;
881
877 if (vtbl_check(ubi, ubi->vtbl)) { 882 if (vtbl_check(ubi, ubi->vtbl)) {
878 ubi_err("paranoid check failed"); 883 ubi_err("paranoid check failed");
879 BUG(); 884 BUG();
880 } 885 }
881} 886}
882 887
883#endif /* CONFIG_MTD_UBI_DEBUG_PARANOID */ 888#endif /* CONFIG_MTD_UBI_DEBUG */