Skip to content

Commit 8ff4e62

Browse files
Zhihao Chengrichardweinberger
authored andcommitted
ubi: fastmap: Use free pebs reserved for bad block handling
If new bad PEBs occur, UBI firstly consumes ubi->beb_rsvd_pebs, and then ubi->avail_pebs, finally UBI becomes read-only if above two items are 0, which means that the amount of PEBs for user volumes is not effected. Besides, UBI reserves count of free PBEs is ubi->beb_rsvd_pebs while filling wl pool or getting free PEBs, but ubi->avail_pebs is not reserved. So ubi->beb_rsvd_pebs and ubi->avail_pebs have nothing to do with the usage of free PEBs, UBI can use all free PEBs. Commit 78d6d49 ("UBI: Move fastmap specific functions out of wl.c") has removed beb_rsvd_pebs checking while filling pool. Now, don't reserve ubi->beb_rsvd_pebs while filling wl_pool. This will fill more PEBs in pool and also reduce fastmap updating frequency. Also remove beb_rsvd_pebs checking in ubi_wl_get_fm_peb. Link: https://bugzilla.kernel.org/show_bug.cgi?id=217787 Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: Richard Weinberger <richard@nod.at>
1 parent c19286d commit 8ff4e62

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

drivers/mtd/ubi/fastmap-wl.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ struct ubi_wl_entry *ubi_wl_get_fm_peb(struct ubi_device *ubi, int anchor)
7676
{
7777
struct ubi_wl_entry *e = NULL;
7878

79-
if (!ubi->free.rb_node || (ubi->free_count - ubi->beb_rsvd_pebs < 1))
79+
if (!ubi->free.rb_node)
8080
goto out;
8181

8282
if (anchor)
@@ -100,28 +100,22 @@ struct ubi_wl_entry *ubi_wl_get_fm_peb(struct ubi_device *ubi, int anchor)
100100
/*
101101
* has_enough_free_count - whether ubi has enough free pebs to fill fm pools
102102
* @ubi: UBI device description object
103-
* @is_wl_pool: whether UBI is filling wear leveling pool
104103
*
105104
* This helper function checks whether there are enough free pebs (deducted
106105
* by fastmap pebs) to fill fm_pool and fm_wl_pool, above rule works after
107106
* there is at least one of free pebs is filled into fm_wl_pool.
108-
* For wear leveling pool, UBI should also reserve free pebs for bad pebs
109-
* handling, because there maybe no enough free pebs for user volumes after
110-
* producing new bad pebs.
111107
*/
112-
static bool has_enough_free_count(struct ubi_device *ubi, bool is_wl_pool)
108+
static bool has_enough_free_count(struct ubi_device *ubi)
113109
{
114110
int fm_used = 0; // fastmap non anchor pebs.
115-
int beb_rsvd_pebs;
116111

117112
if (!ubi->free.rb_node)
118113
return false;
119114

120-
beb_rsvd_pebs = is_wl_pool ? ubi->beb_rsvd_pebs : 0;
121115
if (ubi->fm_wl_pool.size > 0 && !(ubi->ro_mode || ubi->fm_disabled))
122116
fm_used = ubi->fm_size / ubi->leb_size - 1;
123117

124-
return ubi->free_count - beb_rsvd_pebs > fm_used;
118+
return ubi->free_count > fm_used;
125119
}
126120

127121
/**
@@ -159,7 +153,7 @@ void ubi_refill_pools(struct ubi_device *ubi)
159153
for (;;) {
160154
enough = 0;
161155
if (pool->size < pool->max_size) {
162-
if (!has_enough_free_count(ubi, false))
156+
if (!has_enough_free_count(ubi))
163157
break;
164158

165159
e = wl_get_wle(ubi);
@@ -172,7 +166,7 @@ void ubi_refill_pools(struct ubi_device *ubi)
172166
enough++;
173167

174168
if (wl_pool->size < wl_pool->max_size) {
175-
if (!has_enough_free_count(ubi, true))
169+
if (!has_enough_free_count(ubi))
176170
break;
177171

178172
e = find_wl_entry(ubi, &ubi->free, WL_FREE_MAX_DIFF);

0 commit comments

Comments
 (0)