btrfs: Don't remove block group that still has pinned down bytes
[sfrench/cifs-2.6.git] / fs / btrfs / extent-tree.c
index 0ca3999356c7d19256f29cf7d6ac4c1a2890673f..37d8927015d9fa2b25082d04acf409614f3732f9 100644 (file)
@@ -10702,7 +10702,7 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info)
                /* Don't want to race with allocators so take the groups_sem */
                down_write(&space_info->groups_sem);
                spin_lock(&block_group->lock);
                /* Don't want to race with allocators so take the groups_sem */
                down_write(&space_info->groups_sem);
                spin_lock(&block_group->lock);
-               if (block_group->reserved ||
+               if (block_group->reserved || block_group->pinned ||
                    btrfs_block_group_used(&block_group->item) ||
                    block_group->ro ||
                    list_is_singular(&block_group->list)) {
                    btrfs_block_group_used(&block_group->item) ||
                    block_group->ro ||
                    list_is_singular(&block_group->list)) {