u32 blocksize, int copy)
{
int ret;
- int dev_nr;
struct extent_buffer *eb;
u64 length;
struct btrfs_multi_bio *multi = NULL;
if (!eb)
return NULL;
- dev_nr = 0;
length = blocksize;
while (1) {
ret = btrfs_map_block(&root->fs_info->mapping_tree, READ,
break;
};
}
- return 0;
+ return ret;
}
static void reada_walk_down(struct btrfs_root *root,
struct btrfs_root *ref_root;
struct btrfs_key key;
struct btrfs_path path;
- int ret;
int level;
int found = 0;
btrfs_init_path(&path);
path.lowest_level = level + 1;
- ret = btrfs_search_slot(NULL, ref_root, &key, &path, 0, 0);
+ btrfs_search_slot(NULL, ref_root, &key, &path, 0, 0);
if (buf->start == btrfs_node_blockptr(path.nodes[level + 1],
path.slots[level + 1]))
continue;
}
if (key.type == BTRFS_BLOCK_GROUP_ITEM_KEY) {
- struct btrfs_block_group_item *bi;
- bi = btrfs_item_ptr(buf, i,
- struct btrfs_block_group_item);
-#if 0
- fprintf(stderr,"block group %Lu %Lu used %Lu ",
- btrfs_disk_key_objectid(disk_key),
- btrfs_disk_key_offset(disk_key),
- btrfs_block_group_used(bi));
- fprintf(stderr, "flags %x\n", bi->flags);
-#endif
continue;
}
if (key.type == BTRFS_EXTENT_REF_V0_KEY) {
struct extent_buffer **cow_ret,
u64 search_start, u64 empty_size)
{
- u64 generation;
struct extent_buffer *cow;
struct btrfs_disk_key disk_key;
int level;
WARN_ON(root->ref_cows && trans->transid != root->last_trans);
level = btrfs_header_level(buf);
- generation = btrfs_header_generation(buf);
if (level == 0)
btrfs_item_key(buf, &disk_key, 0);
int wret;
int pslot;
int orig_slot = path->slots[level];
- int err_on_enospc = 0;
u64 orig_ptr;
if (level == 0)
BTRFS_NODEPTRS_PER_BLOCK(root) / 4)
return 0;
- if (btrfs_header_nritems(mid) < 2)
- err_on_enospc = 1;
-
left = read_node_slot(root, parent, pslot - 1);
if (left) {
wret = btrfs_cow_block(trans, root, left,
wret = push_node_left(trans, root, left, mid, 1);
if (wret < 0)
ret = wret;
- if (btrfs_header_nritems(mid) < 2)
- err_on_enospc = 1;
}
/*
int wret;
int pslot;
int orig_slot = path->slots[level];
- u64 orig_ptr;
if (level == 0)
return 1;
mid = path->nodes[level];
WARN_ON(btrfs_header_generation(mid) != trans->transid);
- orig_ptr = btrfs_node_blockptr(mid, orig_slot);
if (level < BTRFS_MAX_LEVEL - 1)
parent = path->nodes[level + 1];
{
int ret = 0;
int slot;
- int slot_orig;
struct extent_buffer *leaf;
struct btrfs_item *item;
u32 nritems;
unsigned int size_diff;
int i;
- slot_orig = path->slots[0];
leaf = path->nodes[0];
slot = path->slots[0];
{
int ret = 0;
int slot;
- int slot_orig;
struct extent_buffer *leaf;
struct btrfs_item *item;
u32 nritems;
unsigned int old_size;
int i;
- slot_orig = path->slots[0];
leaf = path->nodes[0];
nritems = btrfs_header_nritems(leaf);
struct btrfs_item *item;
int ret = 0;
int slot;
- int slot_orig;
int i;
u32 nritems;
u32 total_size = 0;
if (ret < 0)
goto out;
- slot_orig = path->slots[0];
leaf = path->nodes[0];
nritems = btrfs_header_nritems(leaf);
exit(1);
}
-static void print_extent_leaf(struct btrfs_root *root, struct extent_buffer *l)
-{
- int i;
- struct btrfs_item *item;
-// struct btrfs_extent_ref *ref;
- struct btrfs_key key;
- static u64 last = 0;
- static u64 last_len = 0;
- u32 nr = btrfs_header_nritems(l);
- u32 type;
-
- for (i = 0 ; i < nr ; i++) {
- item = btrfs_item_nr(l, i);
- btrfs_item_key_to_cpu(l, &key, i);
- type = btrfs_key_type(&key);
- switch (type) {
- case BTRFS_EXTENT_ITEM_KEY:
- last_len = key.offset;
- last = key.objectid;
- break;
-#if 0
- case BTRFS_EXTENT_REF_KEY:
- ref = btrfs_item_ptr(l, i, struct btrfs_extent_ref);
- printf("%llu %llu extent back ref root %llu gen %llu "
- "owner %llu num_refs %lu\n",
- (unsigned long long)last,
- (unsigned long long)last_len,
- (unsigned long long)btrfs_ref_root(l, ref),
- (unsigned long long)btrfs_ref_generation(l, ref),
- (unsigned long long)btrfs_ref_objectid(l, ref),
- (unsigned long)btrfs_ref_num_refs(l, ref));
- break;
-#endif
- };
- fflush(stdout);
- }
-}
-
static void print_extents(struct btrfs_root *root, struct extent_buffer *eb)
{
int i;
if (!eb)
return;
- if (btrfs_is_leaf(eb)) {
- print_extent_leaf(root, eb);
- return;
- }
+
size = btrfs_level_size(root, btrfs_header_level(eb) - 1);
nr = btrfs_header_nritems(eb);
for (i = 0; i < nr; i++) {
ret = btrfs_truncate_item(trans, root, path,
item_len - sub_item_len, 1);
}
- return 0;
+ return ret;
}
u64 parent_transid)
{
int ret;
- int dev_nr;
struct extent_buffer *eb;
u64 length;
struct btrfs_multi_bio *multi = NULL;
return 0;
}
- dev_nr = 0;
length = blocksize;
ret = btrfs_map_block(&root->fs_info->mapping_tree, READ,
bytenr, &length, &multi, 0);
u32 blocksize, u64 parent_transid)
{
int ret;
- int dev_nr;
struct extent_buffer *eb;
u64 length;
struct btrfs_multi_bio *multi = NULL;
if (btrfs_buffer_uptodate(eb, parent_transid))
return eb;
- dev_nr = 0;
length = blocksize;
while (1) {
ret = btrfs_map_block(&root->fs_info->mapping_tree, READ,
struct cache_extent *pe)
{
struct rb_node *found;
- struct cache_extent *entry;
found = tree_insert(&tree->root, pe->start, pe->size, &pe->rb_node);
- if (found) {
- entry = rb_entry(found, struct cache_extent, rb_node);
+ if (found)
return -EEXIST;
- }
+
return 0;
}
int i;
int level;
int ret = 0;
- int faili = 0;
int (*process_func)(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
u64, u64, u64, u64, u64, u64);
parent, ref_root, key.objectid,
key.offset);
if (ret) {
- faili = i;
WARN_ON(1);
goto fail;
}
ret = process_func(trans, root, bytenr, num_bytes,
parent, ref_root, level - 1, 0);
if (ret) {
- faili = i;
WARN_ON(1);
goto fail;
}
return 0;
fail:
WARN_ON(1);
-#if 0
- for (i =0; i < faili; i++) {
- if (level == 0) {
- u64 disk_bytenr;
- btrfs_item_key_to_cpu(buf, &key, i);
- if (btrfs_key_type(&key) != BTRFS_EXTENT_DATA_KEY)
- continue;
- fi = btrfs_item_ptr(buf, i,
- struct btrfs_file_extent_item);
- if (btrfs_file_extent_type(buf, fi) ==
- BTRFS_FILE_EXTENT_INLINE)
- continue;
- disk_bytenr = btrfs_file_extent_disk_bytenr(buf, fi);
- if (disk_bytenr == 0)
- continue;
- err = btrfs_free_extent(trans, root, disk_bytenr,
- btrfs_file_extent_disk_num_bytes(buf,
- fi), 0);
- BUG_ON(err);
- } else {
- bytenr = btrfs_node_blockptr(buf, i);
- err = btrfs_free_extent(trans, root, bytenr,
- btrfs_level_size(root, level - 1), 0);
- BUG_ON(err);
- }
- }
-#endif
return ret;
}
struct extent_state *prealloc = NULL;
struct cache_extent *node;
int err = 0;
- int set;
u64 last_start;
u64 last_end;
again:
* Just lock what we found and keep going
*/
if (state->start == start && state->end <= end) {
- set = state->state & bits;
state->state |= bits;
merge_state(tree, state);
if (last_end == (u64)-1)
* desired bit on it.
*/
if (state->start < start) {
- set = state->state & bits;
err = split_state(tree, state, prealloc, start);
BUG_ON(err == -EEXIST);
prealloc = NULL;
* We need to split the extent, and set the bit
* on the first half
*/
- set = state->state & bits;
err = split_state(tree, state, prealloc, end + 1);
BUG_ON(err == -EEXIST);
int zero_end = 1;
int option_index = 0;
int fd;
- int first_fd;
int ret;
int i;
int mixed = 0;
fprintf(stderr, "unable to open %s\n", file);
exit(1);
}
- first_fd = fd;
first_file = file;
ret = btrfs_prepare_device(fd, file, zero_end, &dev_block_count, &mixed);
if (block_count == 0)
}
file = output;
- first_fd = fd;
first_file = file;
block_count = size_sourcedir(source_dir, sectorsize,
&num_of_meta_chunks, &size_of_data);
struct btrfs_dir_item *di;
struct btrfs_inode_item *ii;
struct btrfs_file_extent_item *fi;
- struct btrfs_csum_item *ci;
struct btrfs_block_group_item *bi;
struct btrfs_extent_data_ref *dref;
struct btrfs_shared_data_ref *sref;
#endif
break;
case BTRFS_CSUM_ITEM_KEY:
- ci = btrfs_item_ptr(l, i, struct btrfs_csum_item);
printf("\t\tcsum item\n");
break;
case BTRFS_EXTENT_CSUM_KEY:
- ci = btrfs_item_ptr(l, i, struct btrfs_csum_item);
printf("\t\textent csum item\n");
break;
case BTRFS_EXTENT_DATA_KEY:
struct list_head *cur;
struct map_lookup *map;
int min_stripe_size = 1 * 1024 * 1024;
- u64 physical;
u64 calc_size = 8 * 1024 * 1024;
u64 min_free;
u64 max_chunk_size = 4 * calc_size;
btrfs_set_stack_stripe_devid(stripe, device->devid);
btrfs_set_stack_stripe_offset(stripe, dev_offset);
memcpy(stripe->dev_uuid, device->uuid, BTRFS_UUID_SIZE);
- physical = dev_offset;
index++;
}
BUG_ON(!list_empty(&private_devs));
struct cache_extent *ce;
struct map_lookup *map;
int ret;
- u64 offset;
ce = find_first_cache_extent(&map_tree->cache_tree, logical);
BUG_ON(!ce);
BUG_ON(ce->start > logical || ce->start + ce->size < logical);
map = container_of(ce, struct map_lookup, ce);
- offset = logical - ce->start;
if (map->type & (BTRFS_BLOCK_GROUP_DUP | BTRFS_BLOCK_GROUP_RAID1))
ret = map->num_stripes;
else if (map->type & BTRFS_BLOCK_GROUP_RAID10)