]> git.hungrycats.org Git - linux/commitdiff
read-repair-fixes: new series (repair bio end_io for submit failures)
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Thu, 22 Oct 2026 12:15:25 +0000 (08:15 -0400)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Thu, 22 Oct 2026 12:15:25 +0000 (08:15 -0400)
The read-repair NULL end_io fix is added to both lanes as a new topic.
It is exported here with a 0/1 cover.  TESTING.md (m-reloc's abort arm,
q-repair's fail_function, repair and corrupt-recovery rows) now records
the lane SHAs, and the README has the new row, the ORDER entry and the
new heads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B6wxsJn1aY7PwnhgXdz6Ec

README.md
topics/read-repair-fixes/0000-cover-letter.patch [new file with mode: 0644]
topics/read-repair-fixes/0001-btrfs-give-the-read-repair-bio-an-end_io-for-submit-.patch [new file with mode: 0644]
topics/read-repair-fixes/TESTING.md

index 3fa10b5caccc6f0c4615b844d9a5a36474d58c97..da23f5c0482bf39977acc776006c5ceafd2f9c14 100644 (file)
--- a/README.md
+++ b/README.md
@@ -8,8 +8,8 @@ upstream at all (see the table).
 | | |
 |---|---|
 | base of every series | `0c48d26d46bd` ("btrfs: stop reading free space inodes from the commit root"), the misc-next lane base (`misc-next/testing^1`) |
-| integration branch | `misc-next/testing` `ca79d0a74875` (octopus of all 19 topics) |
-| lane head | `zygo-misc-next-zb64` `62a9fa73e0c9`; its own commits on top of `testing` (kernel configs, `covers/`) are not exported |
+| integration branch | `misc-next/testing` `88248f2a3349` (octopus of all 20 topics) |
+| lane head | `zygo-misc-next-zb64` `a0b180b54ada`; its own commits on top of `testing` (kernel configs, `covers/`) are not exported |
 
 The base is not a published commit: the lane rebuilds it from
 btrfs/for-next plus David Sterba's queue.  It lives in the
@@ -78,6 +78,7 @@ the integration recipe below uses.
 | `replace-fixes` | 7 | `43c8a1e60a5a` | Zygo | new | patch 7 has a btrfs-progs counterpart (`topics/replace-abort-uncorrectable`) |
 | `dev-stats` | 1 | `55ade1cf195c` | Zygo | new, 0/1 (2026-10-21) | behaviour change, offered for rejection; independent of every other series |
 | `resize-missing` | 1 | `8763f9e2126d` | Qu Wenruo, rewritten by Zygo | new, 0/1 (2026-10-21) | Qu's 2019 patch reworked: grow checks now return, absolute sizes checked; Zygo's Signed-off-by to be added before sending |
+| `read-repair-fixes` | 1 | `0bb70f85052f` | Zygo | new, 0/1 (2026-10-22) | upstream bug since v6.3 (Fixes: 7609afac6775): NULL end_io when a repair bio fails to submit |
 
 ## Applying one series
 
@@ -112,7 +113,7 @@ B=0c48d26d46bd
 ORDER="logical-ino-costs balance-resume compress-fixes deadlock-fixes dedupe-fixes
        delalloc-fixes dev-extent-defrag prealloc-size raid56-fixes raid56-scrub-replace
        stripe-alloc low-space dedupe-mtime dm-stripfault allocator-hints read-policies
-       replace-fixes dev-stats resize-missing"
+       replace-fixes dev-stats resize-missing read-repair-fixes"
 
 for t in $ORDER; do
        git checkout -q -b up/$t $B
@@ -134,7 +135,7 @@ plain `git am`, because the later series conflict.  Merging separate
 branches is the supported way.
 
 Verified on the export: the patches of every directory, applied in order
-to `0c48d26d46bd`, give that branch's tree exactly.  Merging all 19 in
+to `0c48d26d46bd`, give that branch's tree exactly.  Merging all 20 in
 the order above with `-X ours` and applying `fixups/post-merge.patch`
 gives the tree of `misc-next/testing` exactly.  The verification used
 git 2.47.
@@ -204,5 +205,5 @@ The fixup adds 640 lines and removes 16, in 10 files.
 - `balance-resume` patch 3 is offered for rejection, as its cover letter
   says.
 - Re-export with `scripts/export.sh` after any lane change.  The
-  directories reflect the lane at `misc-next/testing` `ca79d0a74875`.
+  directories reflect the lane at `misc-next/testing` `88248f2a3349`.
   Commit the result with the misc-next SHAs that the script prints.
diff --git a/topics/read-repair-fixes/0000-cover-letter.patch b/topics/read-repair-fixes/0000-cover-letter.patch
new file mode 100644 (file)
index 0000000..9882050
--- /dev/null
@@ -0,0 +1,52 @@
+From 0bb70f85052f8c7c539a36d596d7ad25402d9869 Mon Sep 17 00:00:00 2001
+From: Zygo Blaxell <ce3g8jdj@umail.furryterror.org>
+Date: Thu, 22 Oct 2026 08:14:28 -0400
+Subject: [PATCH 0/1] btrfs: fix a NULL end_io call when a read repair bio fails to submit
+To: linux-btrfs@vger.kernel.org
+
+Since read repair moved to the storage layer in v6.3, the repair bio has
+a NULL end_io.  Its normal completion goes through btrfs_check_read_bio()
+and never calls end_io.  But btrfs_submit_chunk() can fail a bio before
+it reaches a device: when the block mapping, the bio split or the
+checksum lookup fails.  It then calls end_io, and a btrfs-endio worker
+jumps to address 0.  The original read never completes, and a later
+unmount hangs on it.
+
+The checksum lookup is the failure seen in practice.  A buffered read of
+an old extent searches the csum commit root, but the repair bio searches
+the running transaction's csum tree.  After a transaction abort, the
+cleanup frees that transaction's dirty tree blocks, and a lookup that
+reaches one reads never-written disk and fails with -EIO.  It was found
+when a relocation at a full filesystem forced the filesystem read-only:
+six btrfs-endio workers oopsed within 1.5 seconds.
+
+The patch gives the repair bio an end_io that only this failure
+reaches.  It fails the sector the way an exhausted repair does, so the
+read returns -EIO.  It does not try another mirror, because the mapping
+and the checksum lookup fail the same way for every copy.
+
+Tested on misc-next and 6.18, KASAN kernels, raid1:
+- A deterministic abort trigger (fail a log commit's superblock write,
+  drop the page cache, read a corrupted tail) oopses both lanes.
+  With the patch the read fails with -EIO in under
+  half a second, and the filesystem unmounts.
+- fail_function on btrfs_search_slot, limited to the repair lookup:
+  the lanes oops; with the patch, 3 of 3 runs per lane return -EIO, with
+  every injection confirmed inside a repair lookup.
+- Ordinary read repair (raid1 corrupt mirror, raid6 and raid1c3
+  corrupt-recovery) still returns correct data with the patch.
+
+Not addressed here: the repair bio could search the same csum root as
+the original read, so that repair still works after an abort.
+
+Zygo Blaxell (1):
+  btrfs: give the read repair bio an end_io for submit failures
+
+ fs/btrfs/bio.c | 22 +++++++++++++++++++++-
+ 1 file changed, 21 insertions(+), 1 deletion(-)
+
+
+base-commit: 0c48d26d46bdd6422bb91ba7f1c519a2993116dc
+-- 
+2.47.3
+
diff --git a/topics/read-repair-fixes/0001-btrfs-give-the-read-repair-bio-an-end_io-for-submit-.patch b/topics/read-repair-fixes/0001-btrfs-give-the-read-repair-bio-an-end_io-for-submit-.patch
new file mode 100644 (file)
index 0000000..15420d3
--- /dev/null
@@ -0,0 +1,102 @@
+From 0bb70f85052f8c7c539a36d596d7ad25402d9869 Mon Sep 17 00:00:00 2001
+From: Zygo Blaxell <ce3g8jdj@umail.furryterror.org>
+Date: Thu, 22 Oct 2026 02:16:13 -0400
+Subject: [PATCH 1/1] btrfs: give the read repair bio an end_io for submit
+ failures
+To: linux-btrfs@vger.kernel.org
+
+repair_one_sector() initializes the repair bbio with a NULL end_io.  A
+repair bio normally completes through btrfs_check_read_bio(), which hands
+it to btrfs_end_repair_bio() and never calls end_io.  But
+btrfs_submit_chunk() can fail a bio before it reaches a device: when
+btrfs_map_block() fails, when btrfs_split_bio() fails, or when
+btrfs_lookup_bio_sums() fails for a data read.  It then ends the bio with
+btrfs_bio_end_io(), which calls bbio->end_io.  For a repair bio that is a
+jump to address 0 in a btrfs-endio worker.  The original read never
+completes, and an unmount hangs on it later:
+
+  BUG: kernel NULL pointer dereference, address: 0000000000000000
+  Workqueue: btrfs-endio simple_end_io_work
+  RIP: 0010:0x0
+  Call Trace:
+   btrfs_bio_end_io+0x1b7/0x420
+   btrfs_submit_bbio+0xc1e/0x1fa0
+   btrfs_check_read_bio+0x80e/0x1760
+   simple_end_io_work+0xc8/0x190
+
+The repair bio's checksum lookup can fail where the original read's
+lookup succeeded, because the two search different trees.  A buffered
+read of an extent from a past transaction searches the commit root
+(csum_search_commit_root).  The repair bbio leaves that flag clear and
+searches the running transaction's csum tree.  When that transaction
+aborts, the cleanup frees its dirty tree blocks.  A later lookup reads
+such a block from disk, where it was never written, and fails with -EIO:
+
+  BTRFS error (device dm-6 state EA): bad tree block start, mirror 2 want 31490048 have 14842989077554535085
+  BTRFS error (device dm-6 state EA): bad tree block start, mirror 1 want 31490048 have 8810637562337132983
+
+This was first seen right after a relocation forced the filesystem
+read-only: six btrfs-endio workers oopsed within 1.5 seconds.  It
+reproduces with a raid1 filesystem:
+- Commit a file, write more data so that the csum leaf holding the file's
+  tail is COWed in the running transaction, and corrupt the tail on both
+  mirrors.
+- Abort the transaction by failing a log commit's superblock write, and
+  drop the page cache.
+- A buffered read of the tail now oopses.
+
+Give the repair bbio an end_io for this case.  A failed submission does
+not depend on the mirror: the mapping and the checksum lookup fail the
+same way for every copy.  So give up on the sector the way an exhausted
+repair does: mark the original bio failed, drop the repair's count on
+the failed_bio, and free the repair bio.  The read then fails with -EIO.
+
+Fixes: 7609afac6775 ("btrfs: handle checksum validation and repair at the storage layer")
+Assisted-by: Claude:claude-opus-5-5
+---
+ fs/btrfs/bio.c | 22 +++++++++++++++++++++-
+ 1 file changed, 21 insertions(+), 1 deletion(-)
+
+diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c
+index 2c6234f6182f8..5002fb69c0f03 100644
+--- a/fs/btrfs/bio.c
++++ b/fs/btrfs/bio.c
+@@ -202,6 +202,26 @@ static void btrfs_end_repair_bio(struct btrfs_bio *repair_bbio,
+       bio_put(&repair_bbio->bio);
+ }
+ 
++/*
++ * A repair bio completes through btrfs_check_read_bio() and
++ * btrfs_end_repair_bio(), never through its end_io.  This end_io only runs
++ * when btrfs_submit_bbio() fails the bio before it reaches a device, for
++ * example when the block mapping or the checksum lookup fails.  Neither
++ * depends on the mirror, so give up on the sector instead of trying the
++ * next copy.
++ */
++static void btrfs_repair_bio_submit_failed(struct btrfs_bio *repair_bbio)
++{
++      struct btrfs_failed_bio *fbio = repair_bbio->private;
++
++      btrfs_debug(repair_bbio->inode->root->fs_info,
++                  "repair read submit failed: %d",
++                  blk_status_to_errno(repair_bbio->bio.bi_status));
++      fbio->bbio->bio.bi_status = BLK_STS_IOERR;
++      btrfs_repair_done(fbio);
++      bio_put(&repair_bbio->bio);
++}
++
+ /*
+  * Try to kick off a repair read to the next available mirror for a bad sector.
+  *
+@@ -264,7 +284,7 @@ static struct btrfs_failed_bio *repair_one_sector(struct btrfs_bio *failed_bbio,
+ 
+       repair_bbio = btrfs_bio(repair_bio);
+       btrfs_bio_init(repair_bbio, failed_bbio->inode, failed_bbio->file_offset + bio_offset,
+-                     NULL, fbio);
++                     btrfs_repair_bio_submit_failed, fbio);
+ 
+       mirror = next_repair_mirror(fbio, failed_bbio->mirror_num);
+       btrfs_debug(fs_info, "submitting repair read to mirror %d", mirror);
+-- 
+2.47.3
+
index 3f446df579f8ed0f04785544f1cc806089d533fb..aa6f6f0c3cd357c1f61698421eb22948936a78f4 100644 (file)
@@ -1,9 +1,11 @@
 # 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
+Added to both lanes 2026-10-22.  One patch: "btrfs: give the read repair
+bio an end_io for submit failures": misc-next topic 0bb70f85052f (testing
+88248f2a3349, zb64 a0b180b54ada), 6.18 topic 06844e9bdd0a (testing
+2add79022650, zb64 772b786210dc).  The tested kernels were built from
+refs/cand/m-reloc-repair/{mn,618}/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.