Check nodesize against features, not only sectorsize.
In fact, one of the btrfs-convert and mkfs differs in the nodesize
check.
This patch also provides the basis for later btrfs-convert fix.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fprintf(stderr, "filetype feature is missing\n");
goto fail;
}
- if (btrfs_check_nodesize(nodesize, blocksize))
+ if (btrfs_check_nodesize(nodesize, blocksize, features))
goto fail;
blocks_per_node = nodesize / blocksize;
ret = -blocks_per_node;
print_usage(c != GETOPT_VAL_HELP);
}
}
+
sectorsize = max(sectorsize, (u32)sysconf(_SC_PAGESIZE));
- if (btrfs_check_nodesize(nodesize, sectorsize))
- exit(1);
saved_optind = optind;
dev_cnt = ac - optind;
if (dev_cnt == 0)
}
}
- if (!nodesize_forced) {
+ if (!nodesize_forced)
nodesize = best_nodesize;
- if (btrfs_check_nodesize(nodesize, sectorsize))
- exit(1);
- }
- if (nodesize != sectorsize) {
- fprintf(stderr, "Error: mixed metadata/data block groups "
- "require metadata blocksizes equal to the sectorsize\n");
- exit(1);
- }
}
+ if (btrfs_check_nodesize(nodesize, sectorsize,
+ features))
+ exit(1);
/* Check device/block_count after the nodesize is determined */
if (block_count && block_count < btrfs_min_dev_size(nodesize)) {
return v2_supported;
}
-int btrfs_check_nodesize(u32 nodesize, u32 sectorsize)
+int btrfs_check_nodesize(u32 nodesize, u32 sectorsize, u64 features)
{
if (nodesize < sectorsize) {
fprintf(stderr,
"ERROR: Illegal nodesize %u (not aligned to %u)\n",
nodesize, sectorsize);
return -1;
+ } else if (features & BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS &&
+ nodesize != sectorsize) {
+ fprintf(stderr,
+ "ERROR: Illegal nodesize %u (not equal to %u for mixed block group)\n",
+ nodesize, sectorsize);
+ return -1;
}
return 0;
}
}
int btrfs_tree_search2_ioctl_supported(int fd);
-int btrfs_check_nodesize(u32 nodesize, u32 sectorsize);
+int btrfs_check_nodesize(u32 nodesize, u32 sectorsize, u64 features);
const char *get_argv0_buf(void);