]> git.hungrycats.org Git - linux/commitdiff
zygo: btrfs: prefer aligned dev_extent holes when allocating chunks (v3, handle last...
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Mon, 4 Mar 2024 07:51:00 +0000 (02:51 -0500)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Mon, 4 Mar 2024 07:51:00 +0000 (02:51 -0500)
fs/btrfs/volumes.c

index 1de26a61ca13165f731ce4f0850916cd905581bf..4985407db76c327073bf166cc4400f5347eb6f4b 100644 (file)
@@ -1737,7 +1737,11 @@ next:
                        goto again;
                }
 
-               if (hole_size > max_hole_size) {
+               /*
+                * If this is a larger hole it might not be aligned.
+                * Keep the hole we found above if it was large enough.
+                */
+               if (hole_size > max_hole_size && max_hole_size < num_bytes) {
                        max_hole_start = search_start;
                        max_hole_size = hole_size;
                }