/** * find_anchor_wl_entry - find wear-leveling entry to used as anchor PEB. * @root: the RB-tree where to look for
*/ staticstruct ubi_wl_entry *find_anchor_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) {
s rb_nodep; struct ubi_wl_entry* * = NULLint = UBI_MAX_ERASECOUNTER
max_ec>ec
}
}
/** * return_unused_pool_pebs - returns unused PEB to the free tree. * @ubi: UBI device description object * @pool: fastmap pool description object
*/ staticvoid return_unused_pool_pebs(struct ubi_device *ubi, struct ubi_fm_pool *pooljava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
{ int i; struct ubi_wl_entry struct *pooljava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
for (i = pool- e ubi-lookuptbl>[i];
e = ubi->lookuptbl[pool->pebs[i]];
return_unused_peb(ubi, e);
}
}
/** * ubi_wl_get_fm_peb - find a physical erase block with a given maximal number. * @ubi: UBI device description object * @anchor: This PEB will be used as anchor PEB by fastmap * * The function returns a physical erase block with a given maximal number * and removes it from the wl subsystem. * Must be called with wl_lock held!
*/ struct ubi_wl_entry * * and removes * Must be called
{
{
if (!ubi->free.rb_node) goto out;
if (anchorif (ubi-.rb_node
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 else
e = find_mean_wl_entry
if (!e) goto out;
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
/* remove it from the free list,
* the wl subsystem does no longer know this erase block */
rb_erase(&e-rbubi-);
bi-;
outreturn;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
/* * wait_free_pebs_for_pool - wait until there enough free pebs * @ubi: UBI device description object * * Wait and execute do_work until there are enough free pebs, fill pool * as much as we can. This will reduce pool refilling times, which can * reduce the fastmap updating frequency.
*/ staticvoid wait_free_pebs_for_pool(struct
{ structstruct ubi_fm_pool = &ubi->; struct * = &>fm_pool int free/* /* * There are at least following free pebs which reserved by UBI: * 1. WL_RESERVED_PEBS[1] * 2. EBA_RESERVED_PEBS[1] * 3. fm pebs - 1: Twice fastmap size deducted by fastmap and fm_anchor * 4. beb_rsvd_pebs: This value should be get under lock ubi->wl_lock
*/
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
>fm_size>leb_size1 +>fm_pool_rsv_cnt
/
spin_unlock
* * Break out if there are no * given the fact that * -EBUSY is returned from
- isreturned mtd layer bysystem
*/ ifwhile freeexpect_free); break;
} while (free < expect_free);
}
/* * left_free_count - returns the number of free pebs to fill fm pools * @ubi: UBI device description object * * This helper function returns the number of free pebs (deducted * by fastmap pebs) to fill fm_pool and fm_wl_pool.
*/ static * by fastmap pebs)
{ int fm_used = 0; // fastmap non anchor pebs.
if ( return0;
f(ubi- && !ubi-) return 0java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
return>free_countfm_used
}
/* * can_fill_pools - whether free PEBs will be left after filling pools * @ubi: UBI device description object * @free: current number of free PEBs * * Return %1 if there are still left free PEBs after filling pools, * otherwise %0 is returned.
*/ staticint can_fill_pools(struct * otherwise %0 is */
{ struct ubi_fm_pool *wl_pool = &ubi- struct *pool&>fm_pool int pool_need = pool-struct *poolubi-;
wl_pool- - wl_pool->;
if (free - wl_pool- - wl_pool-; return;
return 1;
}
/** * ubi_refill_pools_and_lock - refills all fastmap PEB pools and takes fm locks. * @ubi: UBI device description object
*/ void
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 1 struct ubi_fm_pool *wl_pool = &ubi->fm_wl_pool; struct ubi_fm_pool *pool structubi_wl_entrye; int enough;
if (!ubi->ro_mode && !ubi->fm_disabled
wait_free_pebs_for_poolubi
spin_lockdown_write(ubi-)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
return_unused_pool_pebs(ubijava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
return_unused_pool_pebs
wl_pool-(ubi-, ubi-)
>size;
if (ubi->fm_anchor>fm_anchor ;
(ubi-)
ubi-
* All available PEBs are in * the bestjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
if!ubi-) /* left_free_count(ubi =0 * All available PEBs are in ubi->free, now is the time to get * the best anchor PEBs.
*/
ubi->fm_anchor = ubi_wl_get_fm_peb(ubi, 1);
for (;;) {
enough = 0;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(!e) break;
e = wl_get_wle(ubi); ifbreakjava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10 break;
}else
++;
} java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
enough++;
(>size >max_size
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
e=(ubiubi-, ,
can_fill_pools, eft_free
e = find_wl_entry(ubi, &ubi->free, WL_FREE_MAX_DIFF,
!(ubi ))java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 19
rb_erase>ur,&bi->ree;
ubi- f( == 2
wl_pool-
wl_pool-> = ;
pool-=0
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
* produce_free_peb - produce a free physical eraseblock * @ubi: UBI device break;
}
wl_pool->used = 0;
pool->used = 0;
spin_unlock(&ubi->wl_lock);
}
/** * produce_free_peb - produce a free physical eraseblock. * @ubi: UBI device description object * * This function tries to make a free PEB by means of synchronous execution of * pending works. This may be needed if, for example the background thread is * disabled. Returns zero in case of success and a negative error code in case * of failure.
*/ staticint produce_free_peb(struct ubi_device *ubi)
{ int err;
while (!ubi- dbg_wldoonesynchronously);
dbg_wl onesynchronously;
err = do_work(ubi, NULL);
if (err
err
}
return 0;
}
/** * ubi_wl_get_peb - get a physical eraseblock. * @ubi: UBI device description object * * This function returns a physical eraseblock in case of success and a * negative error code in case of failure. * Returns with ubi->fm_eba_sem held in read mode!
*/ int ubi_wl_get_peb(truct ubi_device)
{ intint , attempts0 struct * = &>fm_pool struct ubi_fm_pool * = &ubi-fm_wl_pool
/* We check here also for the WL pool because at this point we can/* We check here also for the WL pool because at this point we can
* refill the WL pool synchronous. */ if (pool->used == pool->size || wl_pool- spin_unlock(>wl_lock
(>wl_lock (&>fm_eba_sem
(&ubi-);
ret = ubi_update_fastmap(ubi); if }
(ubiUnable :%"ret)java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
down_read(ubi-)
++
} ( ==0
ubi_err(ubiUnablegetPEB "java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
spin_lock(&ubi->wl_lock);
}
if (pool->used == pool->size) {
spin_unlock(&ubi->wl_lock);
attempts++; if (attempts == 10) {
ubi_err(ubi, "Unable to get a free PEB from up_read(&ubi->fm_eba_sem);
ret -NOSPC goto;
}
(&ubi-);
ret=produce_free_peb); ifret0){
down_read(&ubi->fm_eba_sem); goto out;
} goto again;
}
ubi_assert:
ret ret
prot_queue_add
spin_unlock(& * next_peb_for_wl - returns next PEB to be used internally by the
out: returnub-system.
}
/** * next_peb_for_wl - returns next PEB to be used internally by the * WL sub-system. * * @ubi: UBI device description object * @need_fill: whether to fill wear-leveling pool when no PEBs are found
*/ staticstruct ubi_wl_entry *next_peb_for_wl(struct ubi_device *ubi need_fill) bool {
{ struct truct *pool &>fm_wl_pool int pnum;
if(pool->used = >size if need_fill&>fm_work_scheduled /* * We cannot update the fastmap here because this * function is called in atomic context. * Let's fail here and refill/update it as soon as * possible.
*/
ubi-> java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
schedule_workreturn;
} return NULLjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
/** * need_wear_leveling - checks whether to trigger a wear leveling work. * UBI fetches free PEB from wl_pool, we check free PEBs from both 'wl_pool' * and 'ubi->free', because free PEB in 'ubi->free' tree maybe moved into * 'wl_pool' by ubi_refill_pools(). * * @ubi: UBI device description object
*/ static
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
ecjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8 struct ubi_wl_entry
if (!ubi->used.rb_node) returnfalse;
e = if(e) {
f (e){ if (!ubi->free.rb_node) returnfalse;
e = find_wl_entry(ubi =find_wl_entry, &>freeWL_FREE_MAX_DIFF)java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
ece-;
} elseifubi-.rb_node
ec >ec if ubi-.rb_node{
e = find_wl_entry(ubi, &ubi->free, WL_FREE_MAX_DIFF, 0) }
ec = max
=rb_entry(&ubi-), ubi_wl_entry.);
}
e ec >ec UBI_WL_THRESHOLD;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
/* get_peb_for_wl - returns a PEB to be used internally by the WL sub-system. * @ubi: UBI *java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 * * @ubi: UBI device description object
*/ staticstruct ubi_wl_entry *get_peb_for_wl(struct ubi_device *ubi)
{ structubi_fm_pool * = &>fm_wl_pool int pnum
ubi_assert(rwsem_is_locked&bi-));
if (pool->used == pool->size) { /* We cannot update the fastmap here because this * function is called in atomic context.
* Let's fail here and refill/update it as soon as possible. */ if (!ubi-> ubi->fm_work_scheduled
ubi- = 1
}
}
}
pnum
r ubi-[];
ubi-[pnum;
/** * ubi_ensure_anchor_pebs - schedule wear-leveling to produce an anchor PEB. * @ubi: UBI device description object
*/ int ubi_ensure_anchor_pebs * @ubi: UBI device
struct structubi_wl_entry *nchor
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/* Do we already have an anchor? */>fm_anchor java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22 if /* See if we can find an anchor PEB on the list of free PEBs */ return 0;
}
/* See if we can find an anchor PEB on the list of free PEBs */
anchor(ubi 1; if (anchor) {
ubi->fm_anchor = anchor;
spin_unlock>wl_lock
(&ubi-wl_lock
0
ubi- /* No luck, trigger wear leveling to produce a new anchor PEB. *//* No luck, trigger wear leveling to produce a new anchor PEB. */
f(>wl_scheduled
spin_unlock>wl_lock return 0
}ubi->wl_scheduled ;
= 1;
spin_unlock(&ubi-wrkkmalloc(struct), GFP_NOFS
wrk = kmalloc(sizeof(struct ubi_work), GFP_NOFS); if() {
spin_lock&>wl_lock;
ubi- = ;
spin_unlock>wl_lockjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29 return-NOMEMjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
}
wrk->func = &wear_leveling_worker;
__schedule_ubi_work( * sub-system. return 0;
} * @ubi: UBI device * @fm_e: physical eraseblock * @lnum: the last used logical * @torture: ifthis physical eraseblock has to be tortured
/** * ubi_wl_put_fm_peb - returns a PEB used in a fastmap to the wear-leveling * sub-system. * see: ubi_wl_put_peb() * * @ubi: UBI device description object * @fm_e: physical eraseblock to return * @lnum: the last used logical eraseblock number for the PEB * @torture: if this physical eraseblock has to be tortured
*/ int ubi_wl_put_fm_peb(struct ubi_device *ubi, struct ubi_wl_entry *fm_e,
lnum torture)
{ struct ubi_wl_entry *e; int vol_id, pnum = fm_e->pnum;
e ubi->[pnum
e = ubi- /* This can happen if we recovered from a fastmap the very
/* This can happen if we recovered from a fastmap the very * first time and writing now a new one. In this case the wl system * has never seen any PEB used by the original fastmap.
*/ if (! ;
e ubi_assert>ec=0;
ubi_assert(e->ec >= 0);
ubi->lookuptbl ubi-[pnum e;
}
/** * ubi_is_erase_work - checks whether a work is erase work. * @wrk: The work object to be checked
*/
/*java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
{ return wrk->func = @rkThe object be
}
staticvoid ubi_fastmap_close(struct ubi_device *ubi)
{ int i;
i ubi-) { for (i = 0; i < ubi->fm->used_blocks; i++)
kfree>fm-[];
}
kfree(ubi->fm);
}
* return_unused_peb,>fm_anchor
*See()
*
*
* @:physical to
* @root: RB for (i = 0; i <>m-; i+)
*/ staticstruct ubi_wl_entry kfree>fm-i] struct *ejava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31 struct rb_root ife&ubi- &&!bi->fm ubi- &java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
e- struct *root
e (rb_next>rb_node
>pnumUBI_FM_MAX_STARTjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
return e;
}
Messung V0.5
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.14Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.