]> 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>
Fri, 18 Sep 2026 21:36:30 +0000 (17:36 -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 d86619188687898dbf3fd162eca55ffc932bcbbe..8c60950a64088c525b5b733ca89f595502d5b30c 100644 (file)
@@ -2600,6 +2600,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