]> git.hungrycats.org Git - linux/commitdiff
btrfs: stripe_meta: sync the open-run remainder when the commit retires metadata...
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Wed, 16 Sep 2026 05:20:32 +0000 (01:20 -0400)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Wed, 16 Sep 2026 21:40:07 +0000 (17:40 -0400)
btrfs_retire_meta_stripes() closes the committing transaction's metadata
runs and returns their tails, which shrinks the group's open-run
remainder, but never folded that delta into the space_info's
bytes_stripe_open: the next allocation from the group carried it, so
the counter only lagged by a commit while the policy was on.  After a
runtime disable nothing allocates from the group again and the
remainder of the runs the last commit retired stayed counted as used
metadata for the life of the mount (147456 bytes in
stripe-meta-toggle-test.sh, after the disable had already zeroed the
group's trapped and claimable bytes).

Sync after the closes, as the data-side retirement does.

Assisted-by: Claude:claude-fable-5-1
fs/btrfs/block-group.c

index 3cf5da6b0f23223a0dce656b9deff51574ca2c51..128daaa70d80a25db94fb8cf808e16e6e065167f 100644 (file)
@@ -2567,6 +2567,14 @@ void btrfs_retire_meta_stripes(struct btrfs_fs_info *fs_info, u64 transid)
                        if (tail_len)
                                btrfs_add_free_space(bg, tail_start, tail_len);
                }
+               /*
+                * The closes above shrank the group's open-run remainder;
+                * fold the delta into the space_info now.  While the policy
+                * is on the next allocation from this group would carry it,
+                * but after a runtime disable nothing allocates here again
+                * and the stale remainder holds metadata back for good.
+                */
+               stripe_open_remainder_sync(bg);
 
                /*
                 * Every tree block is on disk, so end_bbio_meta_write() has