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()
1088 struct ubi_wl_entry *e = wl_wrk->e; local
1089 int pnum = e->pnum;
1095 pnum, e->ec, wl_wrk->vol_id, wl_wrk->lnum);
1097 err = sync_erase(ubi, e, wl_wrk->torture);
1102 e->pnum < UBI_FM_MAX_START) {
1107 ubi->fm_anchor = e;
1110 wl_tree_add(e, &ubi->free);
1134 err1 = schedule_erase(ubi, e, vol_id, lnum, 0, true);
1137 wl_entry_destroy(ubi, e);
1146 wl_entry_destroy(ubi, e);
1222 struct ubi_wl_entry *e = wl_wrk->e; local
1224 dbg_wl("cancel erasure of PEB %d EC %d", e->pnum, e->ec);
1226 wl_entry_destroy(ubi, e);
1252 struct ubi_wl_entry *e; local
1262 e = ubi->lookuptbl[pnum];
1263 if (!e) {
1275 if (e == ubi->move_from) {
1288 } else if (e == ubi->move_to) {
1305 if (in_wl_tree(e, &ubi->used)) {
1306 self_check_in_wl_tree(ubi, e, &ubi->used);
1307 rb_erase(&e->u.rb, &ubi->used);
1308 } else if (in_wl_tree(e, &ubi->scrub)) {
1309 self_check_in_wl_tree(ubi, e, &ubi->scrub);
1310 rb_erase(&e->u.rb, &ubi->scrub);
1311 } else if (in_wl_tree(e, &ubi->erroneous)) {
1312 self_check_in_wl_tree(ubi, e, &ubi->erroneous);
1313 rb_erase(&e->u.rb, &ubi->erroneous);
1319 err = prot_queue_del(ubi, e->pnum);
1331 err = schedule_erase(ubi, e, vol_id, lnum, torture, false);
1334 wl_tree_add(e, &ubi->used);
1354 struct ubi_wl_entry *e; local
1360 e = ubi->lookuptbl[pnum];
1361 if (e == ubi->move_from || in_wl_tree(e, &ubi->scrub) ||
1362 in_wl_tree(e, &ubi->erroneous)) {
1367 if (e == ubi->move_to) {
1380 if (in_wl_tree(e, &ubi->used)) {
1381 self_check_in_wl_tree(ubi, e, &ubi->used);
1382 rb_erase(&e->u.rb, &ubi->used);
1386 err = prot_queue_del(ubi, e->pnum);
1395 wl_tree_add(e, &ubi->scrub);
1468 static bool scrub_possible(struct ubi_device *ubi, struct ubi_wl_entry *e) argument
1470 if (in_wl_tree(e, &ubi->scrub))
1472 else if (in_wl_tree(e, &ubi->erroneous))
1474 else if (ubi->move_from == e)
1476 else if (ubi->move_to == e)
1504 struct ubi_wl_entry *e; local
1522 e = ubi->lookuptbl[pnum];
1523 if (!e) {
1532 if (!scrub_possible(ubi, e)) {
1555 e = ubi->lookuptbl[pnum];
1556 if (!e) {
1565 if (!scrub_possible(ubi, e)) {
1571 if (in_pq(ubi, e)) {
1572 prot_queue_del(ubi, e->pnum);
1573 wl_tree_add(e, &ubi->scrub);
1577 } else if (in_wl_tree(e, &ubi->used)) {
1578 rb_erase(&e->u.rb, &ubi->used);
1579 wl_tree_add(e, &ubi->scrub);
1583 } else if (in_wl_tree(e, &ubi->free)) {
1584 rb_erase(&e->u.rb, &ubi->free);
1592 err = schedule_erase(ubi, e, UBI_UNKNOWN, UBI_UNKNOWN,
1620 struct ubi_wl_entry *e; local
1629 e = rb_entry(rb, struct ubi_wl_entry, u.rb);
1633 if (rb->rb_left == &e->u.rb)
1639 wl_entry_destroy(ubi, e);
1740 struct ubi_wl_entry *e; local
1743 e = kmem_cache_alloc(ubi_wl_entry_slab, GFP_KERNEL);
1744 if (!e)
1747 e->pnum = aeb->pnum;
1748 e->ec = aeb->ec;
1749 ubi->lookuptbl[e->pnum] = e;
1752 err = sync_erase(ubi, e, false);
1756 wl_tree_add(e, &ubi->free);
1759 err = schedule_erase(ubi, e, aeb->vol_id, aeb->lnum, 0, false);
1767 wl_entry_destroy(ubi, e);
1786 struct ubi_wl_entry *e; local
1820 e = kmem_cache_alloc(ubi_wl_entry_slab, GFP_KERNEL);
1821 if (!e) {
1826 e->pnum = aeb->pnum;
1827 e->ec = aeb->ec;
1828 ubi_assert(e->ec >= 0);
1830 wl_tree_add(e, &ubi->free);
1833 ubi->lookuptbl[e->pnum] = e;
1842 e = kmem_cache_alloc(ubi_wl_entry_slab, GFP_KERNEL);
1843 if (!e) {
1848 e->pnum = aeb->pnum;
1849 e->ec = aeb->ec;
1850 ubi->lookuptbl[e->pnum] = e;
1854 e->pnum, e->ec);
1855 wl_tree_add(e, &ubi->used);
1858 e->pnum, e->ec);
1859 wl_tree_add(e, &ubi->scrub);
1869 e = ubi_find_fm_block(ubi, aeb->pnum);
1871 if (e) {
1872 ubi_assert(!ubi->lookuptbl[e->pnum]);
1873 ubi->lookuptbl[e->pnum] = e;
1952 struct ubi_wl_entry *e, *tmp; local
1955 list_for_each_entry_safe(e, tmp, &ubi->pq[i], u.list) {
1956 list_del(&e->u.list);
1957 wl_entry_destroy(ubi, e);
2033 struct ubi_wl_entry *e, struct rb_root *root) argument
2038 if (in_wl_tree(e, root))
2042 e->pnum, e->ec, root);
2056 struct ubi_wl_entry *e) argument
2061 if (in_pq(ubi, e))
2065 e->pnum, e->ec);
2072 struct ubi_wl_entry *e; local
2074 e = find_wl_entry(ubi, &ubi->free, WL_FREE_MAX_DIFF);
2075 self_check_in_wl_tree(ubi, e, &ubi->free);
2078 rb_erase(&e->u.rb, &ubi->free);
2080 return e;
2121 struct ubi_wl_entry *e; local
2144 e = wl_get_wle(ubi);
2145 prot_queue_add(ubi, e);
2148 err = ubi_self_check_all_ff(ubi, e->pnum, ubi->vid_hdr_aloffset,
2151 ubi_err(ubi, "new PEB %d does not contain all 0xFF bytes", e->pnum);
2155 return e->pnum;