btrfs-progs: check metadata redundancy
PATCH v2 1/1 btrfs-progs: check metadata redundancy
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.
Quoted 1 line
From
fdfcb5f733ff5ed48562366bda6f1a9c740b031aMon Sep 17 00:00:00 2001
From: Sam Tygier <[email protected]>
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(+)
mkfs.c +6 -0
@@ -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 );
utils.c +18 -0
@@ -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
utils.h +1 -0
@@ -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);
Signature · 1 line
2.1.4
David Sterba
AppliedQuoted 5 lines · sam tygier
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.
Quoted 8 lines
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 raid0V1 -> V2 Downgrade from error to warning as requested by David Sterba.
Signed-off-by Sam Tygier <[email protected]>
Applied, thanks.