btrfs: btrfs_reduce_alloc_profile(): add support for raid1c3/raid1c4
diff mbox series

Message ID 20200530185321.8373-2-kreijack@libero.it
State New
Headers show
Series
  • btrfs: btrfs_reduce_alloc_profile(): add support for raid1c3/raid1c4
Related show

Commit Message

Goffredo Baroncelli May 30, 2020, 6:53 p.m. UTC
From: Goffredo Baroncelli <kreijack@inwind.it>

The function btrfs_reduce_alloc_profile() is in charge to choice
the profile for the 'next' block group allocation.

This patch add support RAID1C3 and RAID1C4.

Moreover are explicetely handled the case DUP and SINGLE.

Before if both DUP and RAID1C3/RAID1C3 were present
btrfs_reduce_alloc_profile() return both the bit set. This would cause
the check alloc_profile_is_valid() to fail leading to a ro filesystem.

Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it>
---
 fs/btrfs/block-group.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index 5627f53ca115..f23a1e1dc359 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -81,8 +81,12 @@  static u64 btrfs_reduce_alloc_profile(struct btrfs_fs_info *fs_info, u64 flags)
 	}
 	allowed &= flags;
 
-	if (allowed & BTRFS_BLOCK_GROUP_RAID6)
+	if (allowed & BTRFS_BLOCK_GROUP_RAID1C4)
+		allowed = BTRFS_BLOCK_GROUP_RAID1C4;
+	else if (allowed & BTRFS_BLOCK_GROUP_RAID6)
 		allowed = BTRFS_BLOCK_GROUP_RAID6;
+	else if (allowed & BTRFS_BLOCK_GROUP_RAID1C3)
+		allowed = BTRFS_BLOCK_GROUP_RAID1C3;
 	else if (allowed & BTRFS_BLOCK_GROUP_RAID5)
 		allowed = BTRFS_BLOCK_GROUP_RAID5;
 	else if (allowed & BTRFS_BLOCK_GROUP_RAID10)
@@ -91,6 +95,14 @@  static u64 btrfs_reduce_alloc_profile(struct btrfs_fs_info *fs_info, u64 flags)
 		allowed = BTRFS_BLOCK_GROUP_RAID1;
 	else if (allowed & BTRFS_BLOCK_GROUP_RAID0)
 		allowed = BTRFS_BLOCK_GROUP_RAID0;
+	else if (allowed & BTRFS_BLOCK_GROUP_DUP)
+		allowed = BTRFS_BLOCK_GROUP_DUP;
+	else if (allowed & BTRFS_AVAIL_ALLOC_BIT_SINGLE)
+		allowed = BTRFS_AVAIL_ALLOC_BIT_SINGLE;
+	else {
+		btrfs_err(fs_info, "invalid profile type %llu", allowed);
+		BUG_ON(1);
+	}
 
 	flags &= ~BTRFS_BLOCK_GROUP_PROFILE_MASK;