}
static void corrupt_keys(struct btrfs_trans_handle *trans,
- struct btrfs_root *root,
+ struct btrfs_fs_info *fs_info,
struct extent_buffer *eb)
{
int slot;
btrfs_mark_buffer_dirty(eb);
if (!trans) {
u16 csum_size =
- btrfs_super_csum_size(root->fs_info->super_copy);
+ btrfs_super_csum_size(fs_info->super_copy);
csum_tree_block_size(eb, csum_size, 0);
write_extent_to_disk(eb);
}
}
-static int corrupt_keys_in_block(struct btrfs_root *root, u64 bytenr)
+static int corrupt_keys_in_block(struct btrfs_fs_info *fs_info, u64 bytenr)
{
struct extent_buffer *eb;
- eb = read_tree_block(root, bytenr, root->fs_info->nodesize, 0);
+ eb = read_tree_block_fs_info(fs_info, bytenr, fs_info->nodesize, 0);
if (!extent_buffer_uptodate(eb))
return -EIO;;
- corrupt_keys(NULL, root, eb);
+ corrupt_keys(NULL, fs_info, eb);
free_extent_buffer(eb);
return 0;
}
}
}
-static int corrupt_metadata_block(struct btrfs_root *root, u64 block,
+static int corrupt_metadata_block(struct btrfs_fs_info *fs_info, u64 block,
char *field)
{
struct btrfs_trans_handle *trans;
+ struct btrfs_root *root;
struct btrfs_path *path;
struct extent_buffer *eb;
struct btrfs_key key, root_key;
return -EINVAL;
}
- eb = read_tree_block(root, block, root->fs_info->nodesize, 0);
+ eb = read_tree_block_fs_info(fs_info, block, fs_info->nodesize, 0);
if (!extent_buffer_uptodate(eb)) {
fprintf(stderr, "Couldn't read in tree block %s\n", field);
return -EINVAL;
root_key.type = BTRFS_ROOT_ITEM_KEY;
root_key.offset = (u64)-1;
- root = btrfs_read_fs_root(root->fs_info, &root_key);
+ root = btrfs_read_fs_root(fs_info, &root_key);
if (IS_ERR(root)) {
fprintf(stderr, "Couldn't find owner root %llu\n",
key.objectid);
if (metadata_block) {
if (*field == 0)
print_usage(1);
- ret = corrupt_metadata_block(root, metadata_block, field);
+ ret = corrupt_metadata_block(root->fs_info, metadata_block,
+ field);
goto out_close;
}
if (corrupt_di) {
while (bytes > 0) {
if (corrupt_block_keys) {
- corrupt_keys_in_block(root, logical);
+ corrupt_keys_in_block(root->fs_info, logical);
} else {
struct extent_buffer *eb;