]> 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>
Mon, 2 Nov 2026 02:16:29 +0000 (21:16 -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 080e2707239bedc8d9798bdeb1fd1f0095b76367..1eabdc2653b26088fafc17558375d134d7c0495d 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) {