diff mbox series

[3/4] btrfs-progs: fix ordering of hole_size setting and dev_extent_hole_check()

Message ID 20220406014313.993961-4-naohiro.aota@wdc.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: zoned: fix mkfs failure on various zone size | expand

Commit Message

Naohiro Aota April 6, 2022, 1:43 a.m. UTC
The hole_size is used by dev_extent_hole_check() to check the hole is OK as
a device extent. However, commit b031fe84fda8 ("btrfs-progs: zoned:
implement zoned chunk allocator") mis-ported the kernel code and placed
dev_extent_hole_check() before setting hole_check. That made the
dev_extent_hole_check() call here essentially pass through as we have
hole_size == 0 on mkfs time.

As a result, mkfs.btrfs creates data BG at 64 MB where the regular
superblock exists, when zone size is 16 MB.

Fix the ordering of hole_size setting and calling dev_extent_hole_check().

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
---
 kernel-shared/volumes.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/kernel-shared/volumes.c b/kernel-shared/volumes.c
index e24428db8412..0199bc26a8b4 100644
--- a/kernel-shared/volumes.c
+++ b/kernel-shared/volumes.c
@@ -774,14 +774,13 @@  next:
 	 * search_end may be smaller than search_start.
 	 */
 	if (search_end > search_start) {
+		hole_size = search_end - search_start;
 		if (dev_extent_hole_check(device, &search_start, &hole_size,
 					  num_bytes)) {
 			btrfs_release_path(path);
 			goto again;
 		}
 
-		hole_size = search_end - search_start;
-
 		if (hole_size > max_hole_size) {
 			max_hole_start = search_start;
 			max_hole_size = hole_size;