]> git.hungrycats.org Git - linux/commitdiff
zygo: btrfs: prefer aligned dev_extent holes when allocating chunks (v4, handle last...
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Thu, 4 Apr 2024 04:11:35 +0000 (00:11 -0400)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Thu, 4 Apr 2024 04:11:35 +0000 (00:11 -0400)
fs/btrfs/volumes.c

index 5076156e77a6b49c85c6a314b96ceb19141ca411..f190f6a8dff6c682c0160c2dbde1fecc819144b0 100644 (file)
@@ -1745,6 +1745,17 @@ next:
                        max_hole_start = search_start;
                        max_hole_size = hole_size;
                }
+
+               /*
+                * The last hole may be aligned and longer than any other,
+                * so do the aligned check and exit early again.
+                */
+               if (hole_size >= num_bytes && (search_start & (SZ_1G - 1)) == SZ_1M) {
+                       max_hole_start = search_start;
+                       max_hole_size = hole_size;
+                       ret = 0;
+                       goto out;
+               }
        }
 
        /* See above. */