]> git.hungrycats.org Git - linux/commitdiff
btrfs: stripe_alloc: track per-sector liveness and pad from the map (allow_rmw part)
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Sat, 19 Sep 2026 17:17:53 +0000 (13:17 -0400)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Sun, 8 Nov 2026 23:37:57 +0000 (18:37 -0500)
The hunks of "btrfs: stripe_alloc: track per-sector liveness and pad
from the map" (earlier in this series) that need code from "btrfs:
stripe_alloc: allow-rmw policy, and write-in-place for isolated nocow
extents", which comes after it in this series: they are applied here,
once "btrfs: stripe_alloc: allow-rmw policy, and write-in-place for
isolated nocow extents" is in, instead of with the rest of "btrfs:
stripe_alloc: track per-sector liveness and pad from the map".

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

index e4be43e01e6ab811897b350837cd0e59c008e4ad..02db80be2abd2700dda412095d549878e3005867 100644 (file)
@@ -1853,12 +1853,18 @@ bool btrfs_stripe_open_run_class(struct btrfs_fs_info *fs_info, u64 logical,
                return false;
        spin_lock_irqsave(&bg->stripe_run_lock, flags);
        list_for_each_entry(run, &bg->open_stripe_runs, list) {
-               if (logical >= run->start && logical < run->end) {
-                       if (class)
-                               *class = run->class;
-                       ret = true;
-                       break;
-               }
+               if (logical < run->start || logical >= run->end)
+                       continue;
+               /*
+                * Draining runs match too (see btrfs_stripe_in_open_run()):
+                * a closed run's end is shrunk to its frontier, so a write
+                * into it is below the frontier and its stripes are still
+                * exclusive.
+                */
+               if (class)
+                       *class = run->class;
+               ret = true;
+               break;
        }
        spin_unlock_irqrestore(&bg->stripe_run_lock, flags);
        btrfs_put_block_group(bg);