Given a 200G vdd1 and 1G vdd2: In current code: # mkfs.btrfs -f /dev/vdd1 /dev/vdd2 SMALL VOLUME: forcing mixed metadata/data groups btrfs-progs v4.1.2 See http://btrfs.wiki.kernel.org for more information. Label: (null) UUID: 7aa6fc75-ce23-4033-9d47-fd046afa2992 Node size: 4096 Sector size: 4096 Filesystem size: 1.20GiB Block group profiles: Data+Metadata: single 8.00MiB System: single 4.00MiB SSD detected: no Incompat features: mixed-bg, extref, skinny-metadata Number of devices: 2 Devices: ID SIZE PATH 1 200.29MiB /dev/vdd1 2 1.00GiB /dev/vdd2 # # mkfs.btrfs -f /dev/vdd2 /dev/vdd1 btrfs-progs v4.1.2 See http://btrfs.wiki.kernel.org for more information. Label: (null) UUID: ac659809-66c1-427d-934d-bd4c209c91a8 Node size: 16384 Sector size: 4096 Filesystem size: 1.20GiB Block group profiles: Data: RAID0 136.00MiB Metadata: RAID1 69.38MiB System: RAID1 12.00MiB SSD detected: no Incompat features: extref, skinny-metadata Number of devices: 2 Devices: ID SIZE PATH 1 1.00GiB /dev/vdd2 2 200.29MiB /dev/vdd1 We can see: mkfs.btrfs -f /dev/vdd1 /dev/vdd2 and mkfs.btrfs -f /dev/vdd2 /dev/vdd1 have different "mixed" type. Reason: Current code determine "is to use mixed-type" only by first device. Fix: Use mixed-type only if all device are small. Signed-off-by: Zhao Lei <zhaolei@xxxxxxxxxxxxxx> --- mkfs.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/mkfs.c b/mkfs.c index cdae94d..29cab13 100644 --- a/mkfs.c +++ b/mkfs.c @@ -1358,6 +1358,7 @@ int main(int ac, char **av) u64 features = BTRFS_MKFS_DEFAULT_FEATURES; struct mkfs_allocation allocation = { 0 }; struct btrfs_mkfs_config mkfs_cfg; + int large_device_cnt = 0; while(1) { int c; @@ -1494,17 +1495,25 @@ int main(int ac, char **av) if (is_block_device(file) == 1) if (test_dev_for_mkfs(file, force_overwrite)) exit(1); + ret = is_vol_small(file); + if (ret < 0) { + error("Failed to check size for '%s': %s", + file, strerror(-ret)); + exit(1); + } + large_device_cnt += (!ret); + ret = 0; } - file = av[optind]; - ssd = is_ssd(file); - - if (is_vol_small(file) || mixed) { + if (!large_device_cnt || mixed) { if (verbose) printf("SMALL VOLUME: forcing mixed metadata/data groups\n"); mixed = 1; } + file = av[optind]; + ssd = is_ssd(file); + /* * Set default profiles according to number of added devices. * For mixed groups defaults are single/single. -- 1.8.5.1 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html
