| # apebs0 = # wlar, LEB_SIZE = n2 + n0, apebs0[n1] = mkpeb(aehdr, empty, mkempbuf(LEB_SIZE), 0, false), wlar[n1] = wl-entry(m1, free), apebs = apebs0[n1, apebs0[n1].vidhdr:= avidhdr(v, m0, sqnum, 0, 0)], apebs1 = apebs0, buf = mkempbuf(n0) + buf0, err = ESUCCESS, err = err0, vtblpnum2 = n1, aehdr.valid?, n1 < # apebs0, n1 < # wlar, bflipset-cons(bflipset, wlar), is-aligned(n0, EB_PAGE_SIZE), ubi-io-inv(apebs0), ubi-io-inv(apebs), unique-sqns(apebs0), valid-ebatbl(apebs0, wlar, vols, vtblpnum1), valid-eraseq(apebs0, q), valid-eraseq(wlar, q), valid-eraseq(q), valid-global-sqn(apebs0, sqnum), valid-vtbl(apebs0, vols, wlar, vtblpnum1), valid-wl(apebs0, wlar), n0 ≤ LEB_SIZE, v ∈ vols ∧ m0 < # vols[v] ∨ v = VTBL_VOLID ∧ m0 = VTBL_LNUM, ⌊err0⌋ ∨ err0 = ESUCCESS ⊦ ⟪if datasize(buf, n0) ≠ 0 then aubi_io_write_data_wl#(vtblpnum2, align↑(datasize(buf, n0), EB_PAGE_SIZE), buf; apebs; err); vtblpnum0 := vtblpnum1; vols0 := vols; q0 := q; if err = ESUCCESS then {if v = VTBL_VOLID ∧ m0 = VTBL_LNUM then {ubi_wl_put_peb#(VTBL_VOLID × VTBL_LNUM, vtblpnum0; wlar, q); bflipset := bflipset -- vtblpnum0; vtblpnum0 := vtblpnum2} else {vtblpnum3 := m0; if vols[v][vtblpnum3] ≠ unmapped then let vtblpnum0 = vols[v][vtblpnum3].pnum in {ubi_wl_put_peb#(v × vtblpnum3, vtblpnum0; wlar, q); bflipset := bflipset -- vtblpnum0}; vols[v][vtblpnum3] := ⌜vtblpnum2⌝ }; wlar[vtblpnum2] := wl-entry(wlar[vtblpnum2].ec, used)} else ubi_wl_put_peb#(none, vtblpnum2; wlar, q)⟫ ( (err = ESUCCESS ∨ ⌊err⌋ ) ∧ id○(apebs, apebs1, n1) ∧ ubi-io-inv(apebs) ∧ # apebs = # wlar ∧ unique-sqns(apebs) ∧ valid-global-sqn(apebs, sqnum + 1) ∧ valid-wl(apebs, wlar) ∧ valid-eraseq(q) ∧ valid-eraseq(wlar, q) ∧ valid-eraseq(apebs, q) ∧ ¬ VTBL_VOLID ∈ vols ∧ bflipset-cons(bflipset, wlar) ∧ ( v ∈ vols0 ∨ is-encoded(to-vtbl(vols0), subarray(buf, 0, LEB_SIZE)) ∧ n0 = LEB_SIZE ∨ err ≠ ESUCCESS → valid-ebatbl(apebs, wlar, vols, vtblpnum0) ∧ valid-vtbl(apebs, vols, wlar, vtblpnum0)) ∧ ( err = ESUCCESS ∧ v = VTBL_VOLID ∧ m0 = VTBL_LNUM → (∀ v0, m0. ¬ v0 ∈ vols0 ∧ is-encoded(to-vtbl(vols0)[v0, m0], subarray(buf, 0, LEB_SIZE)) ∧ n0 = LEB_SIZE → valid-ebatbl(apebs, wlar, vols[v0, fill(mkebatbl(m0), unmapped)], vtblpnum0) ∧ valid-vtbl(apebs, vols[v0, fill(mkebatbl(m0), unmapped)], wlar, vtblpnum0))) ∧ (err = ESUCCESS ∧ v ∈ vols0 ∧ vols0[v][m0] ≠ unmapped → q = q0 + eq-entry(vols0[v][m0].pnum, v × m0) ') ∧ (err = ESUCCESS ∧ v = VTBL_VOLID ∧ m0 = VTBL_LNUM → q = q0 + eq-entry(vtblpnum1, VTBL_VOLID × VTBL_LNUM) ') ∧ id(apebs, apebs1, mapped-pebs(vols0)) ∧ (v = VTBL_VOLID ∧ m0 = VTBL_LNUM ∨ err ≠ ESUCCESS → vols = vols0) ∧ (v ∈ vols0 ∧ err = ESUCCESS → vols = vols0[v, vols0[v][m0, ⌜n1⌝ ]]) ∧ ( err = ESUCCESS → apebs[n1].fill = datasize(buf, n0) ∧ apebs[n1].data = subarray(buf, 0, n0) + mkempbuf(n2) ∧ q.lebrefs ⊆ q0.lebrefs ++ (v × m0)) ∧ (err ≠ ESUCCESS → q.lebrefs = q0.lebrefs)), vtblpnum1 = n1, vtblpnum1 ∈ q, VTBL_VOLID ∈ vols |
# apebs0 = # wlar, LEB_SIZE = n2 + n0, wlar[n1] = wl-entry(m1, free), apebs0[n1] = mkpeb(aehdr, empty, mkempbuf(LEB_SIZE), 0, false), apebs = apebs0[n1, apebs0[n1].vidhdr:= avidhdr(v, m0, sqnum, 0, 0)], apebs1 = apebs0, buf = mkempbuf(n0) + buf0, err = err0, err = ESUCCESS, vtblpnum2 = n1, aehdr.valid?, n1 < # wlar, n1 < # apebs0, bflipset-cons(bflipset, wlar), is-aligned(n0, EB_PAGE_SIZE), ubi-io-inv(apebs), ubi-io-inv(apebs0), unique-sqns(apebs0), valid-ebatbl(apebs0, wlar, vols, vtblpnum1), valid-eraseq(q), valid-eraseq(wlar, q), valid-eraseq(apebs0, q), valid-global-sqn(apebs0, sqnum), valid-vtbl(apebs0, vols, wlar, vtblpnum1), valid-wl(apebs0, wlar), n0 ≤ LEB_SIZE, ⌊err0⌋ ∨ err0 = ESUCCESS, v ∈ vols ∧ m0 < # vols[v] ∨ v = VTBL_VOLID ∧ m0 = VTBL_LNUM ⊦ ⟪skip; vtblpnum0 := vtblpnum1; vols0 := vols; q0 := q; if err = ESUCCESS then {if v = VTBL_VOLID ∧ m0 = VTBL_LNUM then {ubi_wl_put_peb#(VTBL_VOLID × VTBL_LNUM, vtblpnum0; wlar, q); bflipset := bflipset -- vtblpnum0; vtblpnum0 := vtblpnum2} else {vtblpnum3 := m0; if vols[v][vtblpnum3] ≠ unmapped then let vtblpnum0 = vols[v][vtblpnum3].pnum in {ubi_wl_put_peb#(v × vtblpnum3, vtblpnum0; wlar, q); bflipset := bflipset -- vtblpnum0}; vols[v][vtblpnum3] := ⌜vtblpnum2⌝ }; wlar[vtblpnum2] := wl-entry(wlar[vtblpnum2].ec, used)} else ubi_wl_put_peb#(none, vtblpnum2; wlar, q)⟫ ( (err = ESUCCESS ∨ ⌊err⌋ ) ∧ id○(apebs, apebs1, n1) ∧ ubi-io-inv(apebs) ∧ # apebs = # wlar ∧ unique-sqns(apebs) ∧ valid-global-sqn(apebs, sqnum + 1) ∧ valid-wl(apebs, wlar) ∧ valid-eraseq(q) ∧ valid-eraseq(wlar, q) ∧ valid-eraseq(apebs, q) ∧ ¬ VTBL_VOLID ∈ vols ∧ bflipset-cons(bflipset, wlar) ∧ ( v ∈ vols0 ∨ is-encoded(to-vtbl(vols0), subarray(buf, 0, LEB_SIZE)) ∧ n0 = LEB_SIZE ∨ err ≠ ESUCCESS → valid-ebatbl(apebs, wlar, vols, vtblpnum0) ∧ valid-vtbl(apebs, vols, wlar, vtblpnum0)) ∧ ( err = ESUCCESS ∧ v = VTBL_VOLID ∧ m0 = VTBL_LNUM → (∀ v0, m0. ¬ v0 ∈ vols0 ∧ is-encoded(to-vtbl(vols0)[v0, m0], subarray(buf, 0, LEB_SIZE)) ∧ n0 = LEB_SIZE → valid-ebatbl(apebs, wlar, vols[v0, fill(mkebatbl(m0), unmapped)], vtblpnum0) ∧ valid-vtbl(apebs, vols[v0, fill(mkebatbl(m0), unmapped)], wlar, vtblpnum0))) ∧ (err = ESUCCESS ∧ v ∈ vols0 ∧ vols0[v][m0] ≠ unmapped → q = q0 + eq-entry(vols0[v][m0].pnum, v × m0) ') ∧ (err = ESUCCESS ∧ v = VTBL_VOLID ∧ m0 = VTBL_LNUM → q = q0 + eq-entry(vtblpnum1, VTBL_VOLID × VTBL_LNUM) ') ∧ id(apebs, apebs1, mapped-pebs(vols0)) ∧ (v = VTBL_VOLID ∧ m0 = VTBL_LNUM ∨ err ≠ ESUCCESS → vols = vols0) ∧ (v ∈ vols0 ∧ err = ESUCCESS → vols = vols0[v, vols0[v][m0, ⌜n1⌝ ]]) ∧ ( err = ESUCCESS → apebs[n1].fill = datasize(buf, n0) ∧ apebs[n1].data = subarray(buf, 0, n0) + mkempbuf(n2) ∧ q.lebrefs ⊆ q0.lebrefs ++ (v × m0)) ∧ (err ≠ ESUCCESS → q.lebrefs = q0.lebrefs)), vtblpnum1 = n1, VTBL_VOLID ∈ vols, vtblpnum1 ∈ q
Used simplifier rules: ls-datasize-empbuf-append-lower: ⊦ datasize(mkempbuf(n) + buf, n) = 0;%append-a: ⊦ (buf + buf0) + buf1 = buf + buf0 + buf1; from specification array-splice[buffer]