Patchwork [01/21] UBI: Fastmap: enhance find_early_wl_entry()

login
register
mail settings
Submitter Richard Weinberger
Date June 13, 2012, 10:41 a.m.
Message ID <1339584138-69914-2-git-send-email-richard@nod.at>
Download mbox | patch
Permalink /patch/164619/
State New
Headers show

Comments

Richard Weinberger - June 13, 2012, 10:41 a.m.
Select always the PEB with the lowest pnum and ec.

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

Patch

diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 2325d3d..8f6321a 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -418,11 +418,13 @@  static struct ubi_wl_entry *find_early_wl_entry(struct rb_root *root,
 {
 	struct rb_node *p;
 	struct ubi_wl_entry *e, *victim = NULL;
+	int max_ec = UBI_MAX_ERASECOUNTER;
 
 	ubi_rb_for_each_entry(p, e, root, u.rb) {
-		if (e->pnum < max_pnum) {
+		if (e->pnum < max_pnum && e->ec < max_ec) {
 			victim = e;
 			max_pnum = e->pnum;
+			max_ec = e->ec;
 		}
 	}