Lines Matching defs:peb
322 /* check if the PEB is free: magic, crc_ec and erase_cnt is good and
327 dbg_ebh("free peb found\n");
400 /* check if the PEB is free: magic, crc_ec and erase_cnt is good and
405 dbg_ebh("free peb found\n");
451 chfs_err("can't mark peb dirty");
486 chfs_err("can't invalidate peb");
498 * @ec: erase counter of PEB
526 chfs_err("can't mark peb as free: %d\n", pebnr);
756 /* Generate functions for in use PEB's red-black tree */
763 * add_peb_to_erase_queue: adds a PEB to to_erase/fully_erased queue
766 * @ec - erase counter of PEB
769 * This function adds a PEB to the erase queue specified by @queue.
777 struct chfs_peb *peb;
779 peb = kmem_alloc(sizeof(struct chfs_peb), KM_SLEEP);
781 peb->erase_cnt = ec;
782 peb->pebnr = pebnr;
784 TAILQ_INSERT_TAIL(queue, peb, u.queue);
791 * find_peb_in_use - looks up a PEB in the RB-tree of used blocks
794 * This function returns a pointer to the PEB found in the tree,
801 struct chfs_peb peb, *result;
802 peb.pebnr = pebnr;
803 result = RB_FIND(peb_in_use_rbtree, &ebh->in_use, &peb);
808 * add_peb_to_free - adds a PEB to the RB-tree of free PEBs
811 * @ec - erase counter of PEB
822 struct chfs_peb *peb, *result;
824 peb = kmem_alloc(sizeof(struct chfs_peb), KM_SLEEP);
826 peb->erase_cnt = ec;
827 peb->pebnr = pebnr;
828 result = RB_INSERT(peb_free_rbtree, &ebh->free, peb);
830 kmem_free(peb, sizeof(struct chfs_peb));
838 * add_peb_to_in_use - adds a PEB to the RB-tree of used PEBs
841 * @ec - erase counter of PEB
852 struct chfs_peb *peb, *result;
854 peb = kmem_alloc(sizeof(struct chfs_peb), KM_SLEEP);
856 peb->erase_cnt = ec;
857 peb->pebnr = pebnr;
858 result = RB_INSERT(peb_in_use_rbtree, &ebh->in_use, peb);
860 kmem_free(peb, sizeof(struct chfs_peb));
878 struct chfs_peb *peb = priv->peb;
880 peb->erase_cnt += 1;
886 peb->pebnr, peb->erase_cnt);
888 /* cannot mark PEB as free,so erase it again */
890 "cannot mark eraseblock as free, PEB: %d\n",
891 peb->pebnr);
895 add_peb_to_erase_queue(ebh, peb->pebnr, peb->erase_cnt,
900 kmem_free(peb, sizeof(struct chfs_peb));
906 err = add_peb_to_free(ebh, peb->pebnr, peb->erase_cnt);
909 kmem_free(peb, sizeof(struct chfs_peb));
913 * so erase PEB again
916 add_peb_to_erase_queue(ebh, peb->pebnr, peb->erase_cnt, &ebh->to_erase);
917 kmem_free(peb, sizeof(struct chfs_peb));
922 * free_peb: free a PEB
934 struct chfs_peb *peb = NULL;
940 //dbg_ebh("[FREE PEB] got a fully erased block\n");
941 peb = TAILQ_FIRST(&ebh->fully_erased);
942 TAILQ_REMOVE(&ebh->fully_erased, peb, u.queue);
944 peb->pebnr, peb->erase_cnt);
948 err = add_peb_to_free(ebh, peb->pebnr, peb->erase_cnt);
951 /* Erase PEB */
952 //dbg_ebh("[FREE PEB] erasing a block\n");
953 peb = TAILQ_FIRST(&ebh->to_erase);
954 TAILQ_REMOVE(&ebh->to_erase, peb, u.queue);
957 ofs = peb->pebnr * ebh->flash_if->erasesize;
972 ((struct chfs_erase_info_priv *) ei->ei_priv)->peb = peb;
975 dbg_ebh("erased peb: %d\n", peb->pebnr);
993 chfs_err("can not erase PEB: %d, try again\n", peb->pebnr);
1004 kmem_free(peb, sizeof(struct chfs_peb));
1009 * release_peb - schedule an erase for the PEB
1013 * This function get the peb identified by @pebnr from the in_use RB-tree of
1022 struct chfs_peb *peb;
1027 peb = find_peb_in_use(ebh, pebnr);
1028 if (!peb) {
1033 err = add_peb_to_erase_queue(ebh, peb->pebnr, peb->erase_cnt,
1039 RB_REMOVE(peb_in_use_rbtree, &ebh->in_use, peb);
1078 chfs_err("freeing PEB failed in the background thread: %d\n", err);
1109 chfs_err("freeing PEB failed in the"
1203 * @leb_status: the status of the PEB's eraseblock header
1205 * This function adds a PEB to the used tree of the scanning information.
1311 * @leb_status: the status of the PEB's eraseblock header
1313 * This function adds a PEB to the used tree of the scanning information.
1453 dbg_ebh("processing PEB %d\n", pebnr);
1737 /* If PEB is not mapped the buffer is filled with 0xFF */
1764 * The entries sorted by the erase counters, so the PEB with the smallest
1772 struct chfs_peb *peb;
1794 peb = RB_MIN(peb_free_rbtree, &ebh->free);
1795 pebnr = peb->pebnr;
1796 RB_REMOVE(peb_free_rbtree, &ebh->free, peb);
1797 err = add_peb_to_in_use(ebh, peb->pebnr, peb->erase_cnt);
1801 kmem_free(peb, sizeof(struct chfs_peb));
1844 chfs_err("error %d while writing %zu bytes to PEB "
1856 * If the LEB is unmapped, get a free PEB and write the
1877 "error writing eraseblock header: LEB %d , PEB %d\n",
1888 chfs_err("error %d while writing %zu bytes to PEB "
1942 * ebh_map_leb - maps a PEB to LEB
1974 "error writing eraseblock header: LEB %d , PEB %d\n",
2018 * ebh_is_mapped - check if a PEB is mapped to @lnr
2039 * ebh_change_leb - write the LEB to another PEB
2053 struct chfs_peb *peb = NULL;
2097 "error writing eraseblock header: LEB %d , PEB %d",
2107 chfs_err("error %d while writing %zu bytes to PEB %d:%ju,"
2120 peb = find_peb_in_use(ebh, pebnr_old);
2121 err = release_peb(ebh, peb->pebnr);
2129 kmem_free(peb, sizeof(struct chfs_peb));