]> git.hungrycats.org Git - linux/commitdiff
btrfs: stripe_alloc: allow-rmw policy, and write-in-place for isolated nocow extents...
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Sat, 19 Sep 2026 17:17:40 +0000 (13:17 -0400)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Sun, 8 Nov 2026 23:38:03 +0000 (18:38 -0500)
The hunks of "btrfs: stripe_alloc: allow-rmw policy, and write-in-place
for isolated nocow extents" (earlier in this series) that need code from
"btrfs: stripe_alloc: settle a logged extent's stripes at log commit",
which comes after it in this series: they are applied here, once "btrfs:
stripe_alloc: settle a logged extent's stripes at log commit" is in,
instead of with the rest of "btrfs: stripe_alloc: allow-rmw policy, and
write-in-place for isolated nocow extents".

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

index 54e2540a74fe66f18227f91e234786b5df7ee6a6..236a873e648c63105b6ab858f8960d16520b0759 100644 (file)
@@ -1892,6 +1892,9 @@ void btrfs_log_settle_stripes(struct btrfs_fs_info *fs_info, u64 bytenr,
        u64 flush_start = 0;
        u64 flush_len = 0;
 
+       /* stripe_alloc_allow_rmw=fsync waives the log-commit guarantee. */
+       if (btrfs_stripe_allow_rmw(fs_info) & BTRFS_STRIPE_RMW_FSYNC)
+               return;
        if (list_empty_careful(&fs_info->open_stripe_bgs))
                return;
        bg = btrfs_lookup_block_group(fs_info, bytenr);
@@ -1902,6 +1905,14 @@ void btrfs_log_settle_stripes(struct btrfs_fs_info *fs_info, u64 bytenr,
        list_for_each_entry(run, &bg->open_stripe_runs, list) {
                if (bytenr < run->start || bytenr >= run->offset)
                        continue;
+               /*
+                * A nodatacow file's logged extents get no fsync survival
+                * guarantee -- the file's own later in-place writes can
+                * always tear them -- so closing its run would trap the
+                * tail for nothing.
+                */
+               if (run->class == BTRFS_STRIPE_RUN_NOCOW)
+                       break;
                flush_start = run->start;
                flush_len = run->end - run->start;
                if (run->open) {