diff --git a/kernel-shared/free-space-tree.c b/kernel-shared/free-space-tree.c index 0fdf5004..896bd3a2 100644 --- a/kernel-shared/free-space-tree.c +++ b/kernel-shared/free-space-tree.c @@ -1057,6 +1057,9 @@ int populate_free_space_tree(struct btrfs_trans_handle *trans, if (ret) goto out; + start = block_group->start; + end = block_group->start + block_group->length; + /* * Iterate through all of the extent and metadata items in this block * group, adding the free space between them and the free space at the @@ -1071,10 +1074,11 @@ int populate_free_space_tree(struct btrfs_trans_handle *trans, ret = btrfs_search_slot_for_read(extent_root, &key, path, 1, 0); if (ret < 0) goto out; - ASSERT(ret == 0); + if (ret > 0) { + ASSERT(btrfs_fs_incompat(trans->fs_info, EXTENT_TREE_V2)); + goto done; + } - start = block_group->start; - end = block_group->start + block_group->length; while (1) { btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]); @@ -1106,6 +1110,7 @@ int populate_free_space_tree(struct btrfs_trans_handle *trans, if (ret) break; } +done: if (start < end) { ret = __add_to_free_space_tree(trans, block_group, path2, start, end - start);