diff options
-rw-r--r-- | fs/btrfs/extent-tree.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 862df2066e7a..f24ef9020323 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -10606,6 +10606,35 @@ static void clear_avail_alloc_bits(struct btrfs_fs_info *fs_info, u64 flags) | |||
10606 | write_sequnlock(&fs_info->profiles_lock); | 10606 | write_sequnlock(&fs_info->profiles_lock); |
10607 | } | 10607 | } |
10608 | 10608 | ||
10609 | /* | ||
10610 | * Clear incompat bits for the following feature(s): | ||
10611 | * | ||
10612 | * - RAID56 - in case there's neither RAID5 nor RAID6 profile block group | ||
10613 | * in the whole filesystem | ||
10614 | */ | ||
10615 | static void clear_incompat_bg_bits(struct btrfs_fs_info *fs_info, u64 flags) | ||
10616 | { | ||
10617 | if (flags & BTRFS_BLOCK_GROUP_RAID56_MASK) { | ||
10618 | struct list_head *head = &fs_info->space_info; | ||
10619 | struct btrfs_space_info *sinfo; | ||
10620 | |||
10621 | list_for_each_entry_rcu(sinfo, head, list) { | ||
10622 | bool found = false; | ||
10623 | |||
10624 | down_read(&sinfo->groups_sem); | ||
10625 | if (!list_empty(&sinfo->block_groups[BTRFS_RAID_RAID5])) | ||
10626 | found = true; | ||
10627 | if (!list_empty(&sinfo->block_groups[BTRFS_RAID_RAID6])) | ||
10628 | found = true; | ||
10629 | up_read(&sinfo->groups_sem); | ||
10630 | |||
10631 | if (found) | ||
10632 | return; | ||
10633 | } | ||
10634 | btrfs_clear_fs_incompat(fs_info, RAID56); | ||
10635 | } | ||
10636 | } | ||
10637 | |||
10609 | int btrfs_remove_block_group(struct btrfs_trans_handle *trans, | 10638 | int btrfs_remove_block_group(struct btrfs_trans_handle *trans, |
10610 | u64 group_start, struct extent_map *em) | 10639 | u64 group_start, struct extent_map *em) |
10611 | { | 10640 | { |
@@ -10752,6 +10781,7 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans, | |||
10752 | clear_avail_alloc_bits(fs_info, block_group->flags); | 10781 | clear_avail_alloc_bits(fs_info, block_group->flags); |
10753 | } | 10782 | } |
10754 | up_write(&block_group->space_info->groups_sem); | 10783 | up_write(&block_group->space_info->groups_sem); |
10784 | clear_incompat_bg_bits(fs_info, block_group->flags); | ||
10755 | if (kobj) { | 10785 | if (kobj) { |
10756 | kobject_del(kobj); | 10786 | kobject_del(kobj); |
10757 | kobject_put(kobj); | 10787 | kobject_put(kobj); |