* [PATCH v2] btrfs-progs: check metadata redundancy
@ 2015-05-30 14:54 sam tygier
2015-06-02 14:57 ` David Sterba
0 siblings, 1 reply; 2+ messages in thread
From: sam tygier @ 2015-05-30 14:54 UTC (permalink / raw)
To: linux-btrfs
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. It should give a warning in these cases.
When making a filesystem check that metadata mode is at least
as redundant as the data mode. For example give warning when:
-d raid1 -m raid0
V1 -> V2 Downgrade from error to warning as requested by David
Sterba.
Signed-off-by: Sam Tygier <samtygier@yahoo.co.uk>
>From fdfcb5f733ff5ed48562366bda6f1a9c740b031a Mon Sep 17 00:00:00 2001
From: Sam Tygier <samtygier@yahoo.co.uk>
Date: Sat, 30 May 2015 15:37:37 +0100
Subject: [PATCH] When making a filesystem check that metadata mode is at least
as redundant as the data mode. For example give warning when:
-d raid1 -m raid0
---
mkfs.c | 6 ++++++
utils.c | 18 ++++++++++++++++++
utils.h | 1 +
3 files changed, 25 insertions(+)
diff --git a/mkfs.c b/mkfs.c
index 14e0fed..938840d 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -1367,6 +1367,12 @@ int main(int ac, char **av)
exit(1);
}
+ if (group_profile_max_safe_loss(metadata_profile) <
+ group_profile_max_safe_loss(data_profile)){
+ fprintf(stderr,
+ "Warning: metatdata has lower redundancy than data\n");
+ }
+
/* if we are here that means all devs are good to btrfsify */
printf("%s\n", PACKAGE_STRING);
printf("See %s for more information.\n\n", PACKAGE_URL);
diff --git a/utils.c b/utils.c
index 4b8a826..ba35b34 100644
--- a/utils.c
+++ b/utils.c
@@ -2354,6 +2354,24 @@ int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile,
return 0;
}
+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;
+ }
+}
+
/* Check if disk is suitable for btrfs
* returns:
* 1: something is wrong, estr provides the error
diff --git a/utils.h b/utils.h
index 5657c74..98fd812 100644
--- a/utils.h
+++ b/utils.h
@@ -144,6 +144,7 @@ int test_dev_for_mkfs(char *file, int force_overwrite, char *estr);
int get_label_mounted(const char *mount_path, char *labelp);
int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile,
u64 dev_cnt, int mixed, char *estr);
+int group_profile_max_safe_loss(u64 flag);
int is_vol_small(char *file);
int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf,
int verify);
--
2.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] btrfs-progs: check metadata redundancy
2015-05-30 14:54 [PATCH v2] btrfs-progs: check metadata redundancy sam tygier
@ 2015-06-02 14:57 ` David Sterba
0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2015-06-02 14:57 UTC (permalink / raw)
To: sam tygier; +Cc: linux-btrfs
On Sat, May 30, 2015 at 03:54:48PM +0100, sam tygier wrote:
> 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. It should give a warning in these cases.
>
> When making a filesystem check that metadata mode is at least
> as redundant as the data mode. For example give warning when:
> -d raid1 -m raid0
>
> V1 -> V2 Downgrade from error to warning as requested by David
> Sterba.
>
> Signed-off-by: Sam Tygier <samtygier@yahoo.co.uk>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-06-02 14:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-30 14:54 [PATCH v2] btrfs-progs: check metadata redundancy sam tygier
2015-06-02 14:57 ` David Sterba
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.