[PATCH 12/21] UBI: Fastmap: Handle unused "used" PEBs better

Richard Weinberger richard at nod.at
Wed Jun 13 06:42:09 EDT 2012


If fastmap detects that some PEBs in the used list are no longer
used it has to erase them.

Signed-off-by: Richard Weinberger <richard at nod.at>
---
 drivers/mtd/ubi/fastmap.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
index 20b016e..1c2e906 100644
--- a/drivers/mtd/ubi/fastmap.c
+++ b/drivers/mtd/ubi/fastmap.c
@@ -712,6 +712,13 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
 	if (max_sqnum > ai->max_sqnum)
 		ai->max_sqnum = max_sqnum;
 
+	list_for_each_entry_safe(tmp_aeb, _tmp_aeb, &used, u.list) {
+		list_del(&tmp_aeb->u.list);
+		dbg_bld("adding PEB from used to erase list: %i", tmp_aeb->pnum);
+		add_aeb(ai, &ai->erase, tmp_aeb->pnum, tmp_aeb->ec, 0);
+		kmem_cache_free(ai->aeb_slab_cache, tmp_aeb);
+	}
+
 	return 0;
 
 fail_bad:
-- 
1.7.6.5




More information about the linux-mtd mailing list