// SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2012 Linutronix GmbH * Copyright (c) 2014 sigma star gmbh * Author: Richard Weinberger <[email protected]> */ /** * update_fastmap_work_fn - calls ubi_update_fastmap from a work queue * @wrk: the work description object */ static void update_fastmap_work_fn(struct work_struct *wrk) { … } /** * find_anchor_wl_entry - find wear-leveling entry to used as anchor PEB. * @root: the RB-tree where to look for */ static struct ubi_wl_entry *find_anchor_wl_entry(struct rb_root *root) { … } static inline void return_unused_peb(struct ubi_device *ubi, struct ubi_wl_entry *e) { … } /** * return_unused_pool_pebs - returns unused PEB to the free tree. * @ubi: UBI device description object * @pool: fastmap pool description object */ static void return_unused_pool_pebs(struct ubi_device *ubi, struct ubi_fm_pool *pool) { … } /** * 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 *ubi_wl_get_fm_peb(struct ubi_device *ubi, int anchor) { … } /* * 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. */ static void wait_free_pebs_for_pool(struct ubi_device *ubi) { … } /* * 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 int left_free_count(struct ubi_device *ubi) { … } /* * 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. */ static int can_fill_pools(struct ubi_device *ubi, int free) { … } /** * ubi_refill_pools_and_lock - refills all fastmap PEB pools and takes fm locks. * @ubi: UBI device description object */ void ubi_refill_pools_and_lock(struct ubi_device *ubi) { … } /** * 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. */ static int produce_free_peb(struct ubi_device *ubi) { … } /** * 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(struct ubi_device *ubi) { … } /** * next_peb_for_wl - returns next PEB to be used internally by the * WL sub-system. * * @ubi: UBI device description object */ static struct ubi_wl_entry *next_peb_for_wl(struct ubi_device *ubi) { … } /** * 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 bool need_wear_leveling(struct ubi_device *ubi) { … } /* get_peb_for_wl - returns a PEB to be used internally by the WL sub-system. * * @ubi: UBI device description object */ static struct ubi_wl_entry *get_peb_for_wl(struct ubi_device *ubi) { … } /** * ubi_ensure_anchor_pebs - schedule wear-leveling to produce an anchor PEB. * @ubi: UBI device description object */ int ubi_ensure_anchor_pebs(struct ubi_device *ubi) { … } /** * 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, int lnum, int torture) { … } /** * ubi_is_erase_work - checks whether a work is erase work. * @wrk: The work object to be checked */ int ubi_is_erase_work(struct ubi_work *wrk) { … } static void ubi_fastmap_close(struct ubi_device *ubi) { … } /** * may_reserve_for_fm - tests whether a PEB shall be reserved for fastmap. * See find_mean_wl_entry() * * @ubi: UBI device description object * @e: physical eraseblock to return * @root: RB tree to test against. */ static struct ubi_wl_entry *may_reserve_for_fm(struct ubi_device *ubi, struct ubi_wl_entry *e, struct rb_root *root) { … }