summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chunk-recover.c1
-rw-r--r--ctree.h1
-rw-r--r--volumes.c9
3 files changed, 10 insertions, 1 deletions
diff --git a/chunk-recover.c b/chunk-recover.c
index e880bbc8..ae0d318c 100644
--- a/chunk-recover.c
+++ b/chunk-recover.c
@@ -1197,6 +1197,7 @@ open_ctree_with_broken_chunk(struct recover_control *rc)
fprintf(stderr, "Failed to allocate memory for fs_info\n");
return ERR_PTR(-ENOMEM);
}
+ fs_info->is_chunk_recover = 1;
fs_info->fs_devices = rc->fs_devices;
ret = btrfs_open_devices(fs_info->fs_devices, O_RDWR);
diff --git a/ctree.h b/ctree.h
index 187026cc..6d101848 100644
--- a/ctree.h
+++ b/ctree.h
@@ -973,6 +973,7 @@ struct btrfs_fs_info {
int system_allocs;
int readonly;
int on_restoring;
+ int is_chunk_recover;
int (*free_extent_hook)(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
u64 bytenr, u64 num_bytes, u64 parent,
diff --git a/volumes.c b/volumes.c
index c38da6cc..bd012704 100644
--- a/volumes.c
+++ b/volumes.c
@@ -1496,8 +1496,15 @@ int btrfs_chunk_readonly(struct btrfs_root *root, u64 chunk_offset)
int readonly = 0;
int i;
+ /*
+ * During chunk recovering, we may fail to find block group's
+ * corresponding chunk, we will rebuild it later
+ */
ce = search_cache_extent(&map_tree->cache_tree, chunk_offset);
- BUG_ON(!ce);
+ if (!root->fs_info->is_chunk_recover)
+ BUG_ON(!ce);
+ else
+ return 0;
map = container_of(ce, struct map_lookup, ce);
for (i = 0; i < map->num_stripes; i++) {