--- /dev/null
+# Testing: read-repair-fixes
+
+CANDIDATE topic, not promoted. One patch: "btrfs: give the read repair bio
+an end_io for submit failures" (refs/cand/m-reloc-repair/{mn,618}/topic
+0bb70f85052f / 06844e9bdd0a on 0c48d26d46bd / v6.18.57; zb64 c5dc301213ee /
+c3dbf52a35a8 on the lanes 2550544f9c6e / 7626a4a10198). It fixes an
+upstream bug present since 7609afac6775 (v6.3). btrfs/for-next and v6.18.57
+have the same code.
+
+`repair_one_sector()` builds the repair bbio with end_io = NULL. When
+`btrfs_submit_chunk()` fails a repair bio before it reaches a device
+(btrfs_map_block, btrfs_split_bio or btrfs_lookup_bio_sums fails),
+`btrfs_bio_end_io()` calls that NULL end_io. A btrfs-endio worker then
+oopses with RIP 0, the original read never completes, and a later umount
+hangs. The patch adds an end_io that only this failure reaches. It marks
+the original bio failed, drops the repair's count on the failed_bio and
+frees the repair bio, so the read fails with -EIO. It does not try another
+mirror: the mapping and the checksum lookup fail the same way for every
+copy.
+
+To verify, a test must:
+- make a repair bio fail at submission, with a detector that proves the
+ failure happened (a run where every repair submits cleanly proves
+ nothing);
+- show the lane oopses;
+- show the candidate returns EIO promptly with no oops and still unmounts;
+- show ordinary read repair still returns correct data.
+
+Found in m-reloc's relocation runs: six oopses 1.5 s after a relocation
+abort forced the filesystem read-only (forensics m-reloc-20261021,
+lane-relocate).
+
+## New tests
+
+| test | verifies | patch(es) | duration | last result | date | kernel | harness | evidence |
+|---|---|---|---|---|---|---|---|---|
+| `read-repair-submit-fail-test.sh` RR_ARM=abort | a repair bio whose csum lookup fails at submission (-EIO after an abort) does not oops; the read fails with EIO; unmount works | 1 | ~3 min | lane FAIL as expected on #5 (568c45b64012), misc-next lane 2550544f9c6e (`7.3.0-rc7+ #1`) and 6.18 lane 7626a4a10198 (`6.18.57+ #1`): 1 hit, `BUG: kernel NULL pointer dereference` (RIP 0, btrfs_bio_end_io <- btrfs_submit_bbio <- btrfs_check_read_bio), read hung. Candidate PASS on mn c5dc301213ee (`#2`) and 6.18 c3dbf52a35a8 (`#2`): 17 hits, EIO in 0.3-0.4 s, no oops, unmounted | 2026-10-22 | as listed (dhive, KASAN + lockdep) | working copy of read-repair-submit-fail-test.sh (commit pending, see harness log) | harness `forensics/m-reloc-repair-20261022/` |
+| same, RR_ARM=repair (control) | one mirror corrupt, no abort: reads return the file's data through read repair | 1 | ~3 min | PASS on #5 and both candidates: 2 reads correct, 10 "read error corrected", scrub clean | 2026-10-22 | #5; mn #2; 6.18 #2 | as above | as above |
+| W=1 `fs/btrfs/bio.o` | no new warnings | 1 | - | none on either lane, before or after the patch; bzImage links on all four kernels | 2026-10-22 | mn 2550544f9c6e / c5dc301213ee; 6.18 7626a4a10198 / c3dbf52a35a8 | - | `build-{mn,618}/w1-*.txt` |
+
+**read-repair-submit-fail-test.sh, abort arm.**
+
+The original buffered read and its repair read look the checksums up in
+different trees. The read searches the csum commit root
+(`csum_search_commit_root`, an extent from a past transaction). The repair
+bbio has that flag clear and searches the running transaction's csum tree.
+The test:
+- commits a 256 MiB file A (csum tree level 1) with a preallocation past
+ its end;
+- writes B into the preallocation without committing. B's csums COW the
+ rightmost leaf, which also holds A's tail. B must not allocate a block
+ group, because that forces the next fsync into a full commit;
+- corrupts A's tail on both raid1 mirrors;
+- turns both members' superblock copies into dm-flakey error_writes
+ segments, so that an fsync of a new file aborts the transaction in
+ btrfs_sync_log;
+- drops the page cache, then reads A's tail.
+
+The read finds its csums. The repair's lookup re-reads the freed leaf from
+a location that was never written ("bad tree block start" on both mirrors)
+and returns -EIO. Without `drop_caches` the freed leaf comes back uptodate
+from the btree inode's page cache and nothing fails.
+
+Kprobe events detect the trigger. A hit is a repair bbio's
+`btrfs_lookup_bio_sums` returning -5; a run with no hit is INVALID. The
+`inject` arm (fail_function on btrfs_search_slot in kworkers, added by
+q-repair) needs CONFIG_FAULT_INJECTION and was not run on these kernels.
+
+## Open
+
+- Possible follow-up: the repair bbio could inherit `csum_search_commit_root`
+ from the failed bbio, so read repair keeps working after an abort as the
+ original read does. Not done; the fix above is needed either way, for
+ the other submit failures.