From: sam tygier <samtygier@yahoo.co.uk>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] btrfs-progs: check metadata redundancy
Date: Sat, 02 May 2015 17:03:31 +0100 [thread overview]
Message-ID: <mi2sgj$urs$1@ger.gmane.org> (raw)
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@yahoo.co.uk>
---
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
next reply other threads:[~2015-05-02 16:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-02 16:03 sam tygier [this message]
2015-05-05 14:54 ` [PATCH] btrfs-progs: check metadata redundancy David Sterba
2015-05-05 21:18 ` sam tygier
2015-05-06 3:40 ` Paul Jones
2015-05-06 10:14 ` Duncan
2015-05-12 15:04 ` David Sterba
2015-05-12 15:02 ` David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='mi2sgj$urs$1@ger.gmane.org' \
--to=samtygier@yahoo.co.uk \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox