diff options
Diffstat (limited to 'cmds-restore.c')
-rw-r--r-- | cmds-restore.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/cmds-restore.c b/cmds-restore.c index bdd35bd7..c174bdd5 100644 --- a/cmds-restore.c +++ b/cmds-restore.c @@ -42,6 +42,7 @@ #include "volumes.h" #include "utils.h" #include "commands.h" +#include "help.h" static char fs_name[PATH_MAX]; static char path_name[PATH_MAX]; @@ -125,7 +126,7 @@ static int decompress_lzo(struct btrfs_root *root, unsigned char *inbuf, inbuf += LZO_LEN; tot_in += LZO_LEN; - new_len = lzo1x_worst_compress(root->sectorsize); + new_len = lzo1x_worst_compress(root->fs_info->sectorsize); ret = lzo1x_decompress_safe((const unsigned char *)inbuf, in_len, (unsigned char *)outbuf, (void *)&new_len, NULL); @@ -142,8 +143,8 @@ static int decompress_lzo(struct btrfs_root *root, unsigned char *inbuf, * If the 4 byte header does not fit to the rest of the page we * have to move to the next one, unless we read some garbage */ - mod_page = tot_in % root->sectorsize; - rem_page = root->sectorsize - mod_page; + mod_page = tot_in % root->fs_info->sectorsize; + rem_page = root->fs_info->sectorsize - mod_page; if (rem_page < LZO_LEN) { inbuf += rem_page; tot_in += rem_page; @@ -180,6 +181,7 @@ static int next_leaf(struct btrfs_root *root, struct btrfs_path *path) int offset = 1; struct extent_buffer *c; struct extent_buffer *next = NULL; + struct btrfs_fs_info *fs_info = root->fs_info; again: for (; level < BTRFS_MAX_LEVEL; level++) { @@ -209,7 +211,7 @@ again: if (path->reada) reada_for_search(root, path, level, slot, 0); - next = read_node_slot(root, c, slot); + next = read_node_slot(fs_info, c, slot); if (extent_buffer_uptodate(next)) break; offset++; @@ -225,7 +227,7 @@ again: break; if (path->reada) reada_for_search(root, path, level, 0, 0); - next = read_node_slot(root, next, 0); + next = read_node_slot(fs_info, next, 0); if (!extent_buffer_uptodate(next)) goto again; } @@ -344,8 +346,8 @@ static int copy_one_extent(struct btrfs_root *root, int fd, } again: length = size_left; - ret = btrfs_map_block(&root->fs_info->mapping_tree, READ, - bytenr, &length, &multi, mirror_num, NULL); + ret = btrfs_map_block(root->fs_info, READ, bytenr, &length, &multi, + mirror_num, NULL); if (ret) { error("cannot map block logical %llu length %llu: %d", (unsigned long long)bytenr, @@ -364,8 +366,7 @@ again: done = pread(dev_fd, inbuf+count, length, dev_bytenr); /* Need both checks, or we miss negative values due to u64 conversion */ if (done < 0 || done < length) { - num_copies = btrfs_num_copies(&root->fs_info->mapping_tree, - bytenr, length); + num_copies = btrfs_num_copies(root->fs_info, bytenr, length); mirror_num++; /* mirror_num is 1-indexed, so num_copies is a valid mirror. */ if (mirror_num > num_copies) { @@ -402,8 +403,7 @@ again: ret = decompress(root, inbuf, outbuf, disk_size, &ram_size, compress); if (ret) { - num_copies = btrfs_num_copies(&root->fs_info->mapping_tree, - bytenr, length); + num_copies = btrfs_num_copies(root->fs_info, bytenr, length); mirror_num++; if (mirror_num >= num_copies) { ret = -1; @@ -1254,8 +1254,8 @@ static struct btrfs_root *open_fs(const char *dev, u64 root_location, if (!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->nodesize, generation); + root->node = read_tree_block(fs_info, root_location, + fs_info->nodesize, generation); if (!extent_buffer_uptodate(root->node)) { fprintf(stderr, "Error opening tree root\n"); close_ctree(root); @@ -1501,7 +1501,8 @@ 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->nodesize, 0); + root->node = read_tree_block(root->fs_info, fs_location, + root->fs_info->nodesize, 0); if (!extent_buffer_uptodate(root->node)) { fprintf(stderr, "Failed to read fs location\n"); ret = 1; |