btrfs-progs: replace leafsize with nodesize

Nodesize is used in kernel, the values are always equal. We have to keep
leafsize in headers, similarly the tree setting functions still take and
set leafsize, but it's effectively a no-op.

Signed-off-by: David Sterba <dsterba@suse.com>
master
David Sterba 2016-04-01 12:57:11 +02:00
parent b005ca0249
commit 2a796d84af
17 changed files with 88 additions and 89 deletions

View File

@ -451,7 +451,7 @@ static int __add_missing_keys(struct btrfs_fs_info *fs_info,
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;
@ -1157,7 +1157,7 @@ int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical,
}
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;

View File

@ -162,7 +162,7 @@ static int corrupt_keys_in_block(struct btrfs_root *root, u64 bytenr)
{
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;;
@ -289,7 +289,7 @@ static void btrfs_corrupt_extent_tree(struct btrfs_trans_handle *trans,
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;
@ -700,7 +700,7 @@ static int corrupt_metadata_block(struct btrfs_root *root, u64 block,
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;

View File

@ -133,7 +133,7 @@ struct mdrestore_struct {
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;
@ -1073,7 +1073,7 @@ static int copy_tree_blocks(struct btrfs_root *root, struct extent_buffer *eb,
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;
@ -1091,7 +1091,7 @@ static int copy_tree_blocks(struct btrfs_root *root, struct extent_buffer *eb,
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");
@ -1103,7 +1103,7 @@ static int copy_tree_blocks(struct btrfs_root *root, struct extent_buffer *eb,
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;
@ -1255,7 +1255,7 @@ static int copy_from_extent_tree(struct metadump_struct *metadump,
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;
@ -1321,8 +1321,6 @@ static int create_metadump(const char *input, FILE *out, int num_threads,
return -EIO;
}
BUG_ON(root->nodesize != root->leafsize);
ret = metadump_init(&metadump, root, out, num_threads,
compress_level, sanitize);
if (ret) {
@ -1550,16 +1548,16 @@ static int fixup_chunk_tree_block(struct mdrestore_struct *mdres,
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;
@ -1614,9 +1612,9 @@ static int fixup_chunk_tree_block(struct mdrestore_struct *mdres,
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);
@ -1687,7 +1685,7 @@ static void *restore_worker(void *data)
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;
@ -1859,7 +1857,7 @@ static int fill_mdres_info(struct mdrestore_struct *mdres,
int ret;
/* We've already been initialized */
if (mdres->leafsize)
if (mdres->nodesize)
return 0;
if (mdres->compress_method == COMPRESS_ZLIB) {
@ -1881,7 +1879,7 @@ static int fill_mdres_info(struct mdrestore_struct *mdres,
}
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);
@ -1987,18 +1985,18 @@ static int read_chunk_block(struct mdrestore_struct *mdres, u8 *buffer,
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;
@ -2301,7 +2299,7 @@ static int build_chunk_tree(struct mdrestore_struct *mdres,
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);

View File

@ -81,7 +81,7 @@ again:
}
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;

View File

@ -47,7 +47,7 @@ struct recover_control {
u16 csum_size;
u32 sectorsize;
u32 leafsize;
u32 nodesize;
u64 generation;
u64 chunk_root_generation;
@ -477,7 +477,7 @@ static void print_scan_result(struct recover_control *rc)
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");
@ -761,10 +761,10 @@ static int scan_one_device(void *dev_scan_struct)
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) {
@ -773,8 +773,8 @@ static int scan_one_device(void *dev_scan_struct)
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,
@ -818,7 +818,7 @@ static int scan_one_device(void *dev_scan_struct)
break;
}
next_node:
bytenr += rc->leafsize;
bytenr += rc->nodesize;
}
out:
close(fd);
@ -1070,7 +1070,7 @@ again:
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,
@ -1538,7 +1538,7 @@ static int recover_prepare(struct recover_control *rc, char *path)
}
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);

View File

@ -1890,7 +1890,7 @@ static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path,
btrfs_add_corrupt_extent_record(root->fs_info,
&node_key,
path->nodes[*level]->start,
root->leafsize, *level);
root->nodesize, *level);
err = -EIO;
goto out;
}
@ -5187,7 +5187,7 @@ static int process_extent_item(struct btrfs_root *root,
if (key.type == BTRFS_METADATA_ITEM_KEY) {
metadata = 1;
num_bytes = root->leafsize;
num_bytes = root->nodesize;
} else {
num_bytes = key.offset;
}
@ -5407,7 +5407,7 @@ static int verify_space_cache(struct btrfs_root *root,
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;
}
@ -5419,7 +5419,7 @@ static int verify_space_cache(struct btrfs_root *root,
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]++;
}
@ -6379,7 +6379,7 @@ static int delete_extent_records(struct btrfs_trans_handle *trans,
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);
@ -6414,7 +6414,7 @@ static int record_extent(struct btrfs_trans_handle *trans,
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);
@ -8421,7 +8421,7 @@ static int pin_down_tree_blocks(struct btrfs_fs_info *fs_info,
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;
@ -8438,7 +8438,7 @@ static int pin_down_tree_blocks(struct btrfs_fs_info *fs_info,
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) {
@ -8460,7 +8460,7 @@ static int pin_down_tree_blocks(struct btrfs_fs_info *fs_info,
* 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;
@ -8474,12 +8474,12 @@ static int pin_down_tree_blocks(struct btrfs_fs_info *fs_info,
/* 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;

View File

@ -299,7 +299,7 @@ int cmd_inspect_dump_tree(int argc, char **argv)
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) {

View File

@ -104,7 +104,7 @@ static int walk_leaf(struct btrfs_root *root, struct btrfs_path *path,
struct btrfs_key found_key;
int i;
stat->total_bytes += root->leafsize;
stat->total_bytes += root->nodesize;
stat->total_leaves++;
if (!find_inline)
@ -137,7 +137,7 @@ static int walk_nodes(struct btrfs_root *root, struct btrfs_path *path,
{
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;
@ -166,9 +166,9 @@ static int walk_nodes(struct btrfs_root *root, struct btrfs_path *path,
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;
@ -184,7 +184,7 @@ static int walk_nodes(struct btrfs_root *root, struct btrfs_path *path,
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)
@ -192,9 +192,9 @@ static int walk_nodes(struct btrfs_root *root, struct btrfs_path *path,
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)
@ -337,7 +337,7 @@ static int calc_root_size(struct btrfs_root *tree_root, struct btrfs_key *key,
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);

View File

@ -1284,7 +1284,7 @@ static struct btrfs_root *open_fs(const char *dev, u64 root_location,
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);
@ -1535,7 +1535,7 @@ int cmd_restore(int argc, char **argv)
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;

View File

@ -2113,7 +2113,7 @@ again:
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)) {

View File

@ -345,7 +345,7 @@ struct btrfs_header {
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))
@ -428,6 +428,7 @@ struct btrfs_super_block {
__le64 num_devices;
__le32 sectorsize;
__le32 nodesize;
/* Unused and must be equal to nodesize */
__le32 leafsize;
__le32 stripesize;
__le32 sys_chunk_array_size;
@ -1060,10 +1061,10 @@ struct btrfs_root {
/* 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;

View File

@ -56,7 +56,7 @@ static int check_tree_block(struct btrfs_fs_info *fs_info,
{
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))
@ -64,7 +64,7 @@ static int check_tree_block(struct btrfs_fs_info *fs_info,
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;
@ -934,7 +934,7 @@ static int setup_root_or_create_block(struct btrfs_fs_info *fs_info,
{
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);
@ -947,7 +947,7 @@ static int setup_root_or_create_block(struct btrfs_fs_info *fs_info,
* 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);

View File

@ -153,7 +153,7 @@ static int cache_block_group(struct btrfs_root *root,
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;
}
@ -1458,7 +1458,7 @@ int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
if (metadata &&
!btrfs_fs_incompat(root->fs_info,
BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA)) {
offset = root->leafsize;
offset = root->nodesize;
metadata = 0;
}
@ -1493,14 +1493,14 @@ again:
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;
}
@ -1565,7 +1565,7 @@ int btrfs_set_block_flags(struct btrfs_trans_handle *trans,
key.offset = level;
key.type = BTRFS_METADATA_ITEM_KEY;
} else {
key.offset = root->leafsize;
key.offset = root->nodesize;
key.type = BTRFS_EXTENT_ITEM_KEY;
}
@ -1582,13 +1582,13 @@ again:
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;
}
@ -2750,7 +2750,7 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,
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;
}
@ -3897,9 +3897,9 @@ int btrfs_fix_block_accounting(struct btrfs_trans_handle *trans,
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]++;

View File

@ -771,7 +771,7 @@ int write_data_to_disk(struct btrfs_fs_info *info, void *buf, u64 offset,
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);

View File

@ -30,7 +30,7 @@
/* 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)
{
@ -80,7 +80,7 @@ static int add_eb_to_result(struct extent_buffer *eb,
/* 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;
@ -110,7 +110,7 @@ int btrfs_find_root_search(struct btrfs_fs_info *fs_info,
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;
@ -132,12 +132,12 @@ int btrfs_find_root_search(struct btrfs_fs_info *fs_info,
}
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)

View File

@ -944,7 +944,7 @@ static int scan_extents(struct btrfs_fs_info *info,
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;
}

10
utils.h
View File

@ -191,7 +191,7 @@ int get_device_info(int fd, u64 devid,
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);
@ -209,14 +209,14 @@ int get_subvol_info(const char *fullpath, struct root_info *get_ri);
* 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);