continue;
BUG_ON(!ref->wanted_disk_byte);
eb = read_tree_block(fs_info->tree_root, ref->wanted_disk_byte,
- fs_info->tree_root->leafsize, 0);
+ fs_info->tree_root->nodesize, 0);
if (!extent_buffer_uptodate(eb)) {
free_extent_buffer(eb);
return -EIO;
}
btrfs_item_key_to_cpu(path->nodes[0], found_key, path->slots[0]);
if (found_key->type == BTRFS_METADATA_ITEM_KEY)
- size = fs_info->extent_root->leafsize;
+ size = fs_info->extent_root->nodesize;
else if (found_key->type == BTRFS_EXTENT_ITEM_KEY)
size = found_key->offset;
{
struct extent_buffer *eb;
- eb = read_tree_block(root, bytenr, root->leafsize, 0);
+ eb = read_tree_block(root, bytenr, root->nodesize, 0);
if (!extent_buffer_uptodate(eb))
return -EIO;;
struct extent_buffer *next;
next = read_tree_block(root, btrfs_node_blockptr(eb, i),
- root->leafsize,
+ root->nodesize,
btrfs_node_ptr_generation(eb, i));
if (!extent_buffer_uptodate(next))
continue;
return -EINVAL;
}
- eb = read_tree_block(root, block, root->leafsize, 0);
+ eb = read_tree_block(root, block, root->nodesize, 0);
if (!extent_buffer_uptodate(eb)) {
fprintf(stderr, "Couldn't read in tree block %s\n", field);
return -EINVAL;
struct list_head list;
struct list_head overlapping_chunks;
size_t num_items;
- u32 leafsize;
+ u32 nodesize;
u64 devid;
u64 alloced_chunks;
u64 last_physical_offset;
int i = 0;
int ret;
- ret = add_extent(btrfs_header_bytenr(eb), root->leafsize, metadump, 0);
+ ret = add_extent(btrfs_header_bytenr(eb), root->nodesize, metadump, 0);
if (ret) {
fprintf(stderr, "Error adding metadata block\n");
return ret;
continue;
ri = btrfs_item_ptr(eb, i, struct btrfs_root_item);
bytenr = btrfs_disk_root_bytenr(eb, ri);
- tmp = read_tree_block(root, bytenr, root->leafsize, 0);
+ tmp = read_tree_block(root, bytenr, root->nodesize, 0);
if (!extent_buffer_uptodate(tmp)) {
fprintf(stderr,
"Error reading log root block\n");
return ret;
} else {
bytenr = btrfs_node_blockptr(eb, i);
- tmp = read_tree_block(root, bytenr, root->leafsize, 0);
+ tmp = read_tree_block(root, bytenr, root->nodesize, 0);
if (!extent_buffer_uptodate(tmp)) {
fprintf(stderr, "Error reading log block\n");
return -EIO;
bytenr = key.objectid;
if (key.type == BTRFS_METADATA_ITEM_KEY)
- num_bytes = extent_root->leafsize;
+ num_bytes = extent_root->nodesize;
else
num_bytes = key.offset;
return -EIO;
}
- BUG_ON(root->nodesize != root->leafsize);
-
ret = metadump_init(&metadump, root, out, num_threads,
compress_level, sanitize);
if (ret) {
u64 bytenr = async->start;
int i;
- if (size_left % mdres->leafsize)
+ if (size_left % mdres->nodesize)
return 0;
- eb = alloc_dummy_eb(bytenr, mdres->leafsize);
+ eb = alloc_dummy_eb(bytenr, mdres->nodesize);
if (!eb)
return -ENOMEM;
while (size_left) {
eb->start = bytenr;
- memcpy(eb->data, buffer, mdres->leafsize);
+ memcpy(eb->data, buffer, mdres->nodesize);
if (btrfs_header_bytenr(eb) != bytenr)
break;
memcpy(buffer, eb->data, eb->len);
csum_block(buffer, eb->len);
next:
- size_left -= mdres->leafsize;
- buffer += mdres->leafsize;
- bytenr += mdres->leafsize;
+ size_left -= mdres->nodesize;
+ buffer += mdres->nodesize;
+ bytenr += mdres->nodesize;
}
free(eb);
int err = 0;
pthread_mutex_lock(&mdres->mutex);
- while (!mdres->leafsize || list_empty(&mdres->list)) {
+ while (!mdres->nodesize || list_empty(&mdres->list)) {
if (mdres->done) {
pthread_mutex_unlock(&mdres->mutex);
goto out;
int ret;
/* We've already been initialized */
- if (mdres->leafsize)
+ if (mdres->nodesize)
return 0;
if (mdres->compress_method == COMPRESS_ZLIB) {
}
super = (struct btrfs_super_block *)outbuf;
- mdres->leafsize = btrfs_super_leafsize(super);
+ mdres->nodesize = btrfs_super_nodesize(super);
memcpy(mdres->fsid, super->fsid, BTRFS_FSID_SIZE);
memcpy(mdres->uuid, super->dev_item.uuid,
BTRFS_UUID_SIZE);
int ret = 0;
int i;
- eb = alloc_dummy_eb(bytenr, mdres->leafsize);
+ eb = alloc_dummy_eb(bytenr, mdres->nodesize);
if (!eb) {
ret = -ENOMEM;
goto out;
}
while (item_bytenr != bytenr) {
- buffer += mdres->leafsize;
- item_bytenr += mdres->leafsize;
+ buffer += mdres->nodesize;
+ item_bytenr += mdres->nodesize;
}
- memcpy(eb->data, buffer, mdres->leafsize);
+ memcpy(eb->data, buffer, mdres->nodesize);
if (btrfs_header_bytenr(eb) != bytenr) {
fprintf(stderr, "Eb bytenr doesn't match found bytenr\n");
ret = -EIO;
pthread_mutex_lock(&mdres->mutex);
super = (struct btrfs_super_block *)buffer;
chunk_root_bytenr = btrfs_super_chunk_root(super);
- mdres->leafsize = btrfs_super_leafsize(super);
+ mdres->nodesize = btrfs_super_nodesize(super);
memcpy(mdres->fsid, super->fsid, BTRFS_FSID_SIZE);
memcpy(mdres->uuid, super->dev_item.uuid,
BTRFS_UUID_SIZE);
}
logical = key.objectid;
if (key.type == BTRFS_METADATA_ITEM_KEY)
- len = fs_info->tree_root->leafsize;
+ len = fs_info->tree_root->nodesize;
else
len = key.offset;
u16 csum_size;
u32 sectorsize;
- u32 leafsize;
+ u32 nodesize;
u64 generation;
u64 chunk_root_generation;
printf("DEVICE SCAN RESULT:\n");
printf("Filesystem Information:\n");
printf("\tsectorsize: %d\n", rc->sectorsize);
- printf("\tleafsize: %d\n", rc->leafsize);
+ printf("\tnodesize: %d\n", rc->nodesize);
printf("\ttree root generation: %llu\n", rc->generation);
printf("\tchunk root generation: %llu\n", rc->chunk_root_generation);
printf("\n");
if (ret)
return 1;
- buf = malloc(sizeof(*buf) + rc->leafsize);
+ buf = malloc(sizeof(*buf) + rc->nodesize);
if (!buf)
return -ENOMEM;
- buf->len = rc->leafsize;
+ buf->len = rc->nodesize;
bytenr = 0;
while (1) {
if (is_super_block_address(bytenr))
bytenr += rc->sectorsize;
- if (pread64(fd, buf->data, rc->leafsize, bytenr) <
- rc->leafsize)
+ if (pread64(fd, buf->data, rc->nodesize, bytenr) <
+ rc->nodesize)
break;
if (memcmp_extent_buffer(buf, rc->fs_devices->fsid,
break;
}
next_node:
- bytenr += rc->leafsize;
+ bytenr += rc->nodesize;
}
out:
close(fd);
key.type == BTRFS_METADATA_ITEM_KEY) {
old_val = btrfs_super_bytes_used(fs_info->super_copy);
if (key.type == BTRFS_METADATA_ITEM_KEY)
- old_val += root->leafsize;
+ old_val += root->nodesize;
else
old_val += key.offset;
btrfs_set_super_bytes_used(fs_info->super_copy,
}
rc->sectorsize = btrfs_super_sectorsize(sb);
- rc->leafsize = btrfs_super_leafsize(sb);
+ rc->nodesize = btrfs_super_nodesize(sb);
rc->generation = btrfs_super_generation(sb);
rc->chunk_root_generation = btrfs_super_chunk_root_generation(sb);
rc->csum_size = btrfs_super_csum_size(sb);
btrfs_add_corrupt_extent_record(root->fs_info,
&node_key,
path->nodes[*level]->start,
- root->leafsize, *level);
+ root->nodesize, *level);
err = -EIO;
goto out;
}
if (key.type == BTRFS_METADATA_ITEM_KEY) {
metadata = 1;
- num_bytes = root->leafsize;
+ num_bytes = root->nodesize;
} else {
num_bytes = key.offset;
}
if (key.type == BTRFS_EXTENT_ITEM_KEY)
last = key.objectid + key.offset;
else
- last = key.objectid + root->leafsize;
+ last = key.objectid + root->nodesize;
path->slots[0]++;
continue;
}
if (key.type == BTRFS_EXTENT_ITEM_KEY)
last = key.objectid + key.offset;
else
- last = key.objectid + root->leafsize;
+ last = key.objectid + root->nodesize;
path->slots[0]++;
}
if (found_key.type == BTRFS_EXTENT_ITEM_KEY ||
found_key.type == BTRFS_METADATA_ITEM_KEY) {
u64 bytes = (found_key.type == BTRFS_EXTENT_ITEM_KEY) ?
- found_key.offset : root->leafsize;
+ found_key.offset : root->nodesize;
ret = btrfs_update_block_group(trans, root, bytenr,
bytes, 0, 0);
if (!back->is_data)
rec->max_size = max_t(u64, rec->max_size,
- info->extent_root->leafsize);
+ info->extent_root->nodesize);
if (!allocated) {
u32 item_size = sizeof(*ei);
struct btrfs_root_item *ri;
struct btrfs_key key;
u64 bytenr;
- u32 leafsize;
+ u32 nodesize;
int level = btrfs_header_level(eb);
int nritems;
int ret;
btrfs_pin_extent(fs_info, eb->start, eb->len);
- leafsize = btrfs_super_leafsize(fs_info->super_copy);
+ nodesize = btrfs_super_nodesize(fs_info->super_copy);
nritems = btrfs_header_nritems(eb);
for (i = 0; i < nritems; i++) {
if (level == 0) {
* just pass in extent_root.
*/
tmp = read_tree_block(fs_info->extent_root, bytenr,
- leafsize, 0);
+ nodesize, 0);
if (!extent_buffer_uptodate(tmp)) {
fprintf(stderr, "Error reading root block\n");
return -EIO;
/* If we aren't the tree root don't read the block */
if (level == 1 && !tree_root) {
- btrfs_pin_extent(fs_info, bytenr, leafsize);
+ btrfs_pin_extent(fs_info, bytenr, nodesize);
continue;
}
tmp = read_tree_block(fs_info->extent_root, bytenr,
- leafsize, 0);
+ nodesize, 0);
if (!extent_buffer_uptodate(tmp)) {
fprintf(stderr, "Error reading tree block\n");
return -EIO;
if (block_only) {
leaf = read_tree_block(root,
block_only,
- root->leafsize, 0);
+ root->nodesize, 0);
if (extent_buffer_uptodate(leaf) &&
btrfs_header_level(leaf) != 0) {
struct btrfs_key found_key;
int i;
- stat->total_bytes += root->leafsize;
+ stat->total_bytes += root->nodesize;
stat->total_leaves++;
if (!find_inline)
{
struct extent_buffer *b = path->nodes[level];
u64 last_block;
- u64 cluster_size = root->leafsize;
+ u64 cluster_size = root->nodesize;
int i;
int ret = 0;
find_inline);
else
ret = walk_leaf(root, path, stat, find_inline);
- if (last_block + root->leafsize != cur_blocknr) {
+ if (last_block + root->nodesize != cur_blocknr) {
u64 distance = calc_distance(last_block +
- root->leafsize,
+ root->nodesize,
cur_blocknr);
stat->total_seeks++;
stat->total_seek_len += distance;
stat->forward_seeks++;
else
stat->backward_seeks++;
- if (cluster_size != root->leafsize) {
+ if (cluster_size != root->nodesize) {
stat->total_cluster_size += cluster_size;
stat->total_clusters++;
if (cluster_size < stat->min_cluster_size)
if (cluster_size > stat->max_cluster_size)
stat->max_cluster_size = cluster_size;
}
- cluster_size = root->leafsize;
+ cluster_size = root->nodesize;
} else {
- cluster_size += root->leafsize;
+ cluster_size += root->nodesize;
}
last_block = cur_blocknr;
if (cur_blocknr < stat->lowest_bytenr)
stat.lowest_bytenr = btrfs_header_bytenr(root->node);
stat.highest_bytenr = stat.lowest_bytenr;
stat.min_cluster_size = (u64)-1;
- stat.max_cluster_size = root->leafsize;
+ stat.max_cluster_size = root->nodesize;
path->nodes[level] = root->node;
if (gettimeofday(&start, NULL)) {
fprintf(stderr, "Error getting time: %d\n", errno);
root_location = btrfs_super_root(fs_info->super_copy);
generation = btrfs_super_generation(fs_info->super_copy);
root->node = read_tree_block(root, root_location,
- root->leafsize, generation);
+ root->nodesize, generation);
if (!extent_buffer_uptodate(root->node)) {
fprintf(stderr, "Error opening tree root\n");
close_ctree(root);
if (fs_location != 0) {
free_extent_buffer(root->node);
- root->node = read_tree_block(root, fs_location, root->leafsize, 0);
+ root->node = read_tree_block(root, fs_location, root->nodesize, 0);
if (!extent_buffer_uptodate(root->node)) {
fprintf(stderr, "Failed to read fs location\n");
ret = 1;
else
btrfs_item_key(l, &disk_key, mid);
- right = btrfs_alloc_free_block(trans, root, root->leafsize,
+ right = btrfs_alloc_free_block(trans, root, root->nodesize,
root->root_key.objectid,
&disk_key, 0, l->start, 0);
if (IS_ERR(right)) {
sizeof(struct btrfs_header)) / \
sizeof(struct btrfs_key_ptr))
#define __BTRFS_LEAF_DATA_SIZE(bs) ((bs) - sizeof(struct btrfs_header))
-#define BTRFS_LEAF_DATA_SIZE(r) (__BTRFS_LEAF_DATA_SIZE(r->leafsize))
+#define BTRFS_LEAF_DATA_SIZE(r) (__BTRFS_LEAF_DATA_SIZE(r->nodesize))
#define BTRFS_MAX_INLINE_DATA_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \
sizeof(struct btrfs_item) - \
sizeof(struct btrfs_file_extent_item))
__le64 num_devices;
__le32 sectorsize;
__le32 nodesize;
+ /* Unused and must be equal to nodesize */
__le32 leafsize;
__le32 stripesize;
__le32 sys_chunk_array_size;
/* node allocations are done in nodesize units */
u32 nodesize;
- /* leaf allocations are done in leafsize units */
+ /* Unused, equal to nodesize */
u32 leafsize;
- /* leaf allocations are done in leafsize units */
+ /* leaf allocations are done in nodesize units */
u32 stripesize;
int ref_cows;
{
struct btrfs_fs_devices *fs_devices;
- u32 leafsize = btrfs_super_leafsize(fs_info->super_copy);
+ u32 nodesize = btrfs_super_nodesize(fs_info->super_copy);
int ret = BTRFS_BAD_FSID;
if (buf->start != btrfs_header_bytenr(buf))
if (btrfs_header_level(buf) >= BTRFS_MAX_LEVEL)
return BTRFS_BAD_LEVEL;
if (btrfs_header_nritems(buf) > max_nritems(btrfs_header_level(buf),
- leafsize))
+ nodesize))
return BTRFS_BAD_NRITEMS;
fs_devices = fs_info->fs_devices;
{
struct btrfs_super_block *sb = fs_info->super_copy;
struct btrfs_root *root = fs_info->tree_root;
- u32 leafsize = btrfs_super_leafsize(sb);
+ u32 nodesize = btrfs_super_nodesize(sb);
int ret;
ret = find_and_setup_root(root, fs_info, objectid, info_root);
* million of places that assume a root has a valid ->node
*/
info_root->node =
- btrfs_find_create_tree_block(fs_info, 0, leafsize);
+ btrfs_find_create_tree_block(fs_info, 0, nodesize);
if (!info_root->node)
return -ENOMEM;
clear_extent_buffer_uptodate(NULL, info_root->node);
GFP_NOFS);
}
if (key.type == BTRFS_METADATA_ITEM_KEY)
- last = key.objectid + root->leafsize;
+ last = key.objectid + root->nodesize;
else
last = key.objectid + key.offset;
}
if (metadata &&
!btrfs_fs_incompat(root->fs_info,
BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA)) {
- offset = root->leafsize;
+ offset = root->nodesize;
metadata = 0;
}
path->slots[0]);
if (key.objectid == bytenr &&
key.type == BTRFS_EXTENT_ITEM_KEY &&
- key.offset == root->leafsize)
+ key.offset == root->nodesize)
ret = 0;
}
if (ret) {
btrfs_release_path(path);
key.type = BTRFS_EXTENT_ITEM_KEY;
- key.offset = root->leafsize;
+ key.offset = root->nodesize;
metadata = 0;
goto again;
}
key.offset = level;
key.type = BTRFS_METADATA_ITEM_KEY;
} else {
- key.offset = root->leafsize;
+ key.offset = root->nodesize;
key.type = BTRFS_EXTENT_ITEM_KEY;
}
btrfs_item_key_to_cpu(path->nodes[0], &key,
path->slots[0]);
if (key.objectid == bytenr &&
- key.offset == root->leafsize &&
+ key.offset == root->nodesize &&
key.type == BTRFS_EXTENT_ITEM_KEY)
ret = 0;
}
if (ret) {
btrfs_release_path(path);
- key.offset = root->leafsize;
+ key.offset = root->nodesize;
key.type = BTRFS_EXTENT_ITEM_KEY;
goto again;
}
btrfs_mark_buffer_dirty(leaf);
btrfs_free_path(path);
- ret = update_block_group(trans, root, ins->objectid, root->leafsize,
+ ret = update_block_group(trans, root, ins->objectid, root->nodesize,
1, 0);
return ret;
}
key.objectid, key.offset, 1, 0);
BUG_ON(ret);
} else if (key.type == BTRFS_METADATA_ITEM_KEY) {
- bytes_used += root->leafsize;
+ bytes_used += root->nodesize;
ret = btrfs_update_block_group(trans, root,
- key.objectid, root->leafsize, 1, 0);
+ key.objectid, root->nodesize, 1, 0);
BUG_ON(ret);
}
path.slots[0]++;
u64 stripe_len = this_len;
this_len = min(this_len, bytes_left);
- this_len = min(this_len, (u64)info->tree_root->leafsize);
+ this_len = min(this_len, (u64)info->tree_root->nodesize);
eb = malloc(sizeof(struct extent_buffer) + this_len);
BUG_ON(!eb);
/* Return value is the same as btrfs_find_root_search(). */
static int add_eb_to_result(struct extent_buffer *eb,
struct cache_tree *result,
- u32 leafsize,
+ u32 nodesize,
struct btrfs_find_root_filter *filter,
struct cache_extent **match)
{
/* Same level, insert it into the eb_tree */
if (level == gen_cache->highest_level) {
ret = add_cache_extent(&gen_cache->eb_tree,
- start, leafsize);
+ start, nodesize);
if (ret < 0 && ret != -EEXIST)
return ret;
ret = 0;
u64 chunk_offset = 0;
u64 chunk_size = 0;
u64 offset = 0;
- u32 leafsize = btrfs_super_leafsize(fs_info->super_copy);
+ u32 nodesize = btrfs_super_nodesize(fs_info->super_copy);
int suppress_errors = 0;
int ret = 0;
}
for (offset = chunk_offset;
offset < chunk_offset + chunk_size;
- offset += leafsize) {
- eb = read_tree_block_fs_info(fs_info, offset, leafsize,
+ offset += nodesize) {
+ eb = read_tree_block_fs_info(fs_info, offset, nodesize,
0);
if (!eb || IS_ERR(eb))
continue;
- ret = add_eb_to_result(eb, result, leafsize, filter,
+ ret = add_eb_to_result(eb, result, nodesize, filter,
match);
free_extent_buffer(eb);
if (ret)
bytenr = key.objectid;
num_bytes = key.offset;
if (key.type == BTRFS_METADATA_ITEM_KEY) {
- num_bytes = info->extent_root->leafsize;
+ num_bytes = info->extent_root->nodesize;
meta = 1;
}
struct btrfs_ioctl_dev_info_args *di_args);
u64 get_partition_size(const char *dev);
-int test_minimum_size(const char *file, u32 leafsize);
+int test_minimum_size(const char *file, u32 nodesize);
int test_issubvolname(const char *name);
int test_issubvolume(const char *path);
int test_isdir(const char *path);
* To avoid the overkill calculation, (system group + global block rsv) * 2
* for *EACH* device should be good enough.
*/
-static inline u64 btrfs_min_global_blk_rsv_size(u32 leafsize)
+static inline u64 btrfs_min_global_blk_rsv_size(u32 nodesize)
{
- return leafsize << 10;
+ return nodesize << 10;
}
-static inline u64 btrfs_min_dev_size(u32 leafsize)
+static inline u64 btrfs_min_dev_size(u32 nodesize)
{
return 2 * (BTRFS_MKFS_SYSTEM_GROUP_SIZE +
- btrfs_min_global_blk_rsv_size(leafsize));
+ btrfs_min_global_blk_rsv_size(nodesize));
}
int find_next_key(struct btrfs_path *path, struct btrfs_key *key);