Lines Matching refs:e
127 struct ubi_wl_entry *e, struct rb_root *root);
129 struct ubi_wl_entry *e);
139 static void wl_tree_add(struct ubi_wl_entry *e, struct rb_root *root) in wl_tree_add() argument
150 if (e->ec < e1->ec) in wl_tree_add()
152 else if (e->ec > e1->ec) in wl_tree_add()
155 ubi_assert(e->pnum != e1->pnum); in wl_tree_add()
156 if (e->pnum < e1->pnum) in wl_tree_add()
163 rb_link_node(&e->u.rb, parent, p); in wl_tree_add()
164 rb_insert_color(&e->u.rb, root); in wl_tree_add()
175 static void wl_entry_destroy(struct ubi_device *ubi, struct ubi_wl_entry *e) in wl_entry_destroy() argument
177 ubi->lookuptbl[e->pnum] = NULL; in wl_entry_destroy()
178 kmem_cache_free(ubi_wl_entry_slab, e); in wl_entry_destroy()
236 static int in_wl_tree(struct ubi_wl_entry *e, struct rb_root *root) in in_wl_tree() argument
246 if (e->pnum == e1->pnum) { in in_wl_tree()
247 ubi_assert(e == e1); in in_wl_tree()
251 if (e->ec < e1->ec) in in_wl_tree()
253 else if (e->ec > e1->ec) in in_wl_tree()
256 ubi_assert(e->pnum != e1->pnum); in in_wl_tree()
257 if (e->pnum < e1->pnum) in in_wl_tree()
275 static inline int in_pq(const struct ubi_device *ubi, struct ubi_wl_entry *e) in in_pq() argument
282 if (p == e) in in_pq()
298 static void prot_queue_add(struct ubi_device *ubi, struct ubi_wl_entry *e) in prot_queue_add() argument
305 list_add_tail(&e->u.list, &ubi->pq[pq_tail]); in prot_queue_add()
306 dbg_wl("added PEB %d EC %d to the protection queue", e->pnum, e->ec); in prot_queue_add()
322 struct ubi_wl_entry *e; in find_wl_entry() local
325 e = rb_entry(rb_first(root), struct ubi_wl_entry, u.rb); in find_wl_entry()
326 max = e->ec + diff; in find_wl_entry()
337 e = e1; in find_wl_entry()
341 return e; in find_wl_entry()
356 struct ubi_wl_entry *e, *first, *last; in find_mean_wl_entry() local
362 e = rb_entry(root->rb_node, struct ubi_wl_entry, u.rb); in find_mean_wl_entry()
367 e = may_reserve_for_fm(ubi, e, root); in find_mean_wl_entry()
369 e = find_wl_entry(ubi, root, WL_FREE_MAX_DIFF/2); in find_mean_wl_entry()
371 return e; in find_mean_wl_entry()
384 struct ubi_wl_entry *e; in wl_get_wle() local
386 e = find_mean_wl_entry(ubi, &ubi->free); in wl_get_wle()
387 if (!e) { in wl_get_wle()
392 self_check_in_wl_tree(ubi, e, &ubi->free); in wl_get_wle()
398 rb_erase(&e->u.rb, &ubi->free); in wl_get_wle()
400 dbg_wl("PEB %d EC %d", e->pnum, e->ec); in wl_get_wle()
402 return e; in wl_get_wle()
415 struct ubi_wl_entry *e; in prot_queue_del() local
417 e = ubi->lookuptbl[pnum]; in prot_queue_del()
418 if (!e) in prot_queue_del()
421 if (self_check_in_pq(ubi, e)) in prot_queue_del()
424 list_del(&e->u.list); in prot_queue_del()
425 dbg_wl("deleted PEB %d from the protection queue", e->pnum); in prot_queue_del()
438 static int sync_erase(struct ubi_device *ubi, struct ubi_wl_entry *e, in sync_erase() argument
443 unsigned long long ec = e->ec; in sync_erase()
445 dbg_wl("erase PEB %d, old EC %llu", e->pnum, ec); in sync_erase()
447 err = self_check_ec(ubi, e->pnum, e->ec); in sync_erase()
455 err = ubi_io_sync_erase(ubi, e->pnum, torture); in sync_erase()
466 e->pnum, ec); in sync_erase()
471 dbg_wl("erased PEB %d, new EC %llu", e->pnum, ec); in sync_erase()
475 err = ubi_io_write_ec_hdr(ubi, e->pnum, ec_hdr); in sync_erase()
479 e->ec = ec; in sync_erase()
481 if (e->ec > ubi->max_ec) in sync_erase()
482 ubi->max_ec = e->ec; in sync_erase()
500 struct ubi_wl_entry *e, *tmp; in serve_prot_queue() local
510 list_for_each_entry_safe(e, tmp, &ubi->pq[ubi->pq_head], u.list) { in serve_prot_queue()
512 e->pnum, e->ec); in serve_prot_queue()
514 list_del(&e->u.list); in serve_prot_queue()
515 wl_tree_add(e, &ubi->used); in serve_prot_queue()
583 static int schedule_erase(struct ubi_device *ubi, struct ubi_wl_entry *e, in schedule_erase() argument
588 ubi_assert(e); in schedule_erase()
591 e->pnum, e->ec, torture); in schedule_erase()
598 wl_wrk->e = e; in schedule_erase()
620 static int do_sync_erase(struct ubi_device *ubi, struct ubi_wl_entry *e, in do_sync_erase() argument
625 dbg_wl("sync erase of PEB %i", e->pnum); in do_sync_erase()
627 wl_wrk.e = e; in do_sync_erase()
1085 struct ubi_wl_entry *e = wl_wrk->e; local
1086 int pnum = e->pnum;
1092 pnum, e->ec, wl_wrk->vol_id, wl_wrk->lnum);
1094 err = sync_erase(ubi, e, wl_wrk->torture);
1099 e->pnum < UBI_FM_MAX_START) {
1104 ubi->fm_anchor = e;
1107 wl_tree_add(e, &ubi->free);
1131 err1 = schedule_erase(ubi, e, vol_id, lnum, 0, false);
1133 wl_entry_destroy(ubi, e);
1140 wl_entry_destroy(ubi, e);
1215 struct ubi_wl_entry *e = wl_wrk->e; local
1217 dbg_wl("cancel erasure of PEB %d EC %d", e->pnum, e->ec);
1219 wl_entry_destroy(ubi, e);
1245 struct ubi_wl_entry *e; local
1255 e = ubi->lookuptbl[pnum];
1256 if (e == ubi->move_from) {
1269 } else if (e == ubi->move_to) {
1286 if (in_wl_tree(e, &ubi->used)) {
1287 self_check_in_wl_tree(ubi, e, &ubi->used);
1288 rb_erase(&e->u.rb, &ubi->used);
1289 } else if (in_wl_tree(e, &ubi->scrub)) {
1290 self_check_in_wl_tree(ubi, e, &ubi->scrub);
1291 rb_erase(&e->u.rb, &ubi->scrub);
1292 } else if (in_wl_tree(e, &ubi->erroneous)) {
1293 self_check_in_wl_tree(ubi, e, &ubi->erroneous);
1294 rb_erase(&e->u.rb, &ubi->erroneous);
1300 err = prot_queue_del(ubi, e->pnum);
1312 err = schedule_erase(ubi, e, vol_id, lnum, torture, false);
1315 wl_tree_add(e, &ubi->used);
1335 struct ubi_wl_entry *e; local
1341 e = ubi->lookuptbl[pnum];
1342 if (e == ubi->move_from || in_wl_tree(e, &ubi->scrub) ||
1343 in_wl_tree(e, &ubi->erroneous)) {
1348 if (e == ubi->move_to) {
1361 if (in_wl_tree(e, &ubi->used)) {
1362 self_check_in_wl_tree(ubi, e, &ubi->used);
1363 rb_erase(&e->u.rb, &ubi->used);
1367 err = prot_queue_del(ubi, e->pnum);
1376 wl_tree_add(e, &ubi->scrub);
1449 static bool scrub_possible(struct ubi_device *ubi, struct ubi_wl_entry *e) argument
1451 if (in_wl_tree(e, &ubi->scrub))
1453 else if (in_wl_tree(e, &ubi->erroneous))
1455 else if (ubi->move_from == e)
1457 else if (ubi->move_to == e)
1485 struct ubi_wl_entry *e; local
1503 e = ubi->lookuptbl[pnum];
1504 if (!e) {
1513 if (!scrub_possible(ubi, e)) {
1536 e = ubi->lookuptbl[pnum];
1537 if (!e) {
1546 if (!scrub_possible(ubi, e)) {
1552 if (in_pq(ubi, e)) {
1553 prot_queue_del(ubi, e->pnum);
1554 wl_tree_add(e, &ubi->scrub);
1558 } else if (in_wl_tree(e, &ubi->used)) {
1559 rb_erase(&e->u.rb, &ubi->used);
1560 wl_tree_add(e, &ubi->scrub);
1564 } else if (in_wl_tree(e, &ubi->free)) {
1565 rb_erase(&e->u.rb, &ubi->free);
1573 err = schedule_erase(ubi, e, UBI_UNKNOWN, UBI_UNKNOWN,
1601 struct ubi_wl_entry *e; local
1610 e = rb_entry(rb, struct ubi_wl_entry, u.rb);
1614 if (rb->rb_left == &e->u.rb)
1620 wl_entry_destroy(ubi, e);
1721 struct ubi_wl_entry *e; local
1724 e = kmem_cache_alloc(ubi_wl_entry_slab, GFP_KERNEL);
1725 if (!e)
1728 e->pnum = aeb->pnum;
1729 e->ec = aeb->ec;
1730 ubi->lookuptbl[e->pnum] = e;
1733 err = sync_erase(ubi, e, false);
1737 wl_tree_add(e, &ubi->free);
1740 err = schedule_erase(ubi, e, aeb->vol_id, aeb->lnum, 0, false);
1748 wl_entry_destroy(ubi, e);
1767 struct ubi_wl_entry *e; local
1801 e = kmem_cache_alloc(ubi_wl_entry_slab, GFP_KERNEL);
1802 if (!e) {
1807 e->pnum = aeb->pnum;
1808 e->ec = aeb->ec;
1809 ubi_assert(e->ec >= 0);
1811 wl_tree_add(e, &ubi->free);
1814 ubi->lookuptbl[e->pnum] = e;
1823 e = kmem_cache_alloc(ubi_wl_entry_slab, GFP_KERNEL);
1824 if (!e) {
1829 e->pnum = aeb->pnum;
1830 e->ec = aeb->ec;
1831 ubi->lookuptbl[e->pnum] = e;
1835 e->pnum, e->ec);
1836 wl_tree_add(e, &ubi->used);
1839 e->pnum, e->ec);
1840 wl_tree_add(e, &ubi->scrub);
1850 e = ubi_find_fm_block(ubi, aeb->pnum);
1852 if (e) {
1853 ubi_assert(!ubi->lookuptbl[e->pnum]);
1854 ubi->lookuptbl[e->pnum] = e;
1933 struct ubi_wl_entry *e, *tmp; local
1936 list_for_each_entry_safe(e, tmp, &ubi->pq[i], u.list) {
1937 list_del(&e->u.list);
1938 wl_entry_destroy(ubi, e);
2014 struct ubi_wl_entry *e, struct rb_root *root) argument
2019 if (in_wl_tree(e, root))
2023 e->pnum, e->ec, root);
2037 struct ubi_wl_entry *e) argument
2042 if (in_pq(ubi, e))
2046 e->pnum, e->ec);
2053 struct ubi_wl_entry *e; local
2055 e = find_wl_entry(ubi, &ubi->free, WL_FREE_MAX_DIFF);
2056 self_check_in_wl_tree(ubi, e, &ubi->free);
2059 rb_erase(&e->u.rb, &ubi->free);
2061 return e;
2102 struct ubi_wl_entry *e; local
2125 e = wl_get_wle(ubi);
2126 prot_queue_add(ubi, e);
2129 err = ubi_self_check_all_ff(ubi, e->pnum, ubi->vid_hdr_aloffset,
2132 ubi_err(ubi, "new PEB %d does not contain all 0xFF bytes", e->pnum);
2136 return e->pnum;