Skip to content

Commit 1d6d4a0

Browse files
josefbacikgregkh
authored andcommitted
btrfs: make sure we create all new block groups
commit 545e336 upstream. Allocating new chunks modifies both the extent and chunk tree, which can trigger new chunk allocations. So instead of doing list_for_each_safe, just do while (!list_empty()) so we make sure we don't exit with other pending bg's still on our list. CC: [email protected] # 4.4+ Reviewed-by: Omar Sandoval <[email protected]> Reviewed-by: Liu Bo <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 9aabbb2 commit 1d6d4a0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

fs/btrfs/extent-tree.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10094,15 +10094,18 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
1009410094
void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans)
1009510095
{
1009610096
struct btrfs_fs_info *fs_info = trans->fs_info;
10097-
struct btrfs_block_group_cache *block_group, *tmp;
10097+
struct btrfs_block_group_cache *block_group;
1009810098
struct btrfs_root *extent_root = fs_info->extent_root;
1009910099
struct btrfs_block_group_item item;
1010010100
struct btrfs_key key;
1010110101
int ret = 0;
1010210102
bool can_flush_pending_bgs = trans->can_flush_pending_bgs;
1010310103

1010410104
trans->can_flush_pending_bgs = false;
10105-
list_for_each_entry_safe(block_group, tmp, &trans->new_bgs, bg_list) {
10105+
while (!list_empty(&trans->new_bgs)) {
10106+
block_group = list_first_entry(&trans->new_bgs,
10107+
struct btrfs_block_group_cache,
10108+
bg_list);
1010610109
if (ret)
1010710110
goto next;
1010810111

0 commit comments

Comments
 (0)