need the balance passed into `btrfs_relocate_chunk()` (shared with
shrink and device remove).
-Candidates (not promoted, not built): `refs/cand/bl1108/{misc-next,7.3,6.18}/balance-resume`;
+Candidates: `refs/cand/bl1108/{misc-next,7.3,6.18}/balance-resume`
+(6.18 promoted 2026-11-09, see "6.18 gate" below; misc-next and 7.3 not
+built or promoted);
misc-next/7.3 without the remap commit (the vrange commits replay clean
without it). Oracles: patch 1/3 content lines unchanged (md5
236bb8028b25 / efe8a0e1ef5a), patch 2 identical on all three lanes
| Test | Checks | Patch | Time | Current | Kernel |
|---|---|---|---|---|---|
-| `balance-resume-limit-test.sh` arm 1 (new) | `limit=N` (N = M-1 data chunks), pause after k, unmount: on-disk item (dump-tree) shows N-k, skip_balance mount shows `limit=N-k`, resume: total N; bpftrace: one item update per chunk the resume relocated | 2 | - | not run | - |
-| arm 2a | `limit=M..M`: on disk (M-k)..(M-k), total M | 2 | - | not run | - |
-| arm 2b | `limit=1..M-2`: on disk max(1-k,0)..(M-2-k), total M-2 | 2 | - | not run | - |
-| arm 3a | `limit=N`, ioctl resume on the same mount: in-memory `limit=N-k`, total N | 2 (guard) | - | not run | - |
-| arm 3b | `limit=M..M`, ioctl resume: in-memory (M-k)..(M-k), total M | 2 | - | not run | - |
-| arm 4 | no limit: 0 item updates over pause + resume (bpftrace: `btrfs_search_slot()` on the balance key with ins_len 0, cow 1, robust to inlining); positive control `limit=2`: exactly 2 | 2 | - | not run | - |
-| arm 5 | dm-log-writes, `limit=N` to the end, every flush state replayed in order and read with dump-tree: with the item present, R + L in {N, N+1}; counts the N+1 states | 2 | - | not run | - |
-| arm 6 (opt-in) | per-chunk item update fails (-ENOMEM via bpf override): balance ends -12, item deleted, fs writable, no BUG, a new balance starts | 2 | - | not run | - |
-| arm `alias` (informational) | `limit=M+2` with M matches: how many relocate (see open items) | - | - | not run | - |
+| `balance-resume-limit-test.sh` arm 1 (new) | `limit=N` (N = M-1 data chunks), pause after k, unmount: on-disk item (dump-tree) shows N-k, skip_balance mount shows `limit=N-k`, resume: total N; bpftrace: one item update per chunk the resume relocated | 2 | 1 min | PASS x2 on #10 (ahive): 5 0 on disk, limit=5, total 6, 5 updates; FAIL on #9: on disk 6 0, limit=6, total 7, 0 updates | #10, #9 |
+| arm 2a | `limit=M..M`: on disk (M-k)..(M-k), total M | 2 | 1 min | PASS x2 on #10: 6 6, total 7; FAIL on #9: 7 7, total 1 (the resume relocated none) | #10, #9 |
+| arm 2b | `limit=1..M-2`: on disk max(1-k,0)..(M-2-k), total M-2 | 2 | 1 min | PASS x2 on #10: 0 4 (progs shows `limit=..4`), total 5; FAIL on #9: 1 5, total 6 | #10, #9 |
+| arm 3a | `limit=N`, ioctl resume on the same mount: in-memory `limit=N-k`, total N | 2 (guard) | 1 min | PASS on #10 and on #9, as expected | #10, #9 |
+| arm 3b | `limit=M..M`, ioctl resume: in-memory (M-k)..(M-k), total M | 2 | 1 min | PASS x2 on #10; FAIL on #9: in memory `limit=7..6` (limit_min never counted down), total 1 | #10, #9 |
+| arm 4 | no limit: 0 item updates over pause + resume (bpftrace: `btrfs_search_slot()` on the balance key with ins_len 0, cow 1, robust to inlining); positive control `limit=2`: exactly 2 | 2 | 1 min | PASS x2 on #10: 0 and 2; FAIL on #9: 0 and 0 | #10, #9 |
+| arm 5 | dm-log-writes, `limit=N` to the end, every flush state replayed in order and read with dump-tree: with the item present, R + L in {N, N+1}; counts the N+1 states | 2 | 2 min | PASS x2 on #10; FAIL on #9: R + L up to N+5 | #10, #9 |
+| arm 6 (opt-in) | per-chunk item update fails (-ENOMEM via bpf override): balance ends -12, item deleted, fs writable, no BUG, a new balance starts | 2 | 1 min | PASS x2 on #10: status -12, 2 relocated, item gone, writable, then limit=1 relocated 1; FAIL on #9: no injection (no update to fail) | #10, #9 |
+| arm `alias` (informational) | `limit=M+2` with M matches: how many relocate (see open items) | - | 1 min | M=7, limit=9: 6 relocated on #10 and on #9 (the model in open items predicts 6) | #10, #9 |
Expected on a kernel without patch 2: arm 1 FAILs (on-disk N, total up
to k+N), 2a FAILs (total k: the resume counts M-k < M), 2b FAILs
(total > M-2), 3b FAILs (total k), arm 4's positive control FAILs (0
updates), arm 5 FAILs (R + L grows past N+1); 3a PASSes.
+#### 6.18 gate (2026-11-09, ahive)
+
+Kernel #10: KASAN + lockdep + BTRFS_ASSERT, nfsd built in, for
+zygo-6.18.x-zb64 1492be3a7e5b (testing 2eaf811267a1 = e07c041af8e3 with
+the limit commit in balance-resume's slot; then the NFS config commit).
+#10 was built at its parent 7038b6b5d3d5 with NFSD/NFS_V4_1/NFS_V4_2 set
+by hand; the two trees differ only in .config, and the KASAN .config
+derived from 1492be3a7e5b is byte-identical to the one #10 was built
+with. Control #9 (8ce830755b7f, e07c041af8e3: patches 1 and 3 only,
+patch 1 without the round-2 error message). Taint 0 and debug_locks 1
+throughout; no KASAN/WARNING/BUG/lockdep lines; no NORESERVE or
+unwritten-on-end lines; the sampled unwritten_on_end* counters stayed 0
+(truncated delta 0).
+
+| Test | #10 | #9 |
+|---|---|---|
+| `balance-resume-limit-test.sh` all arms (incl. 6) | PASS x2 | arms 1, 2a, 2b, 3b, 4, 5, 6 FAIL, 3a PASS, as predicted |
+| `balance-resume-convert-test.sh` x2, `balance-resume-test.sh` | PASS | - |
+| `balance-resume-reuse-test.sh` | PASS x3 (a first run SKIPped: layout not reached) | - |
+| `balance-resume-legacy-test.sh check` plain, convert, vrange, convert-vrange, vrange-max (images written by stock Debian 6.12.115) | PASS | - |
+| fl1106 `nounmount-check.sh` (ioctl resume on the same mount) | PASS | - |
+| `remap-balance-resume-test.sh`, `remap-balance-leak-test.sh` | SKIP (6.18 has no remap tree), as expected | - |
+| `nocmtime-test.sh` (nc1108), local and NFS arms | PASS | - |
+
+The first two #10 runs of the limit test FAILed arms 1, 2a, 2b and 4 on
+two harness defects, both fixed before the PASS runs: the bpftrace count
+was read before bpftrace printed it (`wait` from a subshell returns at
+once), and progs prints a range with a 0 minimum as `limit=..4`. The #9
+control was rerun with the fixed script; same verdicts.
+
Open, for this round:
- `__btrfs_balance()`'s `limit_min` check reads `bctl->data.limit_min`
for every chunk type with no flag test ("limit_min is 0 by default"),
- but `limit_min` is the low 32 bits of a single `limit`. On paper,
- `limit=L` with M <= L-2 matching chunks relocates nothing (count M <
- limit_min = L-1 after the first selection). Upstream since 12907fc79818
- (2015), independent of this series; arm `alias` reports it. The
- limit tests use L <= M so they do not depend on it.
+ but `limit_min` is the low 32 bits of a single `limit`.
+ `should_balance_chunk()` has already counted `limit` down for the
+ chunk, so the i-th match (from 0) sees limit_min = L-1-i and is skipped
+ while M < L-1-i. So `limit=L` with M matches skips the first L-M-1 of
+ them (each still uses up one of the limit) and relocates 2M+1-L; none
+ at L >= 2M+1. Measured 2026-11-09: M=7, limit=9 relocated 6 on #9 and
+ on #10. An earlier note here said "relocates nothing" for L >= M+2;
+ that ignored the decrement. Upstream since 12907fc79818 (2015),
+ independent of this series, and patch 2 does not change it (a single
+ limit never touches limit_min). The limit tests use L <= M, so they
+ do not depend on it.
- METADATA_REMAP chunks are counted at selection and queued;
`count_limited_chunk()` is not called for them, and a pause drops the
queue with the budget consumed (pre-existing; in memory and on disk