btrfs-progs: Use @fs_info to replace @root for btrfs_check_leaf/node()
Signed-off-by: Qu Wenruo <wqu@suse.com>
This commit is contained in:
parent
83aeb251f7
commit
db51d8d8f6
12
check/main.c
12
check/main.c
|
@ -1790,9 +1790,9 @@ static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (btrfs_is_leaf(next))
|
if (btrfs_is_leaf(next))
|
||||||
status = btrfs_check_leaf(root, NULL, next);
|
status = btrfs_check_leaf(fs_info, NULL, next);
|
||||||
else
|
else
|
||||||
status = btrfs_check_node(root, NULL, next);
|
status = btrfs_check_node(fs_info, NULL, next);
|
||||||
if (status != BTRFS_TREE_BLOCK_CLEAN) {
|
if (status != BTRFS_TREE_BLOCK_CLEAN) {
|
||||||
free_extent_buffer(next);
|
free_extent_buffer(next);
|
||||||
err = -EIO;
|
err = -EIO;
|
||||||
|
@ -3464,9 +3464,9 @@ static int check_fs_root(struct btrfs_root *root,
|
||||||
|
|
||||||
/* We may not have checked the root block, lets do that now */
|
/* We may not have checked the root block, lets do that now */
|
||||||
if (btrfs_is_leaf(root->node))
|
if (btrfs_is_leaf(root->node))
|
||||||
status = btrfs_check_leaf(root, NULL, root->node);
|
status = btrfs_check_leaf(root->fs_info, NULL, root->node);
|
||||||
else
|
else
|
||||||
status = btrfs_check_node(root, NULL, root->node);
|
status = btrfs_check_node(root->fs_info, NULL, root->node);
|
||||||
if (status != BTRFS_TREE_BLOCK_CLEAN)
|
if (status != BTRFS_TREE_BLOCK_CLEAN)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
|
@ -4304,9 +4304,9 @@ static int check_block(struct btrfs_root *root,
|
||||||
rec->info_level = level;
|
rec->info_level = level;
|
||||||
|
|
||||||
if (btrfs_is_leaf(buf))
|
if (btrfs_is_leaf(buf))
|
||||||
status = btrfs_check_leaf(root, &rec->parent_key, buf);
|
status = btrfs_check_leaf(root->fs_info, &rec->parent_key, buf);
|
||||||
else
|
else
|
||||||
status = btrfs_check_node(root, &rec->parent_key, buf);
|
status = btrfs_check_node(root->fs_info, &rec->parent_key, buf);
|
||||||
|
|
||||||
if (status != BTRFS_TREE_BLOCK_CLEAN) {
|
if (status != BTRFS_TREE_BLOCK_CLEAN) {
|
||||||
if (repair)
|
if (repair)
|
||||||
|
|
|
@ -4674,7 +4674,7 @@ static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path,
|
||||||
if (*level == 0) {
|
if (*level == 0) {
|
||||||
/* skip duplicate check */
|
/* skip duplicate check */
|
||||||
if (check || !check_all) {
|
if (check || !check_all) {
|
||||||
ret = btrfs_check_leaf(root, NULL, cur);
|
ret = btrfs_check_leaf(fs_info, NULL, cur);
|
||||||
if (ret != BTRFS_TREE_BLOCK_CLEAN) {
|
if (ret != BTRFS_TREE_BLOCK_CLEAN) {
|
||||||
err |= -EIO;
|
err |= -EIO;
|
||||||
break;
|
break;
|
||||||
|
@ -4691,7 +4691,7 @@ static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (check || !check_all) {
|
if (check || !check_all) {
|
||||||
ret = btrfs_check_node(root, NULL, cur);
|
ret = btrfs_check_node(fs_info, NULL, cur);
|
||||||
if (ret != BTRFS_TREE_BLOCK_CLEAN) {
|
if (ret != BTRFS_TREE_BLOCK_CLEAN) {
|
||||||
err |= -EIO;
|
err |= -EIO;
|
||||||
break;
|
break;
|
||||||
|
@ -4739,9 +4739,9 @@ static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (btrfs_is_leaf(next))
|
if (btrfs_is_leaf(next))
|
||||||
status = btrfs_check_leaf(root, NULL, next);
|
status = btrfs_check_leaf(fs_info, NULL, next);
|
||||||
else
|
else
|
||||||
status = btrfs_check_node(root, NULL, next);
|
status = btrfs_check_node(fs_info, NULL, next);
|
||||||
if (status != BTRFS_TREE_BLOCK_CLEAN) {
|
if (status != BTRFS_TREE_BLOCK_CLEAN) {
|
||||||
free_extent_buffer(next);
|
free_extent_buffer(next);
|
||||||
err |= -EIO;
|
err |= -EIO;
|
||||||
|
|
32
ctree.c
32
ctree.c
|
@ -434,8 +434,8 @@ static inline unsigned int leaf_data_end(const struct btrfs_fs_info *fs_info,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum btrfs_tree_block_status
|
enum btrfs_tree_block_status
|
||||||
btrfs_check_node(struct btrfs_root *root, struct btrfs_disk_key *parent_key,
|
btrfs_check_node(struct btrfs_fs_info *fs_info,
|
||||||
struct extent_buffer *buf)
|
struct btrfs_disk_key *parent_key, struct extent_buffer *buf)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct btrfs_key cpukey;
|
struct btrfs_key cpukey;
|
||||||
|
@ -443,7 +443,7 @@ btrfs_check_node(struct btrfs_root *root, struct btrfs_disk_key *parent_key,
|
||||||
u32 nritems = btrfs_header_nritems(buf);
|
u32 nritems = btrfs_header_nritems(buf);
|
||||||
enum btrfs_tree_block_status ret = BTRFS_TREE_BLOCK_INVALID_NRITEMS;
|
enum btrfs_tree_block_status ret = BTRFS_TREE_BLOCK_INVALID_NRITEMS;
|
||||||
|
|
||||||
if (nritems == 0 || nritems > BTRFS_NODEPTRS_PER_BLOCK(root->fs_info))
|
if (nritems == 0 || nritems > BTRFS_NODEPTRS_PER_BLOCK(fs_info))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
ret = BTRFS_TREE_BLOCK_INVALID_PARENT_KEY;
|
ret = BTRFS_TREE_BLOCK_INVALID_PARENT_KEY;
|
||||||
|
@ -466,7 +466,7 @@ fail:
|
||||||
btrfs_disk_key_to_cpu(&cpukey, parent_key);
|
btrfs_disk_key_to_cpu(&cpukey, parent_key);
|
||||||
else
|
else
|
||||||
btrfs_node_key_to_cpu(buf, &cpukey, 0);
|
btrfs_node_key_to_cpu(buf, &cpukey, 0);
|
||||||
btrfs_add_corrupt_extent_record(root->fs_info, &cpukey,
|
btrfs_add_corrupt_extent_record(fs_info, &cpukey,
|
||||||
buf->start, buf->len,
|
buf->start, buf->len,
|
||||||
btrfs_header_level(buf));
|
btrfs_header_level(buf));
|
||||||
}
|
}
|
||||||
|
@ -474,8 +474,8 @@ fail:
|
||||||
}
|
}
|
||||||
|
|
||||||
enum btrfs_tree_block_status
|
enum btrfs_tree_block_status
|
||||||
btrfs_check_leaf(struct btrfs_root *root, struct btrfs_disk_key *parent_key,
|
btrfs_check_leaf(struct btrfs_fs_info *fs_info,
|
||||||
struct extent_buffer *buf)
|
struct btrfs_disk_key *parent_key, struct extent_buffer *buf)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct btrfs_key cpukey;
|
struct btrfs_key cpukey;
|
||||||
|
@ -531,18 +531,18 @@ btrfs_check_leaf(struct btrfs_root *root, struct btrfs_disk_key *parent_key,
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
if (i == 0 && btrfs_item_end_nr(buf, i) !=
|
if (i == 0 && btrfs_item_end_nr(buf, i) !=
|
||||||
BTRFS_LEAF_DATA_SIZE(root->fs_info)) {
|
BTRFS_LEAF_DATA_SIZE(fs_info)) {
|
||||||
ret = BTRFS_TREE_BLOCK_INVALID_OFFSETS;
|
ret = BTRFS_TREE_BLOCK_INVALID_OFFSETS;
|
||||||
fprintf(stderr, "bad item end %u wanted %u\n",
|
fprintf(stderr, "bad item end %u wanted %u\n",
|
||||||
btrfs_item_end_nr(buf, i),
|
btrfs_item_end_nr(buf, i),
|
||||||
(unsigned)BTRFS_LEAF_DATA_SIZE(root->fs_info));
|
(unsigned)BTRFS_LEAF_DATA_SIZE(fs_info));
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < nritems; i++) {
|
for (i = 0; i < nritems; i++) {
|
||||||
if (btrfs_item_end_nr(buf, i) >
|
if (btrfs_item_end_nr(buf, i) >
|
||||||
BTRFS_LEAF_DATA_SIZE(root->fs_info)) {
|
BTRFS_LEAF_DATA_SIZE(fs_info)) {
|
||||||
btrfs_item_key(buf, &key, 0);
|
btrfs_item_key(buf, &key, 0);
|
||||||
btrfs_print_key(&key);
|
btrfs_print_key(&key);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
@ -550,7 +550,7 @@ btrfs_check_leaf(struct btrfs_root *root, struct btrfs_disk_key *parent_key,
|
||||||
fprintf(stderr, "slot end outside of leaf %llu > %llu\n",
|
fprintf(stderr, "slot end outside of leaf %llu > %llu\n",
|
||||||
(unsigned long long)btrfs_item_end_nr(buf, i),
|
(unsigned long long)btrfs_item_end_nr(buf, i),
|
||||||
(unsigned long long)BTRFS_LEAF_DATA_SIZE(
|
(unsigned long long)BTRFS_LEAF_DATA_SIZE(
|
||||||
root->fs_info));
|
fs_info));
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -563,13 +563,13 @@ fail:
|
||||||
else
|
else
|
||||||
btrfs_item_key_to_cpu(buf, &cpukey, 0);
|
btrfs_item_key_to_cpu(buf, &cpukey, 0);
|
||||||
|
|
||||||
btrfs_add_corrupt_extent_record(root->fs_info, &cpukey,
|
btrfs_add_corrupt_extent_record(fs_info, &cpukey,
|
||||||
buf->start, buf->len, 0);
|
buf->start, buf->len, 0);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int noinline check_block(struct btrfs_root *root,
|
static int noinline check_block(struct btrfs_fs_info *fs_info,
|
||||||
struct btrfs_path *path, int level)
|
struct btrfs_path *path, int level)
|
||||||
{
|
{
|
||||||
struct btrfs_disk_key key;
|
struct btrfs_disk_key key;
|
||||||
|
@ -585,9 +585,9 @@ static int noinline check_block(struct btrfs_root *root,
|
||||||
key_ptr = &key;
|
key_ptr = &key;
|
||||||
}
|
}
|
||||||
if (level == 0)
|
if (level == 0)
|
||||||
ret = btrfs_check_leaf(root, key_ptr, path->nodes[0]);
|
ret = btrfs_check_leaf(fs_info, key_ptr, path->nodes[0]);
|
||||||
else
|
else
|
||||||
ret = btrfs_check_node(root, key_ptr, path->nodes[level]);
|
ret = btrfs_check_node(fs_info, key_ptr, path->nodes[level]);
|
||||||
if (ret == BTRFS_TREE_BLOCK_CLEAN)
|
if (ret == BTRFS_TREE_BLOCK_CLEAN)
|
||||||
return 0;
|
return 0;
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
@ -871,7 +871,7 @@ static int balance_level(struct btrfs_trans_handle *trans,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* double check we haven't messed things up */
|
/* double check we haven't messed things up */
|
||||||
check_block(root, path, level);
|
check_block(root->fs_info, path, level);
|
||||||
if (orig_ptr !=
|
if (orig_ptr !=
|
||||||
btrfs_node_blockptr(path->nodes[level], path->slots[level]))
|
btrfs_node_blockptr(path->nodes[level], path->slots[level]))
|
||||||
BUG();
|
BUG();
|
||||||
|
@ -1169,7 +1169,7 @@ again:
|
||||||
WARN_ON(1);
|
WARN_ON(1);
|
||||||
level = btrfs_header_level(b);
|
level = btrfs_header_level(b);
|
||||||
p->nodes[level] = b;
|
p->nodes[level] = b;
|
||||||
ret = check_block(root, p, level);
|
ret = check_block(fs_info, p, level);
|
||||||
if (ret)
|
if (ret)
|
||||||
return -1;
|
return -1;
|
||||||
ret = bin_search(b, key, level, &slot);
|
ret = bin_search(b, key, level, &slot);
|
||||||
|
|
8
ctree.h
8
ctree.h
|
@ -2562,11 +2562,11 @@ int btrfs_comp_cpu_keys(const struct btrfs_key *k1, const struct btrfs_key *k2);
|
||||||
int btrfs_del_ptr(struct btrfs_root *root, struct btrfs_path *path,
|
int btrfs_del_ptr(struct btrfs_root *root, struct btrfs_path *path,
|
||||||
int level, int slot);
|
int level, int slot);
|
||||||
enum btrfs_tree_block_status
|
enum btrfs_tree_block_status
|
||||||
btrfs_check_node(struct btrfs_root *root, struct btrfs_disk_key *parent_key,
|
btrfs_check_node(struct btrfs_fs_info *fs_info,
|
||||||
struct extent_buffer *buf);
|
struct btrfs_disk_key *parent_key, struct extent_buffer *buf);
|
||||||
enum btrfs_tree_block_status
|
enum btrfs_tree_block_status
|
||||||
btrfs_check_leaf(struct btrfs_root *root, struct btrfs_disk_key *parent_key,
|
btrfs_check_leaf(struct btrfs_fs_info *fs_info,
|
||||||
struct extent_buffer *buf);
|
struct btrfs_disk_key *parent_key, struct extent_buffer *buf);
|
||||||
void reada_for_search(struct btrfs_fs_info *fs_info, struct btrfs_path *path,
|
void reada_for_search(struct btrfs_fs_info *fs_info, struct btrfs_path *path,
|
||||||
int level, int slot, u64 objectid);
|
int level, int slot, u64 objectid);
|
||||||
struct extent_buffer *read_node_slot(struct btrfs_fs_info *fs_info,
|
struct extent_buffer *read_node_slot(struct btrfs_fs_info *fs_info,
|
||||||
|
|
Loading…
Reference in New Issue