Currently BTRFS allows you to make bad choices of data and
metadata levels. For example -d raid1 -m raid0 means you can
only use half your total disk space, but will loose everything
if 1 disk fails. This patch prevents you creating the situation
another will be need to prevent rebalancing in to it.
When making a filesystem check that metadata mode is at least
as redundant as the data mode. For example don't allow:
-d raid1 -m raid0
Signed-off-by: Sam Tygier <samtygier@xxxxxxxxxxx>
---
utils.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/utils.c b/utils.c
index b175b01..1136a78 100644
--- a/utils.c
+++ b/utils.c
@@ -2391,6 +2391,24 @@ static int group_profile_devs_min(u64 flag)
}
}
+static int group_profile_max_safe_loss(u64 flag)
+{
+ switch (flag & BTRFS_BLOCK_GROUP_PROFILE_MASK) {
+ case 0: /* single */
+ case BTRFS_BLOCK_GROUP_DUP:
+ case BTRFS_BLOCK_GROUP_RAID0:
+ return 0;
+ case BTRFS_BLOCK_GROUP_RAID1:
+ case BTRFS_BLOCK_GROUP_RAID5:
+ case BTRFS_BLOCK_GROUP_RAID10:
+ return 1;
+ case BTRFS_BLOCK_GROUP_RAID6:
+ return 2;
+ default:
+ return -1;
+ }
+}
+
int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile,
u64 dev_cnt, int mixed, char *estr)
{
@@ -2439,6 +2457,13 @@ int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile,
"dup for data is allowed only in mixed mode");
return 1;
}
+
+ if (group_profile_max_safe_loss(metadata_profile) <
+ group_profile_max_safe_loss(data_profile)){
+ snprintf(estr, sz,
+ "metatdata has lower redundancy than data");
+ return 1;
+ }
return 0;
}
-- 2.1.4
--
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