summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/utils.c b/utils.c
index cec7c738..45fde2e9 100644
--- a/utils.c
+++ b/utils.c
@@ -250,16 +250,10 @@ static int setup_temp_super(int fd, struct btrfs_mkfs_config *cfg,
struct btrfs_super_block *super = (struct btrfs_super_block *)super_buf;
int ret;
- /*
- * We rely on cfg->chunk_uuid and cfg->fs_uuid to pass uuid
- * for other functions.
- * Caller must allocate space for them
- */
- BUG_ON(!cfg->chunk_uuid || !cfg->fs_uuid);
memset(super_buf, 0, BTRFS_SUPER_INFO_SIZE);
cfg->num_bytes = round_down(cfg->num_bytes, cfg->sectorsize);
- if (cfg->fs_uuid && *cfg->fs_uuid) {
+ if (*cfg->fs_uuid) {
if (uuid_parse(cfg->fs_uuid, super->fsid) != 0) {
error("cound not parse UUID: %s", cfg->fs_uuid);
ret = -EINVAL;
@@ -320,8 +314,6 @@ static int setup_temp_extent_buffer(struct extent_buffer *buf,
unsigned char chunk_uuid[BTRFS_UUID_SIZE];
int ret;
- /* We rely on cfg->fs_uuid and chunk_uuid to fsid and chunk uuid */
- BUG_ON(!cfg->fs_uuid || !cfg->chunk_uuid);
ret = uuid_parse(cfg->fs_uuid, fsid);
if (ret)
return -EINVAL;
@@ -1049,7 +1041,7 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg,
memset(&super, 0, sizeof(super));
num_bytes = (cfg->num_bytes / cfg->sectorsize) * cfg->sectorsize;
- if (cfg->fs_uuid && *cfg->fs_uuid) {
+ if (*cfg->fs_uuid) {
if (uuid_parse(cfg->fs_uuid, super.fsid) != 0) {
error("cannot not parse UUID: %s", cfg->fs_uuid);
ret = -EINVAL;
@@ -3280,6 +3272,7 @@ int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile,
u64 dev_cnt, int mixed, int ssd)
{
u64 allowed = 0;
+ u64 profile = metadata_profile | data_profile;
switch (dev_cnt) {
default:
@@ -3294,8 +3287,7 @@ int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile,
allowed |= BTRFS_BLOCK_GROUP_DUP;
}
- if (dev_cnt > 1 &&
- ((metadata_profile | data_profile) & BTRFS_BLOCK_GROUP_DUP)) {
+ if (dev_cnt > 1 && profile & BTRFS_BLOCK_GROUP_DUP) {
warning("DUP is not recommended on filesystem with multiple devices");
}
if (metadata_profile & ~allowed) {
@@ -3315,6 +3307,12 @@ int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile,
return 1;
}
+ if (dev_cnt == 3 && profile & BTRFS_BLOCK_GROUP_RAID6) {
+ warning("RAID6 is not recommended on filesystem with 3 devices only");
+ }
+ if (dev_cnt == 2 && profile & BTRFS_BLOCK_GROUP_RAID5) {
+ warning("RAID5 is not recommended on filesystem with 2 devices only");
+ }
warning_on(!mixed && (data_profile & BTRFS_BLOCK_GROUP_DUP) && ssd,
"DUP may not actually lead to 2 copies on the device, see manual page");