]> git.hungrycats.org Git - linux/commit
btrfs: do not write repaired read sectors back on a read-only mount
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Thu, 27 Aug 2026 20:38:12 +0000 (16:38 -0400)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Wed, 16 Sep 2026 21:39:59 +0000 (17:39 -0400)
commitc4abba564de4300b7539ee02c09abbc672812786
treeaa3332e5b3ed873900bd416313f3b7064967419a
parentf9cf5c743247b3648932cffc9ba5a68994408aa9
btrfs: do not write repaired read sectors back on a read-only mount

btrfs_end_repair_bio() submits btrfs_repair_io_failure() for every bad
mirror once a repair read has produced good data, with no check of the
mount state.  On a read-only mount the write trips
ASSERT(!(fs_info->sb->s_flags & SB_RDONLY)) in btrfs_repair_io_failure()
(kernel BUG on assert-enabled builds); without assertions it would issue
a write to a filesystem the user was promised is read-only.

Easily reproduced with a degraded raid56 mounted ro,degraded: every
read of a stray sector on the missing device reconstructs through
parity, then tries to write the reconstruction back.

Serve the read from the repaired data but skip the write-back when the
filesystem is read-only.

Assisted-by: Claude:claude-fable-5
fs/btrfs/bio.c