Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
5abde384
K
Kernel
项目概览
openeuler
/
Kernel
大约 1 年 前同步成功
通知
6
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5abde384
编写于
9月 13, 2007
作者:
A
Artem Bityutskiy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
UBI: remove useless inlines
Signed-off-by:
N
Artem Bityutskiy
<
Artem.Bityutskiy@nokia.com
>
上级
e8823bd6
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
38 addition
and
81 deletion
+38
-81
drivers/mtd/ubi/wl.c
drivers/mtd/ubi/wl.c
+38
-81
未找到文件。
drivers/mtd/ubi/wl.c
浏览文件 @
5abde384
...
...
@@ -219,17 +219,6 @@ static int paranoid_check_in_wl_tree(struct ubi_wl_entry *e,
/* Slab cache for wear-leveling entries */
static
struct
kmem_cache
*
wl_entries_slab
;
/**
* tree_empty - a helper function to check if an RB-tree is empty.
* @root: the root of the tree
*
* This function returns non-zero if the RB-tree is empty and zero if not.
*/
static
inline
int
tree_empty
(
struct
rb_root
*
root
)
{
return
root
->
rb_node
==
NULL
;
}
/**
* wl_tree_add - add a wear-leveling entry to a WL RB-tree.
* @e: the wear-leveling entry to add
...
...
@@ -266,45 +255,6 @@ static void wl_tree_add(struct ubi_wl_entry *e, struct rb_root *root)
rb_insert_color
(
&
e
->
rb
,
root
);
}
/*
* Helper functions to add and delete wear-leveling entries from different
* trees.
*/
static
void
free_tree_add
(
struct
ubi_device
*
ubi
,
struct
ubi_wl_entry
*
e
)
{
wl_tree_add
(
e
,
&
ubi
->
free
);
}
static
inline
void
used_tree_add
(
struct
ubi_device
*
ubi
,
struct
ubi_wl_entry
*
e
)
{
wl_tree_add
(
e
,
&
ubi
->
used
);
}
static
inline
void
scrub_tree_add
(
struct
ubi_device
*
ubi
,
struct
ubi_wl_entry
*
e
)
{
wl_tree_add
(
e
,
&
ubi
->
scrub
);
}
static
inline
void
free_tree_del
(
struct
ubi_device
*
ubi
,
struct
ubi_wl_entry
*
e
)
{
paranoid_check_in_wl_tree
(
e
,
&
ubi
->
free
);
rb_erase
(
&
e
->
rb
,
&
ubi
->
free
);
}
static
inline
void
used_tree_del
(
struct
ubi_device
*
ubi
,
struct
ubi_wl_entry
*
e
)
{
paranoid_check_in_wl_tree
(
e
,
&
ubi
->
used
);
rb_erase
(
&
e
->
rb
,
&
ubi
->
used
);
}
static
inline
void
scrub_tree_del
(
struct
ubi_device
*
ubi
,
struct
ubi_wl_entry
*
e
)
{
paranoid_check_in_wl_tree
(
e
,
&
ubi
->
scrub
);
rb_erase
(
&
e
->
rb
,
&
ubi
->
scrub
);
}
/**
* do_work - do one pending work.
* @ubi: UBI device description object
...
...
@@ -358,7 +308,7 @@ static int produce_free_peb(struct ubi_device *ubi)
int
err
;
spin_lock
(
&
ubi
->
wl_lock
);
while
(
tree_empty
(
&
ubi
->
free
)
)
{
while
(
!
ubi
->
free
.
rb_node
)
{
spin_unlock
(
&
ubi
->
wl_lock
);
dbg_wl
(
"do one work synchronously"
);
...
...
@@ -514,7 +464,7 @@ int ubi_wl_get_peb(struct ubi_device *ubi, int dtype)
retry:
spin_lock
(
&
ubi
->
wl_lock
);
if
(
tree_empty
(
&
ubi
->
free
)
)
{
if
(
!
ubi
->
free
.
rb_node
)
{
if
(
ubi
->
works_count
==
0
)
{
ubi_assert
(
list_empty
(
&
ubi
->
works
));
ubi_err
(
"no free eraseblocks"
);
...
...
@@ -585,7 +535,8 @@ int ubi_wl_get_peb(struct ubi_device *ubi, int dtype)
* Move the physical eraseblock to the protection trees where it will
* be protected from being moved for some time.
*/
free_tree_del
(
ubi
,
e
);
paranoid_check_in_wl_tree
(
e
,
&
ubi
->
free
);
rb_erase
(
&
e
->
rb
,
&
ubi
->
free
);
prot_tree_add
(
ubi
,
e
,
pe
,
protect
);
dbg_wl
(
"PEB %d EC %d, protection %d"
,
e
->
pnum
,
e
->
ec
,
protect
);
...
...
@@ -704,7 +655,7 @@ static void check_protection_over(struct ubi_device *ubi)
*/
while
(
1
)
{
spin_lock
(
&
ubi
->
wl_lock
);
if
(
tree_empty
(
&
ubi
->
prot
.
aec
)
)
{
if
(
!
ubi
->
prot
.
aec
.
rb_node
)
{
spin_unlock
(
&
ubi
->
wl_lock
);
break
;
}
...
...
@@ -721,7 +672,7 @@ static void check_protection_over(struct ubi_device *ubi)
pe
->
e
->
pnum
,
ubi
->
abs_ec
,
pe
->
abs_ec
);
rb_erase
(
&
pe
->
rb_aec
,
&
ubi
->
prot
.
aec
);
rb_erase
(
&
pe
->
rb_pnum
,
&
ubi
->
prot
.
pnum
);
used_tree_add
(
ubi
,
pe
->
e
);
wl_tree_add
(
pe
->
e
,
&
ubi
->
used
);
spin_unlock
(
&
ubi
->
wl_lock
);
kfree
(
pe
);
...
...
@@ -812,8 +763,8 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
* Only one WL worker at a time is supported at this implementation, so
* make sure a PEB is not being moved already.
*/
if
(
ubi
->
move_to
||
tree_empty
(
&
ubi
->
free
)
||
(
tree_empty
(
&
ubi
->
used
)
&&
tree_empty
(
&
ubi
->
scrub
)
))
{
if
(
ubi
->
move_to
||
!
ubi
->
free
.
rb_node
||
(
!
ubi
->
used
.
rb_node
&&
!
ubi
->
scrub
.
rb_node
))
{
/*
* Only one WL worker at a time is supported at this
* implementation, so if a LEB is already being moved, cancel.
...
...
@@ -828,14 +779,14 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
* triggered again.
*/
dbg_wl
(
"cancel WL, a list is empty: free %d, used %d"
,
tree_empty
(
&
ubi
->
free
),
tree_empty
(
&
ubi
->
used
)
);
!
ubi
->
free
.
rb_node
,
!
ubi
->
used
.
rb_node
);
ubi
->
wl_scheduled
=
0
;
spin_unlock
(
&
ubi
->
wl_lock
);
ubi_free_vid_hdr
(
ubi
,
vid_hdr
);
return
0
;
}
if
(
tree_empty
(
&
ubi
->
scrub
)
)
{
if
(
!
ubi
->
scrub
.
rb_node
)
{
/*
* Now pick the least worn-out used physical eraseblock and a
* highly worn-out free physical eraseblock. If the erase
...
...
@@ -852,17 +803,20 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
ubi_free_vid_hdr
(
ubi
,
vid_hdr
);
return
0
;
}
used_tree_del
(
ubi
,
e1
);
paranoid_check_in_wl_tree
(
e1
,
&
ubi
->
used
);
rb_erase
(
&
e1
->
rb
,
&
ubi
->
used
);
dbg_wl
(
"move PEB %d EC %d to PEB %d EC %d"
,
e1
->
pnum
,
e1
->
ec
,
e2
->
pnum
,
e2
->
ec
);
}
else
{
e1
=
rb_entry
(
rb_first
(
&
ubi
->
scrub
),
struct
ubi_wl_entry
,
rb
);
e2
=
find_wl_entry
(
&
ubi
->
free
,
WL_FREE_MAX_DIFF
);
scrub_tree_del
(
ubi
,
e1
);
paranoid_check_in_wl_tree
(
e1
,
&
ubi
->
scrub
);
rb_erase
(
&
e1
->
rb
,
&
ubi
->
scrub
);
dbg_wl
(
"scrub PEB %d to PEB %d"
,
e1
->
pnum
,
e2
->
pnum
);
}
free_tree_del
(
ubi
,
e2
);
paranoid_check_in_wl_tree
(
e2
,
&
ubi
->
free
);
rb_erase
(
&
e2
->
rb
,
&
ubi
->
free
);
ubi_assert
(
!
ubi
->
move_from
&&
!
ubi
->
move_to
);
ubi_assert
(
!
ubi
->
move_to_put
&&
!
ubi
->
move_from_put
);
ubi
->
move_from
=
e1
;
...
...
@@ -908,7 +862,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
ubi_free_vid_hdr
(
ubi
,
vid_hdr
);
spin_lock
(
&
ubi
->
wl_lock
);
if
(
!
ubi
->
move_to_put
)
used_tree_add
(
ubi
,
e2
);
wl_tree_add
(
e2
,
&
ubi
->
used
);
else
put
=
1
;
ubi
->
move_from
=
ubi
->
move_to
=
NULL
;
...
...
@@ -953,7 +907,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
if
(
ubi
->
move_from_put
)
put
=
1
;
else
used_tree_add
(
ubi
,
e1
);
wl_tree_add
(
e1
,
&
ubi
->
used
);
ubi
->
move_from
=
ubi
->
move_to
=
NULL
;
ubi
->
move_from_put
=
ubi
->
move_to_put
=
0
;
spin_unlock
(
&
ubi
->
wl_lock
);
...
...
@@ -1005,8 +959,8 @@ static int ensure_wear_leveling(struct ubi_device *ubi)
* If the ubi->scrub tree is not empty, scrubbing is needed, and the
* the WL worker has to be scheduled anyway.
*/
if
(
tree_empty
(
&
ubi
->
scrub
)
)
{
if
(
tree_empty
(
&
ubi
->
used
)
||
tree_empty
(
&
ubi
->
free
)
)
if
(
!
ubi
->
scrub
.
rb_node
)
{
if
(
!
ubi
->
used
.
rb_node
||
!
ubi
->
free
.
rb_node
)
/* No physical eraseblocks - no deal */
goto
out_unlock
;
...
...
@@ -1079,7 +1033,7 @@ static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk,
spin_lock
(
&
ubi
->
wl_lock
);
ubi
->
abs_ec
+=
1
;
free_tree_add
(
ubi
,
e
);
wl_tree_add
(
e
,
&
ubi
->
fre
e
);
spin_unlock
(
&
ubi
->
wl_lock
);
/*
...
...
@@ -1212,11 +1166,13 @@ int ubi_wl_put_peb(struct ubi_device *ubi, int pnum, int torture)
spin_unlock
(
&
ubi
->
wl_lock
);
return
0
;
}
else
{
if
(
in_wl_tree
(
e
,
&
ubi
->
used
))
used_tree_del
(
ubi
,
e
);
else
if
(
in_wl_tree
(
e
,
&
ubi
->
scrub
))
scrub_tree_del
(
ubi
,
e
);
else
if
(
in_wl_tree
(
e
,
&
ubi
->
used
))
{
paranoid_check_in_wl_tree
(
e
,
&
ubi
->
used
);
rb_erase
(
&
e
->
rb
,
&
ubi
->
used
);
}
else
if
(
in_wl_tree
(
e
,
&
ubi
->
scrub
))
{
paranoid_check_in_wl_tree
(
e
,
&
ubi
->
scrub
);
rb_erase
(
&
e
->
rb
,
&
ubi
->
scrub
);
}
else
prot_tree_del
(
ubi
,
e
->
pnum
);
}
spin_unlock
(
&
ubi
->
wl_lock
);
...
...
@@ -1224,7 +1180,7 @@ int ubi_wl_put_peb(struct ubi_device *ubi, int pnum, int torture)
err
=
schedule_erase
(
ubi
,
e
,
torture
);
if
(
err
)
{
spin_lock
(
&
ubi
->
wl_lock
);
used_tree_add
(
ubi
,
e
);
wl_tree_add
(
e
,
&
ubi
->
used
);
spin_unlock
(
&
ubi
->
wl_lock
);
}
...
...
@@ -1268,12 +1224,13 @@ int ubi_wl_scrub_peb(struct ubi_device *ubi, int pnum)
goto
retry
;
}
if
(
in_wl_tree
(
e
,
&
ubi
->
used
))
used_tree_del
(
ubi
,
e
);
else
if
(
in_wl_tree
(
e
,
&
ubi
->
used
))
{
paranoid_check_in_wl_tree
(
e
,
&
ubi
->
used
);
rb_erase
(
&
e
->
rb
,
&
ubi
->
used
);
}
else
prot_tree_del
(
ubi
,
pnum
);
scrub_tree_add
(
ubi
,
e
);
wl_tree_add
(
e
,
&
ubi
->
scrub
);
spin_unlock
(
&
ubi
->
wl_lock
);
/*
...
...
@@ -1489,7 +1446,7 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_scan_info *si)
e
->
pnum
=
seb
->
pnum
;
e
->
ec
=
seb
->
ec
;
ubi_assert
(
e
->
ec
>=
0
);
free_tree_add
(
ubi
,
e
);
wl_tree_add
(
e
,
&
ubi
->
fre
e
);
ubi
->
lookuptbl
[
e
->
pnum
]
=
e
;
}
...
...
@@ -1523,16 +1480,16 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_scan_info *si)
if
(
!
seb
->
scrub
)
{
dbg_wl
(
"add PEB %d EC %d to the used tree"
,
e
->
pnum
,
e
->
ec
);
used_tree_add
(
ubi
,
e
);
wl_tree_add
(
e
,
&
ubi
->
used
);
}
else
{
dbg_wl
(
"add PEB %d EC %d to the scrub tree"
,
e
->
pnum
,
e
->
ec
);
scrub_tree_add
(
ubi
,
e
);
wl_tree_add
(
e
,
&
ubi
->
scrub
);
}
}
}
if
(
WL_RESERVED_PEBS
>
ubi
->
avail_pebs
)
{
if
(
ubi
->
avail_pebs
<
WL_RESERVED_PEBS
)
{
ubi_err
(
"no enough physical eraseblocks (%d, need %d)"
,
ubi
->
avail_pebs
,
WL_RESERVED_PEBS
);
goto
out_free
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录