This is required for the device replace procedure in a later step.
Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
                }
 
                num_copies =
-                   btrfs_num_copies(&state->root->fs_info->mapping_tree,
+                   btrfs_num_copies(state->root->fs_info,
                                     next_bytenr, state->metablock_size);
                if (state->print_mask & BTRFSIC_PRINT_MASK_NUM_COPIES)
                        printk(KERN_INFO "num_copies(log_bytenr=%llu) = %d\n",
                }
 
                num_copies =
-                   btrfs_num_copies(&state->root->fs_info->mapping_tree,
+                   btrfs_num_copies(state->root->fs_info,
                                     next_bytenr, state->metablock_size);
                if (state->print_mask & BTRFSIC_PRINT_MASK_NUM_COPIES)
                        printk(KERN_INFO "num_copies(log_bytenr=%llu) = %d\n",
        *next_blockp = NULL;
        if (0 == *num_copiesp) {
                *num_copiesp =
-                   btrfs_num_copies(&state->root->fs_info->mapping_tree,
+                   btrfs_num_copies(state->root->fs_info,
                                     next_bytenr, state->metablock_size);
                if (state->print_mask & BTRFSIC_PRINT_MASK_NUM_COPIES)
                        printk(KERN_INFO "num_copies(log_bytenr=%llu) = %d\n",
                        chunk_len = num_bytes;
 
                num_copies =
-                   btrfs_num_copies(&state->root->fs_info->mapping_tree,
+                   btrfs_num_copies(state->root->fs_info,
                                     next_bytenr, state->datablock_size);
                if (state->print_mask & BTRFSIC_PRINT_MASK_NUM_COPIES)
                        printk(KERN_INFO "num_copies(log_bytenr=%llu) = %d\n",
                }
 
                num_copies =
-                   btrfs_num_copies(&state->root->fs_info->mapping_tree,
+                   btrfs_num_copies(state->root->fs_info,
                                     next_bytenr, BTRFS_SUPER_INFO_SIZE);
                if (state->print_mask & BTRFSIC_PRINT_MASK_NUM_COPIES)
                        printk(KERN_INFO "num_copies(log_bytenr=%llu) = %d\n",
        struct btrfsic_block_data_ctx block_ctx;
        int match = 0;
 
-       num_copies = btrfs_num_copies(&state->root->fs_info->mapping_tree,
+       num_copies = btrfs_num_copies(state->root->fs_info,
                                      bytenr, state->metablock_size);
 
        for (mirror_num = 1; mirror_num <= num_copies; mirror_num++) {
 
                if (test_bit(EXTENT_BUFFER_CORRUPT, &eb->bflags))
                        break;
 
-               num_copies = btrfs_num_copies(&root->fs_info->mapping_tree,
+               num_copies = btrfs_num_copies(root->fs_info,
                                              eb->start, eb->len);
                if (num_copies == 1)
                        break;
 
        spin_unlock(&BTRFS_I(inode)->io_tree.lock);
 
        if (state && state->start == failrec->start) {
-               map_tree = &BTRFS_I(inode)->root->fs_info->mapping_tree;
-               num_copies = btrfs_num_copies(map_tree, failrec->logical,
-                                               failrec->len);
+               num_copies = btrfs_num_copies(BTRFS_I(inode)->root->fs_info,
+                                             failrec->logical, failrec->len);
                if (num_copies > 1)  {
+                       map_tree = &BTRFS_I(inode)->root->fs_info->mapping_tree;
                        ret = repair_io_failure(map_tree, start, failrec->len,
                                                failrec->logical, page,
                                                failrec->failed_mirror);
                 * clean_io_failure() clean all those errors at once.
                 */
        }
-       num_copies = btrfs_num_copies(
-                             &BTRFS_I(inode)->root->fs_info->mapping_tree,
-                             failrec->logical, failrec->len);
+       num_copies = btrfs_num_copies(BTRFS_I(inode)->root->fs_info,
+                                     failrec->logical, failrec->len);
        if (num_copies == 1) {
                /*
                 * we only have a single copy of the data, so don't bother with
 
        }
 }
 
-int btrfs_num_copies(struct btrfs_mapping_tree *map_tree, u64 logical, u64 len)
+int btrfs_num_copies(struct btrfs_fs_info *fs_info, u64 logical, u64 len)
 {
+       struct btrfs_mapping_tree *map_tree = &fs_info->mapping_tree;
        struct extent_map *em;
        struct map_lookup *map;
        struct extent_map_tree *em_tree = &map_tree->map_tree;
 
                     struct btrfs_device *device);
 int btrfs_rm_device(struct btrfs_root *root, char *device_path);
 void btrfs_cleanup_fs_uuids(void);
-int btrfs_num_copies(struct btrfs_mapping_tree *map_tree, u64 logical, u64 len);
+int btrfs_num_copies(struct btrfs_fs_info *fs_info, u64 logical, u64 len);
 int btrfs_grow_device(struct btrfs_trans_handle *trans,
                      struct btrfs_device *device, u64 new_size);
 struct btrfs_device *btrfs_find_device(struct btrfs_root *root, u64 devid,