summaryrefslogtreecommitdiff
path: root/btrfs-image.c
diff options
context:
space:
mode:
Diffstat (limited to 'btrfs-image.c')
-rw-r--r--btrfs-image.c38
1 files changed, 15 insertions, 23 deletions
diff --git a/btrfs-image.c b/btrfs-image.c
index d1d3d07..c7fa18f 100644
--- a/btrfs-image.c
+++ b/btrfs-image.c
@@ -733,39 +733,33 @@ static int metadump_init(struct metadump_struct *md, struct btrfs_root *root,
int i, ret = 0;
memset(md, 0, sizeof(*md));
- pthread_cond_init(&md->cond, NULL);
- pthread_mutex_init(&md->mutex, NULL);
+ md->cluster = calloc(1, BLOCK_SIZE);
+ if (!md->cluster)
+ return -ENOMEM;
+ md->threads = calloc(num_threads, sizeof(pthread_t));
+ if (!md->threads) {
+ free(md->cluster);
+ return -ENOMEM;
+ }
INIT_LIST_HEAD(&md->list);
INIT_LIST_HEAD(&md->ordered);
md->root = root;
md->out = out;
md->pending_start = (u64)-1;
md->compress_level = compress_level;
- md->cluster = calloc(1, BLOCK_SIZE);
md->sanitize_names = sanitize_names;
if (sanitize_names > 1)
crc32c_optimization_init();
- if (!md->cluster) {
- pthread_cond_destroy(&md->cond);
- pthread_mutex_destroy(&md->mutex);
- return -ENOMEM;
- }
-
+ md->name_tree.rb_node = NULL;
+ md->num_threads = num_threads;
+ pthread_cond_init(&md->cond, NULL);
+ pthread_mutex_init(&md->mutex, NULL);
meta_cluster_init(md, 0);
+
if (!num_threads)
return 0;
- md->name_tree.rb_node = NULL;
- md->num_threads = num_threads;
- md->threads = calloc(num_threads, sizeof(pthread_t));
- if (!md->threads) {
- free(md->cluster);
- pthread_cond_destroy(&md->cond);
- pthread_mutex_destroy(&md->mutex);
- return -ENOMEM;
- }
-
for (i = 0; i < num_threads; i++) {
ret = pthread_create(md->threads + i, NULL, dump_worker, md);
if (ret)
@@ -1470,8 +1464,7 @@ static int update_super(struct mdrestore_struct *mdres, u8 *buffer)
btrfs_set_stack_chunk_sub_stripes(chunk, 0);
btrfs_set_stack_chunk_type(chunk,
BTRFS_BLOCK_GROUP_SYSTEM);
- btrfs_set_stack_stripe_devid(&chunk->stripe,
- super->dev_item.devid);
+ chunk->stripe.devid = super->dev_item.devid;
physical = logical_to_physical(mdres, key.offset,
&size);
if (size != (u64)-1)
@@ -2829,9 +2822,8 @@ int main(int argc, char *argv[])
OPEN_CTREE_PARTIAL |
OPEN_CTREE_RESTORE);
if (!info) {
- int e = errno;
fprintf(stderr, "unable to open %s error = %s\n",
- target, strerror(e));
+ target, strerror(errno));
return 1;
}