From: Tanya Brokhman Date: Tue, 1 Apr 2014 08:02:07 +0000 (+0300) Subject: UBI: fix ubi free PEBs count calculation X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3d21bb7667c4b57a15077d60d23385d9a1c01d08;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git UBI: fix ubi free PEBs count calculation The ubi->free_count should be updated with every insert/remove to/from the ubi->free list. Signed-off-by: Tanya Brokhman Reviewed-by: Dolev Raviv Acked-by: Richard Weinberger Signed-off-by: Artem Bityutskiy --- diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c index 457ead32105c..0f3425dac910 100644 --- a/drivers/mtd/ubi/wl.c +++ b/drivers/mtd/ubi/wl.c @@ -671,6 +671,8 @@ static struct ubi_wl_entry *get_peb_for_wl(struct ubi_device *ubi) e = find_wl_entry(ubi, &ubi->free, WL_FREE_MAX_DIFF); self_check_in_wl_tree(ubi, e, &ubi->free); + ubi->free_count--; + ubi_assert(ubi->free_count >= 0); rb_erase(&e->u.rb, &ubi->free); return e; @@ -1071,6 +1073,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, /* Give the unused PEB back */ wl_tree_add(e2, &ubi->free); + ubi->free_count++; goto out_cancel; } self_check_in_wl_tree(ubi, e1, &ubi->used);