mirror of
https://github.com/kdave/btrfs-progs
synced 2025-02-16 09:46:55 +00:00
btrfs-progs: drop local blocksize variables if they're nodesize
Prep work so we can drop the blocksize argument from several functions. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
5d8b645f6f
commit
1fa9653dc8
@ -802,11 +802,10 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans,
|
||||
if (ref->count && ref->parent) {
|
||||
if (extent_item_pos && !ref->inode_list &&
|
||||
ref->level == 0) {
|
||||
u32 bsz;
|
||||
struct extent_buffer *eb;
|
||||
bsz = fs_info->nodesize;
|
||||
eb = read_tree_block(fs_info,
|
||||
ref->parent, bsz, 0);
|
||||
|
||||
eb = read_tree_block(fs_info, ref->parent,
|
||||
fs_info->nodesize, 0);
|
||||
if (!extent_buffer_uptodate(eb)) {
|
||||
free_extent_buffer(eb);
|
||||
ret = -EIO;
|
||||
|
41
cmds-check.c
41
cmds-check.c
@ -1979,7 +1979,6 @@ static void reada_walk_down(struct btrfs_root *root,
|
||||
u64 bytenr;
|
||||
u64 ptr_gen;
|
||||
u32 nritems;
|
||||
u32 blocksize;
|
||||
int i;
|
||||
int level;
|
||||
|
||||
@ -1988,11 +1987,11 @@ static void reada_walk_down(struct btrfs_root *root,
|
||||
return;
|
||||
|
||||
nritems = btrfs_header_nritems(node);
|
||||
blocksize = fs_info->nodesize;
|
||||
for (i = slot; i < nritems; i++) {
|
||||
bytenr = btrfs_node_blockptr(node, i);
|
||||
ptr_gen = btrfs_node_ptr_generation(node, i);
|
||||
readahead_tree_block(fs_info, bytenr, blocksize, ptr_gen);
|
||||
readahead_tree_block(fs_info, bytenr, fs_info->nodesize,
|
||||
ptr_gen);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2116,7 +2115,6 @@ static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path,
|
||||
struct btrfs_fs_info *fs_info = root->fs_info;
|
||||
struct extent_buffer *next;
|
||||
struct extent_buffer *cur;
|
||||
u32 blocksize;
|
||||
int ret, err = 0;
|
||||
u64 refs;
|
||||
|
||||
@ -2165,7 +2163,6 @@ static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path,
|
||||
}
|
||||
bytenr = btrfs_node_blockptr(cur, path->slots[*level]);
|
||||
ptr_gen = btrfs_node_ptr_generation(cur, path->slots[*level]);
|
||||
blocksize = fs_info->nodesize;
|
||||
|
||||
if (bytenr == nrefs->bytenr[*level - 1]) {
|
||||
refs = nrefs->refs[*level - 1];
|
||||
@ -2189,12 +2186,12 @@ static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path,
|
||||
}
|
||||
}
|
||||
|
||||
next = btrfs_find_tree_block(fs_info, bytenr, blocksize);
|
||||
next = btrfs_find_tree_block(fs_info, bytenr, fs_info->nodesize);
|
||||
if (!next || !btrfs_buffer_uptodate(next, ptr_gen)) {
|
||||
free_extent_buffer(next);
|
||||
reada_walk_down(root, cur, path->slots[*level]);
|
||||
next = read_tree_block(root->fs_info, bytenr, blocksize,
|
||||
ptr_gen);
|
||||
next = read_tree_block(root->fs_info, bytenr,
|
||||
fs_info->nodesize, ptr_gen);
|
||||
if (!extent_buffer_uptodate(next)) {
|
||||
struct btrfs_key node_key;
|
||||
|
||||
@ -2255,7 +2252,6 @@ static int walk_down_tree_v2(struct btrfs_root *root, struct btrfs_path *path,
|
||||
struct btrfs_fs_info *fs_info = root->fs_info;
|
||||
struct extent_buffer *next;
|
||||
struct extent_buffer *cur;
|
||||
u32 blocksize;
|
||||
int ret;
|
||||
|
||||
WARN_ON(*level < 0);
|
||||
@ -2295,7 +2291,6 @@ static int walk_down_tree_v2(struct btrfs_root *root, struct btrfs_path *path,
|
||||
}
|
||||
bytenr = btrfs_node_blockptr(cur, path->slots[*level]);
|
||||
ptr_gen = btrfs_node_ptr_generation(cur, path->slots[*level]);
|
||||
blocksize = fs_info->nodesize;
|
||||
|
||||
ret = update_nodes_refs(root, bytenr, nrefs, *level - 1);
|
||||
if (ret)
|
||||
@ -2305,12 +2300,12 @@ static int walk_down_tree_v2(struct btrfs_root *root, struct btrfs_path *path,
|
||||
continue;
|
||||
}
|
||||
|
||||
next = btrfs_find_tree_block(fs_info, bytenr, blocksize);
|
||||
next = btrfs_find_tree_block(fs_info, bytenr, fs_info->nodesize);
|
||||
if (!next || !btrfs_buffer_uptodate(next, ptr_gen)) {
|
||||
free_extent_buffer(next);
|
||||
reada_walk_down(root, cur, path->slots[*level]);
|
||||
next = read_tree_block(fs_info, bytenr, blocksize,
|
||||
ptr_gen);
|
||||
next = read_tree_block(fs_info, bytenr,
|
||||
fs_info->nodesize, ptr_gen);
|
||||
if (!extent_buffer_uptodate(next)) {
|
||||
struct btrfs_key node_key;
|
||||
|
||||
@ -10401,7 +10396,6 @@ static int query_tree_block_level(struct btrfs_fs_info *fs_info, u64 bytenr)
|
||||
struct btrfs_extent_item *ei;
|
||||
u64 flags;
|
||||
u64 transid;
|
||||
u32 nodesize = btrfs_super_nodesize(fs_info->super_copy);
|
||||
u8 backref_level;
|
||||
u8 header_level;
|
||||
int ret;
|
||||
@ -10447,7 +10441,7 @@ static int query_tree_block_level(struct btrfs_fs_info *fs_info, u64 bytenr)
|
||||
btrfs_release_path(&path);
|
||||
|
||||
/* Get level from tree block as an alternative source */
|
||||
eb = read_tree_block(fs_info, bytenr, nodesize, transid);
|
||||
eb = read_tree_block(fs_info, bytenr, fs_info->nodesize, transid);
|
||||
if (!extent_buffer_uptodate(eb)) {
|
||||
free_extent_buffer(eb);
|
||||
return -EIO;
|
||||
@ -10597,12 +10591,11 @@ static int check_shared_block_backref(struct btrfs_fs_info *fs_info,
|
||||
u64 parent, u64 bytenr, int level)
|
||||
{
|
||||
struct extent_buffer *eb;
|
||||
u32 nodesize = btrfs_super_nodesize(fs_info->super_copy);
|
||||
u32 nr;
|
||||
int found_parent = 0;
|
||||
int i;
|
||||
|
||||
eb = read_tree_block(fs_info, parent, nodesize, 0);
|
||||
eb = read_tree_block(fs_info, parent, fs_info->nodesize, 0);
|
||||
if (!extent_buffer_uptodate(eb))
|
||||
goto out;
|
||||
|
||||
@ -10633,7 +10626,7 @@ out:
|
||||
if (!found_parent) {
|
||||
error(
|
||||
"shared extent[%llu %u] lost its parent (parent: %llu, level: %u)",
|
||||
bytenr, nodesize, parent, level);
|
||||
bytenr, fs_info->nodesize, parent, level);
|
||||
return REFERENCER_MISSING;
|
||||
}
|
||||
return 0;
|
||||
@ -10751,12 +10744,11 @@ static int check_shared_data_backref(struct btrfs_fs_info *fs_info,
|
||||
struct extent_buffer *eb;
|
||||
struct btrfs_key key;
|
||||
struct btrfs_file_extent_item *fi;
|
||||
u32 nodesize = btrfs_super_nodesize(fs_info->super_copy);
|
||||
u32 nr;
|
||||
int found_parent = 0;
|
||||
int i;
|
||||
|
||||
eb = read_tree_block(fs_info, parent, nodesize, 0);
|
||||
eb = read_tree_block(fs_info, parent, fs_info->nodesize, 0);
|
||||
if (!extent_buffer_uptodate(eb))
|
||||
goto out;
|
||||
|
||||
@ -11667,7 +11659,6 @@ static int pin_down_tree_blocks(struct btrfs_fs_info *fs_info,
|
||||
struct btrfs_root_item *ri;
|
||||
struct btrfs_key key;
|
||||
u64 bytenr;
|
||||
u32 nodesize;
|
||||
int level = btrfs_header_level(eb);
|
||||
int nritems;
|
||||
int ret;
|
||||
@ -11684,7 +11675,6 @@ static int pin_down_tree_blocks(struct btrfs_fs_info *fs_info,
|
||||
|
||||
btrfs_pin_extent(fs_info, eb->start, eb->len);
|
||||
|
||||
nodesize = btrfs_super_nodesize(fs_info->super_copy);
|
||||
nritems = btrfs_header_nritems(eb);
|
||||
for (i = 0; i < nritems; i++) {
|
||||
if (level == 0) {
|
||||
@ -11705,7 +11695,7 @@ static int pin_down_tree_blocks(struct btrfs_fs_info *fs_info,
|
||||
* in, but for now this doesn't actually use the root so
|
||||
* just pass in extent_root.
|
||||
*/
|
||||
tmp = read_tree_block(fs_info, bytenr, nodesize, 0);
|
||||
tmp = read_tree_block(fs_info, bytenr, fs_info->nodesize, 0);
|
||||
if (!extent_buffer_uptodate(tmp)) {
|
||||
fprintf(stderr, "Error reading root block\n");
|
||||
return -EIO;
|
||||
@ -11719,12 +11709,13 @@ 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, nodesize);
|
||||
btrfs_pin_extent(fs_info, bytenr,
|
||||
fs_info->nodesize);
|
||||
continue;
|
||||
}
|
||||
|
||||
tmp = read_tree_block(fs_info, bytenr,
|
||||
nodesize, 0);
|
||||
fs_info->nodesize, 0);
|
||||
if (!extent_buffer_uptodate(tmp)) {
|
||||
fprintf(stderr, "Error reading tree block\n");
|
||||
return -EIO;
|
||||
|
@ -38,7 +38,6 @@ static void print_extents(struct btrfs_root *root, struct extent_buffer *eb)
|
||||
struct extent_buffer *next;
|
||||
int i;
|
||||
u32 nr;
|
||||
u32 size;
|
||||
|
||||
if (!eb)
|
||||
return;
|
||||
@ -48,12 +47,11 @@ static void print_extents(struct btrfs_root *root, struct extent_buffer *eb)
|
||||
return;
|
||||
}
|
||||
|
||||
size = root->fs_info->nodesize;
|
||||
nr = btrfs_header_nritems(eb);
|
||||
for (i = 0; i < nr; i++) {
|
||||
next = read_tree_block(root->fs_info,
|
||||
btrfs_node_blockptr(eb, i),
|
||||
size, btrfs_node_ptr_generation(eb, i));
|
||||
root->fs_info->nodesize, btrfs_node_ptr_generation(eb, i));
|
||||
if (!extent_buffer_uptodate(next))
|
||||
continue;
|
||||
if (btrfs_is_leaf(next) && btrfs_header_level(eb) != 1) {
|
||||
|
8
ctree.c
8
ctree.c
@ -979,7 +979,6 @@ void reada_for_search(struct btrfs_root *root, struct btrfs_path *path,
|
||||
int direction = path->reada;
|
||||
struct extent_buffer *eb;
|
||||
u32 nr;
|
||||
u32 blocksize;
|
||||
u32 nscan = 0;
|
||||
|
||||
if (level != 1)
|
||||
@ -990,8 +989,7 @@ void reada_for_search(struct btrfs_root *root, struct btrfs_path *path,
|
||||
|
||||
node = path->nodes[level];
|
||||
search = btrfs_node_blockptr(node, slot);
|
||||
blocksize = fs_info->nodesize;
|
||||
eb = btrfs_find_tree_block(fs_info, search, blocksize);
|
||||
eb = btrfs_find_tree_block(fs_info, search, fs_info->nodesize);
|
||||
if (eb) {
|
||||
free_extent_buffer(eb);
|
||||
return;
|
||||
@ -1021,9 +1019,9 @@ void reada_for_search(struct btrfs_root *root, struct btrfs_path *path,
|
||||
if ((search >= lowest_read && search <= highest_read) ||
|
||||
(search < lowest_read && lowest_read - search <= 32768) ||
|
||||
(search > highest_read && search - highest_read <= 32768)) {
|
||||
readahead_tree_block(fs_info, search, blocksize,
|
||||
readahead_tree_block(fs_info, search, fs_info->nodesize,
|
||||
btrfs_node_ptr_generation(node, nr));
|
||||
nread += blocksize;
|
||||
nread += fs_info->nodesize;
|
||||
}
|
||||
nscan++;
|
||||
if (path->reada < 2 && (nread > SZ_256K || nscan > 32))
|
||||
|
17
disk-io.c
17
disk-io.c
@ -615,7 +615,6 @@ static int find_and_setup_root(struct btrfs_root *tree_root,
|
||||
u64 objectid, struct btrfs_root *root)
|
||||
{
|
||||
int ret;
|
||||
u32 blocksize;
|
||||
u64 generation;
|
||||
|
||||
btrfs_setup_root(root, fs_info, objectid);
|
||||
@ -624,11 +623,10 @@ static int find_and_setup_root(struct btrfs_root *tree_root,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
blocksize = fs_info->nodesize;
|
||||
generation = btrfs_root_generation(&root->root_item);
|
||||
root->node = read_tree_block(fs_info,
|
||||
btrfs_root_bytenr(&root->root_item),
|
||||
blocksize, generation);
|
||||
fs_info->nodesize, generation);
|
||||
if (!extent_buffer_uptodate(root->node))
|
||||
return -EIO;
|
||||
|
||||
@ -639,7 +637,6 @@ static int find_and_setup_log_root(struct btrfs_root *tree_root,
|
||||
struct btrfs_fs_info *fs_info,
|
||||
struct btrfs_super_block *disk_super)
|
||||
{
|
||||
u32 blocksize;
|
||||
u64 blocknr = btrfs_super_log_root(disk_super);
|
||||
struct btrfs_root *log_root = malloc(sizeof(struct btrfs_root));
|
||||
|
||||
@ -651,13 +648,11 @@ static int find_and_setup_log_root(struct btrfs_root *tree_root,
|
||||
return 0;
|
||||
}
|
||||
|
||||
blocksize = fs_info->nodesize;
|
||||
|
||||
btrfs_setup_root(log_root, fs_info,
|
||||
BTRFS_TREE_LOG_OBJECTID);
|
||||
|
||||
log_root->node = read_tree_block(fs_info, blocknr,
|
||||
blocksize,
|
||||
fs_info->nodesize,
|
||||
btrfs_super_generation(disk_super) + 1);
|
||||
|
||||
fs_info->log_root_tree = log_root;
|
||||
@ -700,7 +695,6 @@ struct btrfs_root *btrfs_read_fs_root_no_cache(struct btrfs_fs_info *fs_info,
|
||||
struct btrfs_path *path;
|
||||
struct extent_buffer *l;
|
||||
u64 generation;
|
||||
u32 blocksize;
|
||||
int ret = 0;
|
||||
|
||||
root = calloc(1, sizeof(*root));
|
||||
@ -744,10 +738,9 @@ out:
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
generation = btrfs_root_generation(&root->root_item);
|
||||
blocksize = fs_info->nodesize;
|
||||
root->node = read_tree_block(fs_info,
|
||||
btrfs_root_bytenr(&root->root_item),
|
||||
blocksize, generation);
|
||||
fs_info->nodesize, generation);
|
||||
if (!extent_buffer_uptodate(root->node)) {
|
||||
free(root);
|
||||
return ERR_PTR(-EIO);
|
||||
@ -984,12 +977,10 @@ int btrfs_setup_all_roots(struct btrfs_fs_info *fs_info, u64 root_tree_bytenr,
|
||||
struct btrfs_root *root;
|
||||
struct btrfs_key key;
|
||||
u64 generation;
|
||||
u32 blocksize;
|
||||
int ret;
|
||||
|
||||
root = fs_info->tree_root;
|
||||
btrfs_setup_root(root, fs_info, BTRFS_ROOT_TREE_OBJECTID);
|
||||
blocksize = fs_info->nodesize;
|
||||
generation = btrfs_super_generation(sb);
|
||||
|
||||
if (!root_tree_bytenr && !(flags & OPEN_CTREE_BACKUP_ROOT)) {
|
||||
@ -1006,7 +997,7 @@ int btrfs_setup_all_roots(struct btrfs_fs_info *fs_info, u64 root_tree_bytenr,
|
||||
generation = btrfs_backup_tree_root_gen(backup);
|
||||
}
|
||||
|
||||
root->node = read_tree_block(fs_info, root_tree_bytenr, blocksize,
|
||||
root->node = read_tree_block(fs_info, root_tree_bytenr, fs_info->nodesize,
|
||||
generation);
|
||||
if (!extent_buffer_uptodate(root->node)) {
|
||||
fprintf(stderr, "Couldn't read tree root\n");
|
||||
|
@ -919,7 +919,6 @@ static int flush_pending(struct metadump_struct *md, int done)
|
||||
{
|
||||
struct async_work *async = NULL;
|
||||
struct extent_buffer *eb;
|
||||
u64 blocksize = md->root->fs_info->nodesize;
|
||||
u64 start = 0;
|
||||
u64 size;
|
||||
size_t offset;
|
||||
@ -972,7 +971,9 @@ static int flush_pending(struct metadump_struct *md, int done)
|
||||
}
|
||||
|
||||
while (!md->data && size > 0) {
|
||||
u64 this_read = min(blocksize, size);
|
||||
u64 this_read = min((u64)md->root->fs_info->nodesize,
|
||||
size);
|
||||
|
||||
eb = read_tree_block(md->root->fs_info, start,
|
||||
this_read, 0);
|
||||
if (!extent_buffer_uptodate(eb)) {
|
||||
|
@ -1277,7 +1277,6 @@ void btrfs_print_tree(struct btrfs_root *root, struct extent_buffer *eb, int fol
|
||||
{
|
||||
u32 i;
|
||||
u32 nr;
|
||||
u32 size;
|
||||
struct btrfs_disk_key disk_key;
|
||||
struct btrfs_key key;
|
||||
struct extent_buffer *next;
|
||||
@ -1297,7 +1296,6 @@ void btrfs_print_tree(struct btrfs_root *root, struct extent_buffer *eb, int fol
|
||||
(unsigned long long)btrfs_header_owner(eb));
|
||||
print_uuids(eb);
|
||||
fflush(stdout);
|
||||
size = root->fs_info->nodesize;
|
||||
for (i = 0; i < nr; i++) {
|
||||
u64 blocknr = btrfs_node_blockptr(eb, i);
|
||||
btrfs_node_key(eb, &disk_key, i);
|
||||
@ -1306,7 +1304,7 @@ void btrfs_print_tree(struct btrfs_root *root, struct extent_buffer *eb, int fol
|
||||
btrfs_print_key(&disk_key);
|
||||
printf(" block %llu (%llu) gen %llu\n",
|
||||
(unsigned long long)blocknr,
|
||||
(unsigned long long)blocknr / size,
|
||||
(unsigned long long)blocknr / root->fs_info->nodesize,
|
||||
(unsigned long long)btrfs_node_ptr_generation(eb, i));
|
||||
fflush(stdout);
|
||||
}
|
||||
@ -1315,7 +1313,7 @@ void btrfs_print_tree(struct btrfs_root *root, struct extent_buffer *eb, int fol
|
||||
|
||||
for (i = 0; i < nr; i++) {
|
||||
next = read_tree_block(root->fs_info,
|
||||
btrfs_node_blockptr(eb, i), size,
|
||||
btrfs_node_blockptr(eb, i), root->fs_info->nodesize,
|
||||
btrfs_node_ptr_generation(eb, i));
|
||||
if (!extent_buffer_uptodate(next)) {
|
||||
fprintf(stderr, "failed to read %llu in tree %llu\n",
|
||||
|
Loading…
Reference in New Issue
Block a user