Commit 3d21bb76 authored by Tanya Brokhman's avatar Tanya Brokhman Committed by Artem Bityutskiy

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: default avatarTanya Brokhman <tlinder@codeaurora.org>
Reviewed-by: default avatarDolev Raviv <draviv@codeaurora.org>
Acked-by: default avatarRichard Weinberger <richard@nod.at>
Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
parent 87ed89d2
...@@ -671,6 +671,8 @@ static struct ubi_wl_entry *get_peb_for_wl(struct ubi_device *ubi) ...@@ -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); e = find_wl_entry(ubi, &ubi->free, WL_FREE_MAX_DIFF);
self_check_in_wl_tree(ubi, e, &ubi->free); 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); rb_erase(&e->u.rb, &ubi->free);
return e; return e;
...@@ -1071,6 +1073,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, ...@@ -1071,6 +1073,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
/* Give the unused PEB back */ /* Give the unused PEB back */
wl_tree_add(e2, &ubi->free); wl_tree_add(e2, &ubi->free);
ubi->free_count++;
goto out_cancel; goto out_cancel;
} }
self_check_in_wl_tree(ubi, e1, &ubi->used); self_check_in_wl_tree(ubi, e1, &ubi->used);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment