From: Zygo Blaxell Date: Mon, 4 Mar 2024 07:51:00 +0000 (-0500) Subject: zygo: btrfs: prefer aligned dev_extent holes when allocating chunks (v3, handle last... X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=825cb15cd8a02a083042cc6fa12767ec1805f92d;p=linux zygo: btrfs: prefer aligned dev_extent holes when allocating chunks (v3, handle last hole correctly) --- diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 1de26a61ca13..4985407db76c 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -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; }