Btrfs: Pass fs_info to btrfs_num_copies() instead of mapping_tree
authorStefan Behrens <sbehrens@giantdisaster.de>
Mon, 5 Nov 2012 13:59:07 +0000 (14:59 +0100)
committerJosef Bacik <jbacik@fusionio.com>
Wed, 12 Dec 2012 22:15:34 +0000 (17:15 -0500)
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>
fs/btrfs/check-integrity.c
fs/btrfs/disk-io.c
fs/btrfs/extent_io.c
fs/btrfs/volumes.c
fs/btrfs/volumes.h

index 5a3e45db642a6b1c64998ba523be143d382d396e..58dfac1359a32e29fdad40f7286166e4fa51c592 100644 (file)
@@ -723,7 +723,7 @@ static int btrfsic_process_superblock(struct btrfsic_state *state,
                }
 
                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",
@@ -903,7 +903,7 @@ static int btrfsic_process_superblock_dev_mirror(
                }
 
                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",
@@ -1287,7 +1287,7 @@ static int btrfsic_create_link_to_next_block(
        *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",
@@ -1489,7 +1489,7 @@ static int btrfsic_handle_extent_data(
                        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",
@@ -2463,7 +2463,7 @@ static int btrfsic_process_written_superblock(
                }
 
                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",
@@ -2960,7 +2960,7 @@ static void btrfsic_cmp_log_and_dev_bytenr(struct btrfsic_state *state,
        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++) {
index ff5d259ac2750f3c2504ae092d68bf4b53655835..ba2b931fd8f65fe942972ae85c58588a2f29ccf7 100644 (file)
@@ -387,7 +387,7 @@ static int btree_read_extent_buffer_pages(struct btrfs_root *root,
                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;
index 3c062c8d1d704a31cdae5e844a432c352f107e5e..e0b7138909f0ac980ee18d760da20d5892fda0df 100644 (file)
@@ -2044,10 +2044,10 @@ static int clean_io_failure(u64 start, struct page *page)
        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);
@@ -2157,9 +2157,8 @@ static int bio_readpage_error(struct bio *failed_bio, struct page *page,
                 * 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
index 1483041eb86a4b98fb3cc4abed9b77d6486d355a..5612767b910e5bf6f1013d76e9c28d0bd5d73772 100644 (file)
@@ -3785,8 +3785,9 @@ void btrfs_mapping_tree_free(struct btrfs_mapping_tree *tree)
        }
 }
 
-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;
index 657bb12b306999b9b43df3115e9816cb4a145bdd..35ea4424963b6d8ca5e77e975570410eb3e0aeda 100644 (file)
@@ -278,7 +278,7 @@ int btrfs_add_device(struct btrfs_trans_handle *trans,
                     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,