]> git.hungrycats.org Git - linux/commitdiff
btrfs: stripe_alloc: report read-modify-write of uncovered stripes
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Sat, 19 Sep 2026 17:17:48 +0000 (13:17 -0400)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Sun, 8 Nov 2026 23:37:47 +0000 (18:37 -0500)
The mount-time warning says which block groups stripe_alloc does not
cover.  It cannot say whether anything is actually landing there, and on
a filesystem with raid56 metadata that is the interesting question: every
sub-stripe write to an uncovered stripe is a write hole window, where
parity and data reach the disk separately and a crash in between leaves
the stripe unreconstructible.

Report it from the one place that knows the write is going out as a
read-modify-write rather than as a full or padded stripe.  Rate limited,
because a raid56-metadata filesystem does this continuously and the point
is to make the exposure visible rather than to fill the log.  (A
meta_rmw counter in stripe_park_stats, to read the rate off without
grepping dmesg, is debug code and is added in the debug subtopic.)

Silent when stripe_alloc is off: there the whole filesystem works this
way and the user has asked for nothing else.

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

index 2faea2718dc44ffba1c665c61157c82b0a1278e1..1cde0837951d0e04849701ed6ccdfe2a32d2e207 100644 (file)
@@ -2819,6 +2819,27 @@ static bool need_read_stripe_sectors(struct btrfs_raid_bio *rbio)
        return false;
 }
 
+/*
+ * Count and audit a metadata or system read-modify-write
+ * (audit_uncovered_rmw()), and warn if it lands in a raid56 group that
+ * stripe_meta does not cover.  Silent when stripe_alloc is off.
+ */
+static void report_uncovered_rmw(struct btrfs_raid_bio *rbio)
+{
+       struct btrfs_fs_info *fs_info = rbio->bioc->fs_info;
+
+       if (!btrfs_test_opt(fs_info, STRIPE_ALLOC))
+               return;
+       /* Data groups are btrfs_is_stripe_alloc_bg()'s. */
+       if ((rbio->bioc->map_type & BTRFS_BLOCK_GROUP_DATA) &&
+           !(rbio->bioc->map_type & BTRFS_BLOCK_GROUP_METADATA))
+               return;
+
+       btrfs_warn_rl(fs_info,
+"read-modify-write of full stripe %llu: this block group is not covered by stripe_alloc, the raid56 write hole applies to it",
+                     rbio->bioc->full_stripe_logical);
+}
+
 static void rmw_rbio(struct btrfs_raid_bio *rbio)
 {
        struct bio_list bio_list;
@@ -2864,6 +2885,10 @@ static void rmw_rbio(struct btrfs_raid_bio *rbio)
                        goto out;
        }
 
+       /* Still a sub-stripe write: this stripe is being modified in place. */
+       if (!rbio_is_full(rbio) && !test_bit(RBIO_PADDED_BIT, &rbio->flags))
+               report_uncovered_rmw(rbio);
+
        /*
         * At this stage we're not allowed to add any new bios to the
         * bio list any more, anyone else that wants to change this stripe