Skip to contentSkip to conversation

btrfs: mkfs: use sectorsize as nodesize for mixed profiles

PATCH In review Qu Wenruo 2 participants 2 messages Apr 3, 2022 – Apr 11, 2022 Btrfs file system

lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

PATCH 1/1 btrfs: mkfs: use sectorsize as nodesize for mixed profiles

[BUG]
When running btrfs/011 with subpage case, even with RAID56 support, it still fails with the following error:

QA output created by 011
*** test btrfs replace
mkfs failed
(see /home/adam/xfstests-dev/results//btrfs/011.full for details)

The full log shows:

---------workout "-m single -d single -M" 1 no 64-----------
ERROR: illegal nodesize 65536 (not equal to 4096 for mixed block group) mkfs failed

This is a critical error, making test case to be aborted, without checking the rest profiles.

[CAUSE]
Mkfs.btrfs always uses the maximum value between sectorsize and page size for its mixed profile nodesize.

For subpage case, it means we always go PAGE_SIZE, no matter whatever the sectorsize is passed in.

[FIX]
Just get rid of the direct PAGE_SIZE usage when determining nodesize for mixed profiles.
And use sectorsize directly (either passed in by the user, or deteremined from page size).

---
 mkfs/main.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
mkfs/main.c +1 -3
index a603ec5896f3..4e0a46a77aa5 100644
@@ -1261,8 +1261,6 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
 			data_profile = tmp;
 		}
 	} else {
-		u32 best_nodesize = max_t(u32, sysconf(_SC_PAGESIZE), sectorsize);
-
 		if (metadata_profile_opt || data_profile_opt) {
 			if (metadata_profile != data_profile) {
 				error(
@@ -1272,7 +1270,7 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
 		}
 
 		if (!nodesize_forced)
-			nodesize = best_nodesize;
+			nodesize = sectorsize;
 	}
 
 	/*
Signature · 1 line
2.35.1
#1 lore raw
Quoted 22 lines · Qu Wenruo

[BUG]
When running btrfs/011 with subpage case, even with RAID56 support, it still fails with the following error:

QA output created by 011
*** test btrfs replace
mkfs failed
(see /home/adam/xfstests-dev/results//btrfs/011.full for details)

The full log shows:

---------workout "-m single -d single -M" 1 no 64-----------
ERROR: illegal nodesize 65536 (not equal to 4096 for mixed block group) mkfs failed

This is a critical error, making test case to be aborted, without checking the rest profiles.

[CAUSE]
Mkfs.btrfs always uses the maximum value between sectorsize and page size for its mixed profile nodesize.

Quoted 8 lines

For subpage case, it means we always go PAGE_SIZE, no matter whatever the sectorsize is passed in.

[FIX]
Just get rid of the direct PAGE_SIZE usage when determining nodesize for mixed profiles.
And use sectorsize directly (either passed in by the user, or deteremined from page size).

Ok, I think it's a sane fallback, on x86_64 there's no change. Added to devel, thanks.