--- /dev/null
+# stripe-alloc: plan to reorder the series by subtopic
+
+o-sord, 2026-10-22. Not committed; for the lead's review.
+
+Source: misc-next/topics/stripe-alloc bcadbfc8ac02 (114 patches on
+0c48d26d46bd). Zygo's requested order:
+
+1. Activation by xattr, basic no-RMW function
+2. xattr to allow RMW for some operations
+3. Stripe-only reclaim for data block groups
+4. Competing fsync implementations
+5. stripe_meta
+6. Debugging code not for upstream
+
+## Result in one paragraph
+
+Every patch has a subtopic (table below). A pure reorder does not work.
+The series grew in the original order, and the later patches edit code
+that the new order puts after them. The trial replays the first 13 patches
+of subtopic 1 with context-only resolutions. It stops at old 24, which
+edits code that old 14 (subtopic 4) and old 20 (subtopic 2) introduce. Per
+the brief, it stops there. There is no `refs/cand/sa-reorder/mn/topic`, no
+boundary build, and no 6.18 run. A build of the 13-patch prefix failed. That
+exposed an include-level dependency on the debug checker (D11), which the
+static analysis had missed. The work that blocks it is structural.
+Section 2 lists eleven dependencies (D1-D11) and the move or split that
+removes each. Five of them need code that no existing patch contains:
+D1, D4, D5, the semantic part of D6, and D10. A mechanical experiment
+(section 3) shows why hunk-moving alone is not enough. Zygo needs to decide
+D1 and D4 before a rebuild can be planned in detail.
+
+## Method
+
+- `git blame base..P^` on the old side of every hunk of every patch finds
+ which series patch wrote each context line or removed line. 177
+ (patch, earlier patch) pairs cross subtopics backwards under the
+ proposed classification.
+- Identifiers new in the series (absent from the base tree), with the
+ first patch that adds each, give about 40 more backward uses: a patch
+ uses a symbol that a later-placed patch defines.
+- The trial is a checkout-free replay. It cherry-picks with `git
+ merge-tree --write-tree --merge-base=P^`. When merge-tree reports a
+ conflict, the trial retries with a line-level 3-way merge. That merge
+ accepts edits that are adjacent but do not overlap. It orders two
+ insertions at the same point by their order in the final tree. For
+ every patch it resolves, the +/- lines are byte-identical to the
+ original patch. The trial stops at the first overlap.
+- A tool check: the replay in the original order reproduces bcadbfc8ac02's
+ tree exactly (d39cc792e5e6).
+
+Scripts and logs are in the job tmp dir: `osord/bin/{replay.py,replay3.py,zmerge.py,blamedeps.py,tokdeps.py}`,
+`osord/{blamedeps.json,tokdeps.json,replay-v3ctx.log,replay3-v3.log,residuals-v3.txt}`.
+
+## 1. Classification
+
+The new numbers are for the order with no splits: S1 1-61, S2 62-72,
+S3 73-77, S4 78-83, S5 84-98, S6 99-114. Within each subtopic the
+original order is kept. Every split in section 2 adds commits and moves
+these numbers.
+
+Summary by subtopic (old numbers):
+
+- S1 (61): 1-6 8-12 17 23-27 30 32-37 40 41 43-45 54 57 60 62-64 67-69
+ 73-77 79 82 84 86 87 89 91 92 95-99 101 109-112
+- S2 (11): 18-21 56 58 66 85 90 100 103
+- S3 (5): 42 46 47 70 114
+- S4 (6): 13-16 83 88
+- S5 (15): 38 48-53 61 65 81 93 102 104 105 106
+- S6 (16): 7 22 28 29 31 39 55 59 71 72 78 80 94 107 108 113
+
+Classification calls worth a second look:
+
+- Relocation under the gate (40, 41, 43-45, 60, 73, 74, 84) is in S1, not
+ S3. Balance, device remove and shrink relocate on every filesystem.
+ Only the reclaim trigger and worker (42, 46, 47), compaction (70) and
+ stripe_reclaim_now (114) are reclaim-specific.
+- 57 (whole stripes stranded behind live runs) is in S1. It applies to
+ any live run, although NOCOW runs motivated it. In S2 it is replayed
+ after S1 patches that later rewrote the same scan code (91), and it
+ conflicts.
+- 81 (META_LOG runs, one per log commit) is in S5. It exists only under
+ raid56 metadata and serves both fsync modes, so it does not belong to
+ the competing implementations.
+- 54 (per-group trapped bytes in the space_info dump) is in S1. It is a
+ line in the existing enospc_debug dump, which is an upstream production
+ diagnostic.
+- 104/105 (comment-only cleanup of the whole series) are at the end of
+ S5, after all upstream code (D7).
+- 27 (mount warning: raid56 metadata not covered) is in S1, where it is
+ true. 38 narrows it and 65 removes it, so the subtopics stay
+ consistent.
+- 113 (dyndbg reclaim log) is in S6, as the brief defines S6. It needs 70
+ (compaction), which is already earlier.
+- S6 follows the brief's definition: stats files (22, 59, 78, 80), the
+ tracepoint (31), audits (29, 55, 72, 94), attribution (71, 107), the
+ checker (7, 39), the unwritten log (108) and the reclaim log (113).
+ This strict reading is what makes D4 expensive.
+
+Debug code wired into production paths:
+
+- 7: the checker is CONFIG_BTRFS_DEBUG only. Its
+ `BLOCK_GROUP_FLAG_STRIPE_RELOC_USED` set_bit sits in
+ do_allocation_stripe() on every build. 19 adds NOCOW_USED next to it,
+ and 20, 24, 32, 38, 58 and 90 edit the checker.
+- 39: its drain worker runs on every runtime enable. It exists only for
+ the checker. 61 extends it with a commit.
+- 28: the "write hole applies" rate-limited warning prints on production
+ kernels. Its counter goes into 22's file.
+- 8: `stripe_unusable_rescan` is a CONFIG_BTRFS_DEBUG sysfs trigger inside
+ a core patch.
+- 30, 35: production tunables (stripe_park_timeout_ms,
+ stripe_park_sync_timeout_ms, stripe_park_congestion) ship in the same
+ patches as debug counters.
+- 31: the pad oracle's return type (`struct btrfs_stripe_pad_info`, the
+ pad-reason enum) is introduced for the tracepoint. It then becomes the
+ oracle's API: 33, 71 and 76 build on it, and 71 records the verdict on
+ every rbio.
+
+### Table
+
+| old | new | S | subject | note |
+|---:|---:|:-:|---|---|
+| 1 | 1 | 1 | add btrfs_claim_free_stripe_run() for stripe-exclusive allocation | |
+| 2 | 2 | 1 | add open stripe run tracking for stripe-exclusive allocation | |
+| 3 | 3 | 1 | add the stripe_alloc allocation policy for raid56 data | |
+| 4 | 4 | 1 | stripe_alloc: control the policy with a filesystem property | activation: the btrfs.stripe_alloc property |
+| 5 | 5 | 1 | report stripe run data IO through the ordered extent lifecycle | |
+| 6 | 6 | 1 | retire stripe runs at commit and gate stripe_alloc | |
+| 7 | 99 | 6 | add a write-hole invariant checker to the raid56 write path | debug: CONFIG_BTRFS_DEBUG checker; its STRIPE_RELOC_USED set_bit sits in do_allocation_stripe() (production path, flag only read by the checker) |
+| 8 | 7 | 1 | account stripe_alloc trapped free space for honest statfs | includes the debug-only sysfs trigger stripe_unusable_rescan and a tracepoint; core is statfs/admission accounting |
+| 9 | 8 | 1 | stripe_alloc: keep an open run per size band to trap less | |
+| 10 | 9 | 1 | stripe_alloc: grow the frontier run instead of stranding its tail | |
+| 11 | 10 | 1 | raid56: batch stripe_alloc partial writes into full-stripe writes | parking is core no-RMW function; its flushes are wired into ordered-extent waits and retirement |
+| 12 | 11 | 1 | stripe_alloc: never claim stripes covered by a live run | |
+| 13 | 78 | 4 | stripe_alloc: settle a logged extent's stripes at log commit | fsync: log-commit settle (shared by both fsync modes) |
+| 14 | 79 | 4 | stripe_alloc: private per-inode stripe runs for log-active inodes | fsync: private LOG runs; also carries the generic private-run machinery S2 needs (see D1) |
+| 15 | 80 | 4 | stripe_alloc: carry an inode's log tail forward at fsync | |
+| 16 | 81 | 4 | stripe_alloc: kick parked rbios before the fast fsync's writeback wait | fsync: parked-rbio kick before the fast fsync's writeback wait |
+| 17 | 12 | 1 | raid56: pad sub-stripe writes to full stripes in open runs | |
+| 18 | 62 | 2 | stripe_alloc: isolate nodatacow and preallocated extents by stripe | allow-rmw: NOCOW class exists only so in-place writes can be confined; reuses old 14's private-run machinery |
+| 19 | 63 | 2 | stripe_alloc: allow-rmw policy, and write-in-place for isolated nocow extents | allow-rmw; its "fsync" word belongs to S4 (see D2); also touches the S6 checker |
+| 20 | 64 | 2 | stripe_alloc: persist nocow runs across commits and remounts | |
+| 21 | 65 | 2 | raid56: do not park sync writes into nocow runs | parking edge for NOCOW runs only |
+| 22 | 100 | 6 | raid56: expose parking statistics in sysfs | debug: stats file; later core patches add counters to it (D4) |
+| 23 | 13 | 1 | raid56: skip parking for sync rbios finished by their unplug batch | parking edge, generic |
+| 24 | 14 | 1 | stripe_alloc: count open stripe run remainders against data reservations | |
+| 25 | 15 | 1 | stripe_alloc: pessimistic data reservation margin | |
+| 26 | 16 | 1 | stripe_alloc: claim fully-free stripes that span free space entries | |
+| 27 | 17 | 1 | stripe_alloc: warn when raid56 metadata is not covered | user-facing mount warning; superseded by 38 and removed by 65 |
+| 28 | 101 | 6 | stripe_alloc: report read-modify-write of uncovered stripes | debug/observability: rate-limited "write hole applies" warning plus meta_rmw counter; the warning is production-visible |
+| 29 | 102 | 6 | raid56: say whether a metadata read-modify-write is a write hole | debug: metadata RMW audit (reads headers under the stripe lock) |
+| 30 | 18 | 1 | stripe_alloc: tunable park deadlines, and say why padding declined | mixed: park-deadline tunables (production knobs) + data_rmw and pad_decline counters (debug) |
+| 31 | 103 | 6 | stripe_alloc: trace why padding declined, at the moment it declined | debug: tracepoint; but it also creates btrfs_stripe_pad_info and the pad-reason enum that 33, 71, 76 build the pad oracle on (see D4) |
+| 32 | 19 | 1 | stripe_alloc: complete parked writes on allocation coverage, not clocks | core parking; edits the fsync kick (16) and settle (13) too |
+| 33 | 20 | 1 | stripe_alloc: track per-sector liveness and pad from the map | core liveness map; moved out of old 38; edits 31's pad_info API |
+| 34 | 21 | 1 | stripe_alloc: count claimable whole-stripe supply directly | |
+| 35 | 22 | 1 | raid56: adaptive park deadline from the parked-rbio backlog | production knob stripe_park_congestion (default off) + counters |
+| 36 | 23 | 1 | stripe_alloc: gate data admission on claimable whole-stripe supply | |
+| 37 | 24 | 1 | stripe_alloc: cache a failed stripe run scan per block group | |
+| 38 | 84 | 5 | stripe_meta: allocate tree blocks by whole stripes | |
+| 39 | 104 | 6 | stripe_alloc: drain the legacy allocator's writes before arming the write-hole check at a runtime enable | debug: exists only to keep the write-hole checker quiet; the drain worker runs on every runtime enable (production path) |
+| 40 | 25 | 1 | stripe_alloc: keep the admitted bytes placeable when a group goes read-only | admission correctness; read-only transitions come from scrub and balance too |
+| 41 | 26 | 1 | stripe_alloc: never let relocation wait on the whole-stripe gate | relocation (balance) correctness under the gate, not reclaim-specific |
+| 42 | 73 | 3 | stripe_alloc: give a queued stripe group a chunk to relocate into when the supply is short | reclaim worker chunk preallocation; tests btrfs_is_stripe_meta_bg (D5) |
+| 43 | 27 | 1 | stripe_alloc: charge relocation a margin per reservation, not per extent | relocation admission, used by balance |
+| 44 | 28 | 1 | stripe_alloc: keep the relocation group's stripes out of the admission supply | relocation admission, used by balance |
+| 45 | 29 | 1 | stripe_alloc: let a data write fall back to the relocation group rather than drop | relocation fallback, used by balance |
+| 46 | 74 | 3 | stripe_alloc: hand groups full of trapped free space to the reclaim worker | reclaim trigger |
+| 47 | 75 | 3 | stripe_alloc: relocate a queued stripe group even while it has reserved or pinned bytes | reclaim worker; tests btrfs_is_stripe_meta_bg (D5) |
+| 48 | 85 | 5 | stripe_meta: maintain trapped free space for metadata groups like data | |
+| 49 | 86 | 5 | stripe_meta: back the global reserve with usable stripes, and say when a tree block finds none | |
+| 50 | 87 | 5 | stripe_meta: hold back whole stripes so tree blocks always land and trapped groups can be reclaimed | |
+| 51 | 88 | 5 | stripe_meta: do not steal from the global reserve below the relocation reserve | |
+| 52 | 89 | 5 | stripe_meta: let the transaction machinery's own reservations draw on the reserve | |
+| 53 | 90 | 5 | stripe_meta: let a group go read-only for relocation against the reserve | |
+| 54 | 30 | 1 | stripe_alloc: show per-group trapped bytes in the space info dump | space_info dump (enospc_debug) line; production diagnostic, kept upstream-side |
+| 55 | 105 | 6 | stripe_alloc: tell a dead tree block from a live one in the metadata RMW audit | debug: RMW audit refinement |
+| 56 | 66 | 2 | stripe_alloc: do not read an inline backref off a keyed-ref extent item | fix to 20's stripe_extents_owned_by() |
+| 57 | 31 | 1 | stripe_alloc: count whole stripes stranded behind live runs as trapped | generic admission accounting (stranded behind any live run); motivated by NOCOW runs; touches 46's reclaim predicate |
+| 58 | 67 | 2 | stripe_alloc: give nocow extents a private run only while they may be written in place | NOCOW run lifecycle under the allow_rmw policy |
+| 59 | 106 | 6 | stripe_alloc: count nocow run lifecycles and stranded stripes in sysfs | debug: stripe_run_stats; later core patches add counters to it (D4) |
+| 60 | 32 | 1 | stripe_alloc: hold a stripe of margin across a preallocation | admission: preallocation margin (fallocate, relocation, encoded write) |
+| 61 | 91 | 5 | stripe_meta: carry raid56 metadata groups through a runtime enable or disable | stripe_meta runtime enable/disable; touches 39's drain worker |
+| 62 | 33 | 1 | stripe_alloc: return a group's allocation cluster before scanning its stripes | runtime-enable scan fix (data groups under ssd_spread, metadata groups) |
+| 63 | 34 | 1 | stripe_alloc: release open stripe runs when a mount fails or an aborted filesystem unmounts | teardown; motivated by metadata runs but releases every class |
+| 64 | 35 | 1 | stripe_alloc: say at mount whether the policy is on | mount message; touches 39's worker comment |
+| 65 | 92 | 5 | stripe_meta: cover raid56 system chunks | stripe_meta system chunks |
+| 66 | 68 | 2 | stripe_alloc: close dead nocow stripe runs at commit | NOCOW dead-run close; adds btrfs_stripe_run_note_free() on the free path |
+| 67 | 36 | 1 | stripe_alloc: do not round a full stripe with power-of-two macros | helper used by 19/20 (nocow writable, re-adoption) and 13/15 (settle); fixes code of several subtopics |
+| 68 | 37 | 1 | stripe_alloc: do not wait for stripe runs to drain on an errored filesystem | errored-fs drain; also stops reclaim on an errored fs |
+| 69 | 38 | 1 | stripe_alloc: end the commit-time and log drains on an errored filesystem too | errored-fs drain; one hunk is in the fsync settle wait (S4) |
+| 70 | 76 | 3 | stripe_alloc: compact mostly live groups instead of skipping them | compaction |
+| 71 | 107 | 6 | stripe_alloc: attribute each data read-modify-write to why padding declined | debug: RMW attribution counters; records the pad verdict on the rbio |
+| 72 | 108 | 6 | stripe_alloc: optionally audit data read-modify-writes against the committed extent tree | debug: CONFIG_BTRFS_DEBUG audit |
+| 73 | 39 | 1 | stripe_alloc: keep relocation's stripe runs until relocation ends | relocation runs retained (balance); tests BTRFS_STRIPE_RUN_META (D5) |
+| 74 | 40 | 1 | stripe_alloc: let relocation allocate a data chunk before it fails | |
+| 75 | 41 | 1 | stripe_alloc: keep a stripe in the rbio cache until its run has written all of it | core: rbio pin; data correctness under strip faults |
+| 76 | 42 | 1 | stripe_alloc: pad a stripe's allocated sectors whose write is still to come | core: pad unwritten sectors; edits 71's attribution |
+| 77 | 43 | 1 | stripe_alloc: apply the property before tree-log replay | activation: property applied before log replay |
+| 78 | 109 | 6 | stripe_alloc: count refused rbio pins and track rbio cache high water | debug: pin counters |
+| 79 | 44 | 1 | stripe_alloc: sweep stale rbio pins, and commit when live pins run low | core: stale-pin sweep + commit request; counters ride along |
+| 80 | 110 | 6 | stripe_alloc: break rbio pins and open stripe runs down by run class | debug: per-class pin/run counters; refactors btrfs_stripe_run_incomplete() into a wrapper |
+| 81 | 93 | 5 | stripe_alloc: give each log commit its own metadata stripe run | stripe_meta: META_LOG runs (log tree metadata); serves fsync under raid56 metadata for both fsync modes |
+| 82 | 45 | 1 | stripe_alloc: don't make a parked rbio wait for sectors that will never be written | core parking |
+| 83 | 82 | 4 | stripe_alloc: share LOG data runs per log transaction | fsync: shared LOG runs per log transaction (the default mode) |
+| 84 | 46 | 1 | stripe_alloc: let relocation allocate as many data chunks as its reservation needs | |
+| 85 | 69 | 2 | stripe_alloc: key private stripe runs by subvolume and inode | fixes 18/19/20 (NOCOW) and 83 (LOG) and 81 (META_LOG owner); S4/S5 hunks go with them |
+| 86 | 47 | 1 | stripe_alloc: do not treat an allocation error as a found extent | fixes 3, 14, 38 |
+| 87 | 48 | 1 | stripe_alloc: mark an ended ordered extent's sectors written | fixes 83 (S4), 75, 76; marking is generic |
+| 88 | 83 | 4 | stripe_alloc: read the shared LOG run mode once per log settle | fsync: shared-mode knob read once |
+| 89 | 49 | 1 | stripe_alloc: remove only the set bits of a bitmap when claiming a split run | |
+| 90 | 70 | 2 | stripe_alloc: claim a stripe tail in one free space lock section | |
+| 91 | 50 | 1 | stripe_alloc: keep the stripe totals consistent with the groups during the commit scan | |
+| 92 | 51 | 1 | stripe_alloc: do not delete an unused block group that still has stripe runs | fixes 3, 20, 38 |
+| 93 | 94 | 5 | stripe_meta: commit before waiting for metadata runs when making a group read-only | stripe_meta read-only commit |
+| 94 | 111 | 6 | raid56: do not read tree blocks under the stripe lock in the metadata RMW audit | debug: fix to 29/55 audits |
+| 95 | 52 | 1 | raid56: stop the park timer before destroying the raid56 workqueue | teardown: park timer vs workqueue |
+| 96 | 53 | 1 | stripe_alloc: order the filesystem error before waking stripe drain waiters | errored-fs wake ordering |
+| 97 | 54 | 1 | raid56: set a padded rbio's data bitmap under bio_list_lock | |
+| 98 | 55 | 1 | stripe_alloc: forget the failed-claim verdict when a cluster returns its space | |
+| 99 | 56 | 1 | stripe_alloc: do not let a remount revert the stripe_alloc property | activation: remount must not revert the property |
+| 100 | 71 | 2 | stripe_alloc: do not block a NOWAIT write in the nocow stripe check | fix to 19 |
+| 101 | 57 | 1 | stripe_alloc: keep the head of a claimed free space entry under the lock | |
+| 102 | 95 | 5 | stripe_meta: check the block group lookup when freeing an unwritten tree block | fix to 38 |
+| 103 | 72 | 2 | stripe_alloc: remove the unused stripe_rmw_opt field | removes 19's dead field |
+| 104 | 96 | 5 | stripe_alloc: correct and trim the block group comments | comment-only, all of block-group.[ch]; placed after all upstream code (end of S5); its hunks in S6 code must move to S6 (D7) |
+| 105 | 97 | 5 | stripe_alloc: correct and trim the comments outside the block group code | comment-only, rest of the series; same treatment as 104 |
+| 106 | 98 | 5 | stripe_meta: keep waiting for metadata runs that do not drain at commit | fix to 38 |
+| 107 | 112 | 6 | stripe_alloc: remove pad refusal reasons that no longer exist | debug: removes dead pad reasons/counters (71/30/31) |
+| 108 | 113 | 6 | stripe_alloc: count and log ordered extents that end with sectors unwritten | debug: counter + rate-limited log; the marking it counts is 87's |
+| 109 | 58 | 1 | stripe_alloc: skip RAID5/6 groups that are mapped as RAID1/RAID1C3 | generic; tests stripe_meta too |
+| 110 | 59 | 1 | stripe_alloc: count single-data-stripe groups' free space in write admission | admission; prints bytes_stripe_reserve (50, S5) in the dump |
+| 111 | 60 | 1 | stripe_alloc: account claimable stripes while a trim has them out | admission vs trim; tests btrfs_is_stripe_meta_bg (D5) |
+| 112 | 61 | 1 | stripe_alloc: do not miss bitmap free space when debiting a trim | |
+| 113 | 114 | 6 | log block group reclaim at debug level | debug: dyndbg reclaim log the harness reads |
+| 114 | 77 | 3 | stripe_alloc: add stripe_reclaim_now to reclaim stripes on demand | reclaim on demand; tests btrfs_is_stripe_meta_bg (D5) |
+
+## 2. Dependencies and the moves or splits that remove them
+
+"Mechanical" means the split only divides a patch's own +/- lines. The
+part that edits later-subtopic code moves to right after the patch that
+introduces that code, as a follow-up commit or folded into it. "Needs
+code" means the split creates an intermediate state that no existing
+commit contains, such as a changed signature, a shortened condition, or
+code at a different place. Zygo or the lead should approve those.
+
+**D1. S2 is built on old 14 (S4). Needs code.**
+14 ("private per-inode stripe runs for log-active inodes") introduces the
+machinery that all of S2 uses:
+- the run `owner` field and btrfs_alloc_from_inode_stripe_run();
+- owner lookup under stripe_run_lock;
+- the `inode` parameter of btrfs_reserve_extent() and all its callers;
+- the commit-time retirement that walks the run list instead of the band
+ slots. Private runs are never in a slot, so without the walk they are
+ never closed.
+
+18 parameterises all of this by class to add NOCOW. 20, 58, 66, 85, 90
+and 100 build on 18. The experiment moved 86 lines of 18 and 75 of 20
+into S4. Nothing of S2 works before then.
+- Proposed split: 14a "private per-inode stripe runs" goes into S2 before
+ 18 (or at the end of S1). It contains the owner field, the
+ class-parameterised allocator in the form 18 gives it, the list-walk
+ retirement and the reserve_extent plumbing. 14b "steer log-active
+ inodes into private LOG runs" stays in S4: the LOG class,
+ BTRFS_INODE_LOG_ALLOC set at fsync entry, log_run_hint, and the
+ for_log_inode steering. 18 shrinks to the NOCOW class and its
+ steering. 14a has no exact counterpart in any existing commit.
+- Alternative with no new code: move 14 whole into S2 just before 18.
+ S2 then contains LOG steering with nothing that settles it. That is
+ harmless at runtime: fsync'd inodes get private runs, and commit
+ retirement closes them. It contradicts the brief's definition of S4.
+
+**D2. The "fsync" word of old 19's allow_rmw. Mechanical.**
+19 parses `fsync` and checks BTRFS_STRIPE_RMW_FSYNC in four places:
+- the settle (13);
+- the carry (15, defrag.c);
+- btrfs_sync_file's LOG flag (14);
+- the reserve_extent steering (14).
+
+Move the word into S4 as its own patch after 15: the parser branch, the
+mask bit, the four checks and the show side. S2 keeps nodatacow and
+prealloc. The parser loses one `else if`, and the S4 patch adds it back.
+
+**D3. Edits to the write-hole checker (old 7, S6). Mechanical.**
+19, 20, 24, 32, 38, 58 and 90 change the checker's skip conditions, or
+set flags that only the checker reads (NOCOW_USED, RELOC_USED). These
+hunks follow 7 into S6. The set_bit calls they move are in production
+allocation paths, so S1-S5 lose dead code and nothing else.
+
+**D4. Observability that later core code builds on (22, 31, 59). Needs code.**
+Two parts:
+- Counters. stripe_park_stats (22) is bumped in 30, 32, 33, 35, 75, 76
+ and 79. stripe_run_stats (59) is bumped in 66, 67, 69, 70, 73, 75, 81,
+ 83, 88 and 92. Moving each increment, field and sysfs line to S6 is
+ mechanical. It is about 25 S6 follow-up commits.
+- The pad API. 31 created `btrfs_stripe_pad_info` and the pad-reason
+ enum for its tracepoint. 33 (liveness map, btrfs_stripe_run_pad_mask)
+ and 76 (pad unwritten sectors) are written against that API, and 71
+ records the verdict on the rbio. With 31 in S6 the experiment moved
+ 122 lines of 33 and 35 lines of 76 into S6. That means S1 would keep
+ the frontier-based pad oracle from 17 and lose the liveness map, which
+ is a correctness piece. Keeping 31 in S6 needs 33 and 76 rewritten
+ without `info`. That is new code in two core patches.
+- Recommendation, for Zygo to decide:
+ - (a) S1 keeps 22, 30, 31 and 59 as "observability" (the files, the
+ struct and the enum), and S6 keeps only the self-contained debug
+ features: 7, 28, 29, 39, 55, 71, 72, 78, 80, 94, 107, 108, 113. A
+ final S6 patch can delete the stats files and the tracepoint if
+ upstream review wants them gone.
+ - (b) Take the strict reading, and rewrite 33 and 76 plus about 25
+ counter splits.
+
+ Under (a), D4 disappears except for the 71/72/78/80 hunks inside 73,
+ 75, 76, 79, 83, 85 and 88. Those are counters and attribution, and
+ splitting them is mechanical.
+
+**D5. stripe_meta (old 38) terms inside S1 and S3 patches. Needs code (one line each).**
+- 42, 47, 111 and 114 test `|| btrfs_is_stripe_meta_bg(bg)` or
+ `&& !btrfs_is_stripe_meta_bg(bg)`.
+- 73 tests `run->class != BTRFS_STRIPE_RUN_META && !run->retained`.
+
+Each needs a data-only form of the line in S1/S3, and a one-line S5 patch
+that adds the metadata term back. Deferring the hunks whole does not
+work: the experiment moved 73's entire retained-run logic (20 lines) into
+S5, because it sits next to the META line. 63 releases runs of every
+class at teardown and moves unchanged.
+
+Two more hunks are mechanical and simply follow their target into S5:
+109 edits btrfs_is_stripe_meta_bg() itself, and 75 adds a declaration
+next to 38's.
+
+**D6. S1 edits to settle and carry code (old 13/15, S4). Mostly mechanical.**
+- 24 adds stripe_open_remainder_sync() calls in the private-run and settle
+ paths (14 lines).
+- 25's margin touches the carry re-dirty in defrag.c.
+- 32 and 33 edit the settle walk.
+- 67 replaces round_down() in btrfs_log_settle_stripes().
+- 69 adds the errored-fs term to the settle wait.
+
+These hunks follow 13/15 into S4. Two are semantic and not just
+textual: 33's settle hunk uses the liveness map, and 32 edits 16's
+fast-fsync kick. Both are fine once 33 itself is in S1 (D4).
+
+**D7. Comment-only cleanups 104 and 105. Mechanical.**
+They touch every subtopic. Place them at the end of S5, after all
+upstream code, and move their hunks in S6 code into one S6 comment patch:
+the RMW audit, the debug sysfs attributes, the checker and the drain
+worker. Do not spread them over the subtopics. The experiment did that,
+and it produced 25 residual commits for these two patches alone.
+
+**D8. old 83 (S4) and old 81 (S5). Mechanical.**
+- 83 adds `log_run_opened` and other counters beside 81's in fs.h and
+ sysfs.c.
+- 85 (subvolume keying) edits LOG (14/83, S4) and META_LOG (81, S5) owner
+ matching.
+
+These hunks follow 83 and 81. 85's NOCOW part stays in S2.
+
+**D9. S3 and S5 code inside S1 patches. Mechanical.**
+- 57 changes btrfs_stripe_bg_wants_reclaim() (46, S3): stranded bytes
+ are excluded from the trapped bytes reclaim counts. 57 also adds
+ `stripe_stranded` to the space_info dump format, whose
+ `stripe_reserve` field comes from 50 (S5).
+- 91 adds `&& btrfs_test_opt(STRIPE_ALLOC)` to 50's reserve-clearing
+ branch (S5).
+- 110 prints `bytes_stripe_reserve` (50, S5).
+
+Each hunk follows its target into S3 or S5.
+
+**D10. Fixes moved ahead of the code they meet. Needs re-resolution.**
+In the original order some S2/S5 patches came before an S1 fix to the same
+lines. In the new order the S1 fix is replayed first, and the S2/S5
+patch then meets text it was never written against. Seen:
+- 90 (S2, claim a stripe tail) against 101 (S1, claim head under the
+ lock), in free-space-cache.c.
+- 57 against 91 in the stripe_unusable scan.
+- 104 against 57/59.
+
+Each needs one merge written by hand. The final tree gives the target
+text, but the intermediate state is new.
+
+**D11. The `#include "block-group.h"` in raid56.c comes from old 7 (S6). Mechanical.**
+11 (parking) calls btrfs_stripe_in_open_run() from raid56.c, and 17
+calls btrfs_stripe_run_pad_start(). raid56.c gets the header from 7's
+checker. Neither blame nor the identifier scan sees this, and the
+prefix build found it (section 6). Move the include line into 11. This
+also shows that blame and identifier analysis miss include-level
+dependencies. Every boundary tree of a real rebuild has to be built,
+not just checked by analysis.
+
+What D1-D11 leave: with D4 (a), the subtopics stay as classified. The
+splits are 14→14a/14b, 19→19 + fsync-word, 104 and 105 each →
+upstream + S6 part, five or six one-line meta re-additions, and about 15
+mechanical follow-ups (D3, D6, D8, D9, D11, and the remaining D4
+counters/attribution). The series grows from 114 to about 135 commits,
+unless the follow-ups are folded into the patches they follow. Folding
+is cleaner for review but changes those patches.
+
+## 3. The deferral experiment: why moving hunks is not enough
+
+To measure D1-D10 rather than guess them, a second replay
+(`osord/bin/replay3.py`, order = the classification above) ran without
+stopping at overlaps. When a patch's hunk overlapped code from a patch
+not yet applied, it held that hunk back. It then emitted the hunk as a
+"fixup! <subject>" commit right after the patch that introduces the code,
+with the original author. This is not a proposal. It shows where each
+patch's lines want to live.
+
+- The replay got through 118 of 137 items: 95 original patches and 23
+ fixups.
+- It stopped at old 104 (S5). 104's comment rewrite in block-group.c
+ overlaps lines that 57 (S1) wrote, and no later patch owns them. This
+ is D10's kind of conflict and needs a hand merge.
+- Ref: `refs/cand/sa-reorder/mn/experiment-deferral` = c113d49f9228.
+ Every hunk is a cherry-picked original hunk, but the intermediate trees
+ were not built. Do not use it as a series.
+
+Where the held-back hunks went (66 groups; the full diffs are in
+`osord/residuals-v3.txt`):
+
+| from | to after | lines | what |
+|---|---|---:|---|
+| S2 old18 | S4 old14 | 86 | the NOCOW class inside 14's private-run code (D1) |
+| S2 old20 | S4 old14 | 75 | nocow-run persistence inside 14's code (D1) |
+| S2 old20 | S6 old7 | 109 | checker skips for NOCOW groups (D3) |
+| S1 old33 | S6 old31 | 122 | the liveness-map pad oracle written on 31's pad_info (D4) |
+| S1 old33 | S4 old15 | 14 | settle walk uses the liveness map (D6) |
+| S1 old33 | S2 old19 | 26 | pad mask beside NOCOW-run checks |
+| S1 old75 | S2 old19 | 131 | the written map (pure insertion anchored in 19's nocow helpers; placing it elsewhere is a context-only change) |
+| S1 old76 | S6 old31 / old71 | 35 + 22 | pad-unwritten written against the pad API and attribution (D4) |
+| S1 old79 | S6 old78 | 75 | stale-pin sweep inside 78's counter code (D4) |
+| S4 old83 | S6 old59 | 132 | shared LOG runs' seal_log_stripe() and settle code, anchored next to 59's carry counter (D4/D8) |
+| S1 old73 | S5 old38 | 20 | relocation's retained runs, next to the META line (D5) |
+| S1 old30/32/35 | S6 old22/29/31 | ~75 | counter fields and sysfs lines (D4) |
+| S2 old19 | S4 old14/15 | 23 | the "fsync" allow_rmw word (D2) |
+| S1 old24 | S4 old14/15, S6 old7 | 19 | remainder sync in private-run and settle code (D6) |
+| S1 old57 | S3 old46, S5 old50 | 10 | reclaim predicate, dump format (D9, D5) |
+| S1 old91 | S5 old50 | 8 | reserve-clearing condition in 50's code |
+| others | | small | counters, comments (104/105 placement), declarations |
+
+The biggest moves would gut S1: the liveness-map oracle (33), the
+written map (75), pad-unwritten (76) and the pin sweep (79). The same is
+true of S2 (18 and 20). That is the evidence for D1 (split 14) and D4
+(a) (keep 22/31/59 in S1). Once those two decisions are made, the
+remaining moves are small and mechanical.
+
+## 4. Conflict log (trial `refs/cand/sa-reorder/mn/partial-s1`)
+
+Replay in the classified order, with context-only resolutions:
+
+| new | old | result | resolution |
+|---:|---:|---|---|
+| 1-6 | 1-6 | clean | |
+| 7 | 8 | conflict in block-group.h | 8's runtime flag goes in the enum next to the slot of 7's `BLOCK_GROUP_FLAG_STRIPE_RELOC_USED`, which is absent here. Adjacency only; +/- lines identical to the original. |
+| 8-11 | 9-12 | clean | |
+| 12 | 17 | conflict in block-group.c, block-group.h | 17's pad helpers and prototypes are inserted where 13/15's settle functions and prototypes sit in the original. Adjacency only; +/- lines identical; insertion order taken from the final tree. |
+| 13 | 23 | conflict in raid56.c | 23's unplug-batch check is next to 21's NOCOW sync-write test and 22's stats increments. Adjacency only; +/- lines identical. |
+| 14 | 24 | **STOP** | 24 ("count open stripe run remainders against data reservations") changes lines in btrfs_alloc_from_inode_stripe_run() (old 14, S4), the settle path (13/15, S4), and the run-tail code that 20 (S2) rewrote. This is not context. Resolving it means writing 24 without those hunks and re-adding them later (D6, D1). The brief says to stop here. |
+
+## 5. Candidate refs and oracle
+
+In ~/share/linux:
+
+| ref | SHA | what | oracle |
+|---|---|---|---|
+| refs/cand/sa-reorder/mn/partial-s1 | 0a5df3ca5081 | new 1-13 (old 1-6, 8-12, 17, 23) on 0c48d26d46bd | authorship (name, email, date) and subjects match the 13 originals exactly; final-tree oracle not applicable (prefix); does not compile without D11's include move (section 6) |
+| refs/cand/sa-reorder/mn/experiment-deferral | c113d49f9228 | section 3's experiment, 118 items, stops at old 104 | none; evidence only |
+| refs/cand/sa-reorder/mn/topic | not created | | final tree == d39cc792e5e6 not reached |
+| refs/cand/sa-reorder/618/topic | not created | brief: only if mn succeeds | |
+
+Tool check: the same replay code in the original order reproduced tree
+d39cc792e5e6 exactly.
+
+## 6. Builds
+
+There are no subtopic boundaries to build, because the reorder did not
+complete. One extra build of the only consistent prefix shows that the
+three adjacency resolutions compile. 17 normally sits after 13-16, and
+here it compiles without them.
+
+Build setup: ahive (idle on #5, never rebooted). Scratch worktree
+/mnt/linux/wt-osord-mn, which was registered (harness map row 02cd4e7)
+and removed afterwards (1a64411). Config config-r5fix-mn-kasan plus
+olddefconfig. Each build ran `make W=1 fs/btrfs/` and then `make
+bzImage` (bzImage only).
+
+| tree | W=1 fs/btrfs | bzImage |
+|---|---|---|
+| partial-s1 0a5df3ca5081 (new 1-13) | **FAIL**: `raid56.c:790 implicit declaration of btrfs_stripe_in_open_run`, `raid56.c:2737 implicit declaration of btrfs_stripe_run_pad_start` | FAIL (same) |
+| partial-s1 + `#include "block-group.h"` in raid56.c (scratch 6ca27b5ae550, deleted) | PASS | PASS (39383552 bytes) |
+
+The failure is D11: the include comes from old 7 (S6). With the include
+moved into old 11, the prefix compiles, so the three adjacency
+resolutions are sound. The only W=1 warning is
+`tree-log.c:3602 frame size 1056 > 1024`. It is pre-existing: no patch
+in the prefix touches tree-log.c.
+
+## 7. 6.18 lane
+
+Not attempted, per the brief, because mn did not complete. For planning:
+6.18/topics/stripe-alloc (1977bbfdee3c, 130 patches on v6.18.57) maps by
+subject to all 114 mn patches except one. mn's old 27 "warn when raid56
+metadata is not covered" is "warn at mount when raid56 metadata is not
+covered" on 6.18. The 16 subjects that exist only on 6.18 classify as
+follows:
+
+| 6.18 # | subject | subtopic |
+|---:|---|---|
+| 7 | refuse space_cache=v1 | S1 |
+| 41 | do not count trapped free space twice when making a block group read-only | S1 (fix to 40) |
+| 62 | charge the held stripe margin against every admission | S1 |
+| 63 | admit data reservations by whole stripes | S1 |
+| 65 | hold the probe margin until the metadata reservation charges it | S1 (data admission margin; read) |
+| 66 | saturate the read-only guard's claimable subtraction | S1 (fix to 40) |
+| 68 | charge the preallocation's stripe hold under the reservation lock | S1 (fix to 60) |
+| 70 | stripe_meta: sync the open-run remainder when the commit retires metadata runs | S5 |
+| 71 | raid56: do not call a covered stripe_meta group uncovered | S6 (fix to 28's warning; uses stripe_meta, fine since S6 is last; read) |
+| 73 | let the property accept a cache-less filesystem like the mount option does | S1 |
+| 75 | hold a reference on the rbio being parked | S1 |
+| 76 | drop the mount options, the property is the interface | S1 (mn never had the options) |
+| 82 | grant the stripe_meta reserve to all of a relocation | S5 |
+| 83 | stripe_meta: let mount-time orphan cleanup steal from the global reserve | S5 |
+| 85 | compact a mostly live group by its trapped share of the group | S3 (fix to 70) |
+| 127 | do not refuse leftover v1 space cache inodes | S1 (fix to 7) |
+
+The rows marked "read" were checked against the patch. The others are
+classified from the subject and the memory notes only. The 6.18 lane has mount options that are later dropped (76),
+which mn does not have, so S1 on 6.18 carries one more interface change.
+
+## 8. Per-subtopic summaries (for the cover letter)
+
+The ranges use the no-split numbering of section 1. The splits proposed
+in section 2 add about 20 commits and will shift them.
+
+### 1. Activation by property and basic no-RMW function (new 1-61)
+
+Under stripe_alloc, raid56 data is allocated so that a stripe holding
+committed data is never written by a partial stripe write. The write
+hole then cannot reach data that a completed transaction made durable.
+
+Mechanisms:
+- Claim rule: allocation takes runs of wholly free stripes (old 1, 26,
+ 89, 101).
+- Open runs: per size band, the frontier run grows instead of stranding
+ its tail (2, 9, 10, 12).
+- Run IO is reported through the ordered-extent lifecycle (5, 87).
+- Commit retirement closes and drains runs before the commit's super, so
+ nothing reopens a stripe across transactions (6, invariants I1-I4).
+- Partial writes inside an open run are parked and batched into
+ full-stripe writes. Otherwise they are padded: unallocated or
+ abandoned sectors are zero-filled (11, 17, 23, 32, 82).
+ - A per-sector liveness map decides what may be padded (33).
+ - A written map pins a stripe in the rbio cache until its run has
+ written all of it (75, 79).
+ - Sectors whose write is still to come get padded too (76).
+- Accounting: trapped free space (partial stripes nobody may write) is
+ out of statfs and df (8, 54). Whole-stripe supply is counted directly
+ (34). Data admission is gated on claimable whole stripes, with a
+ margin per extent and the open-run remainders charged (24, 25, 36, 57,
+ 60, 110, 111, 112).
+- Relocation (balance, device remove, shrink) works under the gate: it
+ is exempt from the gate, gets margins and fallback groups, and its runs
+ are retained until relocation ends (40, 41, 43-45, 73, 74, 84).
+- Lifecycle and robustness: runtime enable and disable, remount, log
+ replay ordering, errored filesystems, mount failure, and teardown (62,
+ 63, 68, 69, 77, 92, 95, 96, 99).
+- 109 skips raid5/6 groups that are mapped as raid1/raid1c3 (3-device
+ raid6).
+
+Knobs:
+- `btrfs.stripe_alloc` property on the top-level subvolume's root
+ directory (`setfattr -n btrfs.stripe_alloc -v 1`). Deleting it turns
+ the policy off. It requires the free space tree and refuses zoned,
+ remap-tree and mixed-bg filesystems. Copies on received or cloned
+ subvolumes are ignored. No on-disk format change: an older kernel
+ uses the legacy allocator.
+- Mount prints whether the policy is on (64). It warns that raid56
+ metadata is uncovered (27) until S5.
+- sysfs `allocation/data/`: `bytes_stripe_unusable`, `bytes_stripe_open`,
+ `bytes_stripe_margin`, `bytes_stripe_claimable`, `bytes_stripe_stranded`.
+- Park tunables `stripe_park_timeout_ms` (100), `stripe_park_sync_timeout_ms`
+ (3) and `stripe_park_congestion` (0, off).
+- Under D4 (a), also the read-only `stripe_park_stats` and
+ `stripe_run_stats` and the pad-decline tracepoint.
+
+### 2. Property to allow RMW for some operations (new 62-72)
+
+Without this subtopic, stripe_alloc forces COW on nodatacow files and
+preallocated extents. A second property lets the administrator allow
+in-place writes again. The blast radius stays bounded: in-place writes
+are allowed only into stripes isolated to the writing inode, so a
+degraded crash can tear only that file's own data, which is the
+nodatacow contract.
+
+Mechanisms:
+- NOCOW-class private runs, keyed by subvolume and inode (18, 85; after
+ 14a under D1).
+- An ownership check: the fast path uses the inode's own runs, the slow
+ path the committed extent tree's single plain ref (19, 56, 100).
+- Legacy nocow files migrate themselves in one COW generation.
+- NOCOW runs persist across commits and remounts while the policy allows
+ in-place writes (20, 58), and dead runs close at commit (66).
+- Sync writes into NOCOW runs are not parked (21).
+- 90 and 103 are small fixes and cleanups.
+
+Knob: `btrfs.stripe_alloc_allow_rmw`, a word list of `nodatacow` and
+`prealloc`. The `fsync` word moves to S4 (D2).
+
+### 3. Stripe-only reclaim for data block groups (new 73-77)
+
+Trapped tails pile up until something relocates their groups, and the
+stock trigger keys on used bytes, so it never sees them.
+
+Mechanisms:
+- A group whose trapped bytes reach `bg_reclaim_threshold` of its free
+ space goes to the existing reclaim worker. The trigger runs from the
+ cleaner tick as well as the commit rescan, with a room check and a
+ five-minute hysteresis (46).
+- The worker relocates queued groups even with reserved or pinned bytes
+ (47). It allocates a chunk to relocate into when supply is short (42).
+- Compaction for mostly live groups. It moves only the closure of the
+ partial stripes under "shares an extent with" (union-find over the
+ extent items). It falls back to whole relocation when the closure is
+ more than half the live bytes (70).
+- On-demand reclaim (114).
+
+These paths also serve S5's metadata groups. S3 contains the
+`|| btrfs_is_stripe_meta_bg()` terms only after the D5 split.
+
+Knobs:
+- `bg_reclaim_threshold` (the existing per-space_info knob; the trigger compares trapped bytes against it, 46).
+- `stripe_compact`: percent of the group trapped before compaction,
+ default 10.
+- `stripe_reclaim_now` (write-only): `all`/`1`, or a group's logical
+ start.
+
+### 4. Competing fsync implementations (new 78-83)
+
+stripe_alloc alone confines the write hole to the current transaction.
+Inside that window two log commits can still share a stripe, so a later
+RMW can tear data that an earlier fsync made durable. The base, 13,
+settles logged extents at each log commit: it closes the stripe's run,
+kicks parked writes, and waits for the run's data IO before the log
+super is written. This closes the hole for completed fsyncs. The cost
+is a trapped tail per fsync per touched stripe. The two implementations
+that pay that cost back are:
+
+- **Private runs with carry-forward** (14, 15; 16 is the parked-rbio
+ kick before the fast fsync's writeback wait):
+ - Each log-active inode gets a private LOG run, which each log commit
+ closes.
+ - The logged extents in the closed run's final partial stripe are
+ recorded. At the next fsync they are re-dirtied defrag-style, so
+ the flush rewrites them into the new run and the old stripe frees
+ whole.
+ - One partial stripe per inode per fsync. A back-to-back fsync loop
+ rewrites its previous tail each time.
+- **Shared LOG runs per log transaction, the default** (83, 88):
+ - LOG runs are keyed by (subvolume, log_transid), so inodes logging in
+ one log transaction fill the same stripes. Allocations of a full
+ stripe or more keep a private run.
+ - The log commit does not close the run. It seals the stripe holding
+ the end of the logged extent: the frontier moves to the stripe end,
+ and the skipped sectors are padded by the stripe's final write.
+ - The settle waits, with no timeout, only until every allocated sector
+ of the logged extent's stripes is written (the written map).
+ - Nothing is carried forward. Leftover partial stripes wait for frees
+ or compaction.
+
+Why shared is the default (Zygo's ruling, 2026-10-06, fsync-log-mode
+bench; the measurements are in 83's message):
+- Setup: 5 x 8 GiB raid5 data, raid1 and raid5 metadata, compared
+ against private runs with carry-forward.
+- At 16 and 64 writers, and with one fsync per inode: 1.2-2.9x the
+ fsyncs/s (one 64-writer rep of eight was 0.8x), and 3-8x fewer device
+ bytes per fsync. Later bench #280: 1.3-3x the fsyncs/s at 4-64
+ writers, with p99.9 latency at 0.1-0.7x.
+- One writer: parity on latency, with 17-29% fewer device bytes.
+- The workload that can lose: two large streaming writers beside small
+ fsync writers, at 0.5-1.9x the fsyncs/s. A small fsync waits for
+ neighbours that joined its stripe. The multi-second p99.9 there is
+ btrfs's log-commit tail, which both modes show and stock raid5 shows
+ too (17.1 s).
+- An earlier mode 1 was dropped. Of the park-ceiling variants, only C1
+ (ceiling from live sectors) was kept.
+
+Knobs:
+- `stripe_log_data_shared` (sysfs, default 1; 0 selects private runs
+ with carry-forward).
+- `btrfs.stripe_alloc_allow_rmw` word `fsync` (D2): waives the
+ log-window guarantee, so no settle and no carry.
+- Counters in `stripe_run_stats`: `log_settle_waits` and
+ `log_settle_wait_ns` (both modes), `log_carry_*` (private),
+ `log_seals` and `log_seal_bytes` (shared).
+
+### 5. stripe_meta (new 84-98)
+
+raid56 metadata gets the data rule. Tree blocks come from runs of wholly
+free stripes, and a stripe is never revisited once its transaction has
+written it. There is no separate switch: raid56 metadata is covered
+whenever stripe_alloc is on, and other profiles have no write hole.
+
+Mechanisms:
+- Metadata write completion reports, and abandoned tree blocks are
+ reported too (38, 102).
+- Two-phase retirement: metadata runs close after the commit writes its
+ tree blocks (38, 106).
+- Trapped-space accounting for metadata groups (48).
+- A global reserve backed by usable stripes (49), and a whole-stripe
+ reserve that relocation alone may draw on. It prevents fill-edge
+ transaction aborts and lets trapped metadata groups be reclaimed (50,
+ 51, 52, 53, 93).
+- Runtime enable and disable (61), and system chunks (65).
+- META_LOG runs: each log commit gets its own metadata stripe run, keyed
+ by (root, log_transid), so log blocks that fsync made durable are never
+ RMWed by the next writer (81).
+ - Trapped space returns once the log tree frees.
+ - Metadata total settles around 2.15x the plain allocator's.
+- 104 and 105 (comment cleanup of the whole series) close the upstream
+ part (D7).
+
+Knobs:
+- `allocation/metadata/bytes_stripe_reserve`, and the S1 counters for
+ metadata.
+- `stripe_log_run` (sysfs, default 1) switches META_LOG runs.
+- The S1 mount warning is narrowed by 38 and removed by 65.
+
+### 6. Debugging code not for upstream (new 99-114)
+
+- The write-hole invariant checker and its runtime-enable drain (7, 39).
+- The metadata RMW audit (29, 55, 94).
+- The CONFIG_BTRFS_DEBUG data-RMW audit against the committed extent
+ tree (72: `debug/stripe_rmw_audit` and `debug/stripe_rmw_audit_stats`).
+- RMW attribution by pad-decline reason (71, 107).
+- The "write hole applies" warning for uncovered RMWs (28).
+- Counters: refused pins and rbio-cache high water (78), the per-class
+ breakdown (80), and ordered extents that end with sectors unwritten
+ (108).
+- The dyndbg reclaim log (113).
+- Under D4 (b) this subtopic would also hold `stripe_park_stats` (22),
+ the pad-decline tracepoint (31) and `stripe_run_stats` (59).
+- `space_info/stripe_unusable_rescan` (debug, from 8) should move here
+ as a split of 8. That split is mechanical.
+
+Wired into production paths: see section 1 (7's RELOC_USED and 19's
+NOCOW_USED set_bit calls, 39's drain worker, 28's warning).