@@ -3856,10 +3856,14 @@ static void update_global_block_rsv(struct btrfs_fs_info *fs_info)
spin_unlock(&block_rsv->lock);
}
-static void init_global_block_rsv(struct btrfs_fs_info *fs_info)
+static int init_global_block_rsv(struct btrfs_fs_info *fs_info)
{
struct btrfs_space_info *space_info;
+ space_info = __find_space_info(fs_info, BTRFS_BLOCK_GROUP_DATA);
+ if (!space_info)
+ return -EAGAIN;
+
space_info = __find_space_info(fs_info, BTRFS_BLOCK_GROUP_SYSTEM);
fs_info->chunk_block_rsv.space_info = space_info;
fs_info->chunk_block_rsv.priority = 10;
@@ -3884,6 +3888,8 @@ static void init_global_block_rsv(struct btrfs_fs_info *fs_info)
btrfs_add_durable_block_rsv(fs_info, &fs_info->delalloc_block_rsv);
update_global_block_rsv(fs_info);
+
+ return 0;
}
static void release_global_block_rsv(struct btrfs_fs_info *fs_info)
@@ -8514,7 +8520,13 @@ int btrfs_read_block_groups(struct btrfs_root *root)
set_block_group_ro(cache);
}
- init_global_block_rsv(info);
+again:
+ ret = init_global_block_rsv(info);
+ if (ret == -EAGAIN) {
+ update_space_info(info, BTRFS_BLOCK_GROUP_DATA, 0, 0,
+ &space_info);
+ goto again;
+ }
ret = 0;
error:
btrfs_free_path(path);