}
}
+static int add_extent_rec_nolookup(struct cache_tree *extent_cache,
+ struct btrfs_key *parent_key, u64 parent_gen,
+ u64 start, u64 nr, u64 extent_item_refs,
+ int is_root, int inc_ref, int set_checked,
+ int metadata, int extent_rec, u64 max_size)
+{
+ struct extent_record *rec;
+ int ret = 0;
+
+ rec = malloc(sizeof(*rec));
+ if (!rec)
+ return -ENOMEM;
+ rec->start = start;
+ rec->max_size = max_size;
+ rec->nr = max(nr, max_size);
+ rec->found_rec = !!extent_rec;
+ rec->content_checked = 0;
+ rec->owner_ref_checked = 0;
+ rec->num_duplicates = 0;
+ rec->metadata = metadata;
+ rec->flag_block_full_backref = -1;
+ rec->bad_full_backref = 0;
+ rec->crossing_stripes = 0;
+ rec->wrong_chunk_type = 0;
+ INIT_LIST_HEAD(&rec->backrefs);
+ INIT_LIST_HEAD(&rec->dups);
+ INIT_LIST_HEAD(&rec->list);
+
+ if (is_root)
+ rec->is_root = 1;
+ else
+ rec->is_root = 0;
+
+ if (inc_ref)
+ rec->refs = 1;
+ else
+ rec->refs = 0;
+
+ if (extent_item_refs)
+ rec->extent_item_refs = extent_item_refs;
+ else
+ rec->extent_item_refs = 0;
+
+ if (parent_key)
+ btrfs_cpu_key_to_disk(&rec->parent_key, parent_key);
+ else
+ memset(&rec->parent_key, 0, sizeof(*parent_key));
+
+ if (parent_gen)
+ rec->parent_generation = parent_gen;
+ else
+ rec->parent_generation = 0;
+
+ rec->cache.start = start;
+ rec->cache.size = nr;
+ ret = insert_cache_extent(extent_cache, &rec->cache);
+ BUG_ON(ret);
+ bytes_used += nr;
+ if (set_checked) {
+ rec->content_checked = 1;
+ rec->owner_ref_checked = 1;
+ }
+
+ if (metadata)
+ rec->crossing_stripes = check_crossing_stripes(rec->start,
+ rec->max_size);
+ check_extent_type(rec);
+ return ret;
+}
+
static int add_extent_rec(struct cache_tree *extent_cache,
struct btrfs_key *parent_key, u64 parent_gen,
u64 start, u64 nr, u64 extent_item_refs,
maybe_free_extent_rec(extent_cache, rec);
return ret;
}
- rec = malloc(sizeof(*rec));
- if (!rec)
- return -ENOMEM;
- rec->start = start;
- rec->max_size = max_size;
- rec->nr = max(nr, max_size);
- rec->found_rec = !!extent_rec;
- rec->content_checked = 0;
- rec->owner_ref_checked = 0;
- rec->num_duplicates = 0;
- rec->metadata = metadata;
- rec->flag_block_full_backref = -1;
- rec->bad_full_backref = 0;
- rec->crossing_stripes = 0;
- rec->wrong_chunk_type = 0;
- INIT_LIST_HEAD(&rec->backrefs);
- INIT_LIST_HEAD(&rec->dups);
- INIT_LIST_HEAD(&rec->list);
-
- if (is_root)
- rec->is_root = 1;
- else
- rec->is_root = 0;
-
- if (inc_ref)
- rec->refs = 1;
- else
- rec->refs = 0;
-
- if (extent_item_refs)
- rec->extent_item_refs = extent_item_refs;
- else
- rec->extent_item_refs = 0;
- if (parent_key)
- btrfs_cpu_key_to_disk(&rec->parent_key, parent_key);
- else
- memset(&rec->parent_key, 0, sizeof(*parent_key));
+ ret = add_extent_rec_nolookup(extent_cache, parent_key, parent_gen,
+ start, nr, extent_item_refs, is_root, inc_ref,
+ set_checked, metadata, extent_rec, max_size);
- if (parent_gen)
- rec->parent_generation = parent_gen;
- else
- rec->parent_generation = 0;
-
- rec->cache.start = start;
- rec->cache.size = nr;
- ret = insert_cache_extent(extent_cache, &rec->cache);
- BUG_ON(ret);
- bytes_used += nr;
- if (set_checked) {
- rec->content_checked = 1;
- rec->owner_ref_checked = 1;
- }
-
- if (metadata)
- rec->crossing_stripes = check_crossing_stripes(rec->start,
- rec->max_size);
- check_extent_type(rec);
return ret;
}