UBI WL-Subsys: Improvement in prot tree
Subsystems (2)
PATCH 2/4 UBI WL-Subsys: Improvement in prot tree
Quoted 1 line
From
9e4a9b537f4681118fe7472a0f9c3b45a2a54fe0Mon Sep 17 00:00:00 2001
From: Xiaochuan-Xu <[email protected]>
Date: Tue, 9 Dec 2008 19:08:47 +0800
Subject: [PATCH] Improvement in the prot RB tree
In this implement, protection lists are used to replace of the current prot RB-tree. By means of link lists, the new protection mothed is simpler and higher efficient.
Signed-off-by Xiaochuan-Xu <[email protected]>
--- drivers/mtd/ubi/ubi.h | 40 +++++-- drivers/mtd/ubi/wl.c | 330 ++++++++++++++++++++++-------------------------- 2 files changed, 181 insertions(+), 189 deletions(-)
drivers/mtd/ubi/ubi.h +30 -10
@@ -93,9 +93,28 @@ enum { UBI_IO_BITFLIPS }; +/* +* It's impossible that the first field of rb_node structure is equal to 0x2 +* and 0x3, so Ox2 is used to check whether the physical eraseblock is in one +* of prot lists or not. 0x3 is used for prot list head's mark. +*/ +#define PROT_LIST_NODE 0x2 +#define PROT_LIST_HEAD 0x3 + +/** +* struct prot_node - prot link list's node. +* @priv: private data when in prot list +* @list: link one of the prot list node +*/ +struct prot_node { +unsigned long priv; +struct list_head list; +}; +/** * struct ubi_wl_entry - wear-leveling entry. * @u.rb: link in the corresponding (free/used) RB-tree +* @u.prot: node in prot list * @ec: erase counter * @pnum: physical eraseblock number *
@@ -106,6 +125,7 @@ enum {struct ubi_wl_entry {union {struct rb_node rb; +struct prot_node prot; } u;int ec;int pnum;
@@ -308,12 +328,14 @@ struct ubi_wl_entry;* @used: RB-tree of used physical eraseblocks * @free: RB-tree of free physical eraseblocks * @scrub: RB-tree of physical eraseblocks which need scrubbing -* @prot: protection trees -* @prot.pnum: protection tree indexed by physical eraseblock numbers -* @prot.aec: protection tree indexed by absolute erase counter value -* @wl_lock: protects the @used, @free, @prot, @lookuptbl, @abs_ec, @move_from, -* @move_to, @move_to_put @erase_pending, @wl_scheduled, and @works -* fields +* @prot: protection link lists, physical eraseblocks, should be protected, +* are listed by one of its list +* @prot_over: the index of element (list head) in the prot lists, all the +* physical eraseblocks linked should be moved to used RB-tree in +* the next "check_protection_over" operation. +* @wl_lock: protects the @used, @free, @prot, @prot_over, @lookuptbl, +* @move_from, @move_to, @move_to_put @erase_pending, @wl_scheduled +* and @works fields * @move_mutex: serializes eraseblock moves * @work_sem: sycnhronizes the WL worker with use tasks * @wl_scheduled: non-zero if the wear-leveling was scheduled
@@ -394,10 +416,8 @@ struct ubi_device {struct rb_root used;struct rb_root free;struct rb_root scrub; -struct { -struct rb_root pnum; -struct rb_root aec; - } prot; +struct prot_node *prot; +int prot_over;spinlock_t wl_lock;struct mutex move_mutex;struct rw_semaphore work_sem;
drivers/mtd/ubi/wl.c +151 -179
506 lines not on this page · raw message
Signature · 6 lines
1.5.3.2 -- Yours sincerely xiaochuan-xu(cqu.edu.cn)