| # apebs = # wlar, wlar[vtblpnum2] = wl-entry(m1, used), wlar[vtblpnum1] = wl-entry(m0, free), apebs[vtblpnum2] = mkpeb(aehdr, avhdr0, buf1, m2, false), apebs1 = apebs, buf = mkbuf(LEB_SIZE), err = ESUCCESS, err = err0, q1 = q, vols1 = vols, wlar0 = wlar, vtblpnum2 < # wlar, vtblpnum1 < # wlar, vtblpnum2 < # apebs, bflipset-cons(bflipset0, wlar), ubi-io-inv(apebs), ubi-io-peb-inv(mkpeb(aehdr, avhdr0, buf1, m2, false)), unique-sqns(apebs), valid-ebatbl(apebs, wlar, vols, n2), valid-eraseq(q), valid-eraseq(wlar, q), valid-eraseq(apebs, q), valid-global-sqn(apebs, n1), valid-vtbl(apebs, vols, wlar, n2), valid-wl(apebs, wlar), m1 + WL_THRESHOLD ≤ m0, 0 + LEB_SIZE ≤ # buf, 0 + LEB_SIZE ≤ # apebs[vtblpnum2].data, ⌊err0⌋ ∨ err0 = ESUCCESS ⊦ [ubi_atomic_leb_change# (avhdr0.vol, avhdr0.leb, vtblpnum1, LEB_SIZE, copy(apebs[vtblpnum2].data, 0, buf, 0, LEB_SIZE), EB_PAGE_SIZE ; vols, wlar, q, bflipset0, n2, n1, apebs ; err); if err ≠ ESUCCESS then debug#("ubi: wear-leveling of PEB " + vtblpnum2.toString + " to PEB " + vtblpnum1.toString + " failed"); if err = ESUCCESS then {ubi_erase_worker_helper#(vtblpnum2; wlar, apebs; err); if err = ESUCCESS then q := q.butlast}] ( # apebs = # wlar ∧ unique-sqns(apebs) ∧ valid-global-sqn(apebs, n1) ∧ valid-wl(apebs, wlar) ∧ valid-eraseq(q) ∧ valid-eraseq(wlar, q) ∧ valid-eraseq(apebs, q) ∧ ¬ VTBL_VOLID ∈ vols ∧ bflipset-cons(bflipset0, wlar) ∧ valid-ebatbl(apebs, wlar, vols, n2) ∧ valid-vtbl(apebs, vols, wlar, n2) ∧ ubi-io-inv(apebs) ∧ ( vols1 = vols ∧ id(apebs, apebs1, mapped-pebs(vols)) ∧ q.lebrefs ⊆ q1.lebrefs ++ (VTBL_VOLID × VTBL_LNUM) ∨ (∃ v, m, n. v ∈ vols1 ∧ m < # vols1[v] ∧ vols1[v][m] ≠ unmapped ∧ vols = vols1[v, vols1[v][m, ⌜n⌝ ]] ∧ id(apebs, apebs1, mapped-pebs(vols1) -- vols1[v][m].pnum) ∧ apebs[n].data = apebs1[vols1[v][m].pnum].data ∧ apebs[n].fill ≤ apebs1[vols1[v][m].pnum].fill ∧ q.lebrefs ⊆ q1.lebrefs ++ (v × m))) → err = ESUCCESS → Δ wlar < Δ wlar0), VTBL_VOLID ∈ vols |
# apebs = # wlar, wlar[vtblpnum2] = wl-entry(m1, used), wlar[vtblpnum1] = wl-entry(m0, free), apebs[vtblpnum2] = mkpeb(aehdr, avhdr0, buf1, m2, false), apebs1 = apebs, q1 = q, vols1 = vols, wlar0 = wlar, vtblpnum1 < # wlar, vtblpnum2 < # wlar, bflipset-cons(bflipset0, wlar), ubi-io-inv(apebs), ubi-io-peb-inv(mkpeb(aehdr, avhdr0, buf1, m2, false)), unique-sqns(apebs), valid-ebatbl(apebs, wlar, vols, n2), valid-eraseq(q), valid-eraseq(wlar, q), valid-eraseq(apebs, q), valid-global-sqn(apebs, n1), valid-vtbl(apebs, vols, wlar, n2), valid-wl(apebs, wlar), m1 + WL_THRESHOLD ≤ m0, ¬ VTBL_VOLID ∈ vols ⊦ [ubi_atomic_leb_change# (avhdr0.vol, avhdr0.leb, vtblpnum1, LEB_SIZE, copy(apebs[vtblpnum2].data, 0, mkbuf(LEB_SIZE), 0, LEB_SIZE), EB_PAGE_SIZE ; vols, wlar, q, bflipset0, n2, n1, apebs ; err0); if err0 ≠ ESUCCESS then debug#("ubi: wear-leveling of PEB " + vtblpnum2.toString + " to PEB " + vtblpnum1.toString + " failed"); if err0 = ESUCCESS then {ubi_erase_worker_helper#(vtblpnum2; wlar, apebs; err0); if err0 = ESUCCESS then q := q.butlast}] ( # apebs = # wlar ∧ unique-sqns(apebs) ∧ valid-global-sqn(apebs, n1) ∧ valid-wl(apebs, wlar) ∧ valid-eraseq(q) ∧ valid-eraseq(wlar, q) ∧ valid-eraseq(apebs, q) ∧ ¬ VTBL_VOLID ∈ vols ∧ bflipset-cons(bflipset0, wlar) ∧ valid-ebatbl(apebs, wlar, vols, n2) ∧ valid-vtbl(apebs, vols, wlar, n2) ∧ ubi-io-inv(apebs) ∧ ( vols1 = vols ∧ id(apebs, apebs1, mapped-pebs(vols)) ∧ q.lebrefs ⊆ q1.lebrefs ++ (VTBL_VOLID × VTBL_LNUM) ∨ (∃ v, m, n. v ∈ vols1 ∧ m < # vols1[v] ∧ vols1[v][m] ≠ unmapped ∧ vols = vols1[v, vols1[v][m, ⌜n⌝ ]] ∧ id(apebs, apebs1, mapped-pebs(vols1) -- vols1[v][m].pnum) ∧ apebs[n].data = apebs1[vols1[v][m].pnum].data ∧ apebs[n].fill ≤ apebs1[vols1[v][m].pnum].fill ∧ q.lebrefs ⊆ q1.lebrefs ++ (v × m))) → err0 = ESUCCESS → Δ wlar < Δ wlar0)
Used simplifier rules: ⊦ ubi-io-peb-inv(mkpeb(aehdr, avhdr, buf, n, boolvar)) → # buf = LEB_SIZE; (s)% ⊦ mkpeb(aehdr, avhdr, buf, m, boolvar).data = buf; (s)% ⊦ ¬ ⌊ESUCCESS⌋ ; (s)% ⊦ m ≤ m; (s)% ⊦ # mkbuf(n) = n; (s)%c: ⊦ m + n = n + m; from specification nat-basic%a: ⊦ (m + n0) + n1 = m + n0 + n1; from specification nat-basic% ⊦ n + 0 = n; (s)