| ubi_wear_leveling_worker#(LEBSIZE, PAGESIZE; VOLS, WLARRAY, ERASEQ, BFLIPSET, VTBLPNUM, SQNUM, APEBS; ERR) {let VALID = ?, TO = ?, FROM = ? in {ubi_get_pebs_for_wl#(WLARRAY; TO, FROM, BFLIPSET; VALID); if VALID then let AVHDR = ?, BITFLIPS = ? in {aubi_io_read_vidhdr#(FROM, APEBS; AVHDR; BITFLIPS, ERR); if ERR = ESUCCESS then let BUF = mkbuf(LEBSIZE) in {aubi_io_read_data#(FROM, 0, 0, LEBSIZE, APEBS; BUF; BITFLIPS, ERR); if ERR = ESUCCESS then ubi_atomic_leb_change# (AVHDR.vol, AVHDR.leb, TO, LEBSIZE, BUF, PAGESIZE; VOLS, WLARRAY, ERASEQ, BFLIPSET, VTBLPNUM, SQNUM, APEBS; ERR); if ERR ≠ ESUCCESS then debug#("ubi: wear-leveling of PEB " + FROM.toString + " to PEB " + TO.toString + " failed"); if ERR = ESUCCESS then {ubi_erase_worker_helper#(FROM; WLARRAY, APEBS; ERR); if ERR = ESUCCESS then ERASEQ := ERASEQ.butlast}}} else ERR := ENOSPC} } |