btrfs-progs: Refactor btrfs_num_copies to use btrfs_fs_info
authorQu Wenruo <quwenruo@cn.fujitsu.com>
Tue, 13 Jun 2017 09:19:18 +0000 (17:19 +0800)
committerDavid Sterba <dsterba@suse.com>
Wed, 12 Jul 2017 15:52:15 +0000 (17:52 +0200)
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
btrfs-corrupt-block.c
btrfs-map-logical.c
cmds-check.c
cmds-restore.c
disk-io.c
image/main.c
volumes.c
volumes.h

index 01bd1f2..3269de5 100644 (file)
@@ -88,8 +88,8 @@ static int debug_corrupt_block(struct extent_buffer *eb,
                        fsync(eb->fd);
                }
 
-               num_copies = btrfs_num_copies(&root->fs_info->mapping_tree,
-                                             eb->start, eb->len);
+               num_copies = btrfs_num_copies(root->fs_info, eb->start,
+                                             eb->len);
                if (num_copies == 1)
                        break;
 
index c56253c..d752cf6 100644 (file)
@@ -149,7 +149,7 @@ static int print_mapping_info(struct btrfs_fs_info *fs_info, u64 logical,
        int mirror_num;
        int ret = 0;
 
-       num_copies = btrfs_num_copies(&fs_info->mapping_tree, logical, len);
+       num_copies = btrfs_num_copies(fs_info, logical, len);
        for (mirror_num = 1; mirror_num <= num_copies; mirror_num++) {
                ret = __print_mapping_info(fs_info, logical, len, mirror_num);
                if (ret < 0)
index cb4c11c..1b07f3a 100644 (file)
@@ -7214,8 +7214,7 @@ again:
                                fprintf(stderr, "mirror %d bytenr %llu csum %u expected csum %u\n",
                                                mirror, bytenr + tmp,
                                                csum, csum_expected);
-                               num_copies = btrfs_num_copies(
-                                               &root->fs_info->mapping_tree,
+                               num_copies = btrfs_num_copies(root->fs_info,
                                                bytenr, num_bytes);
                                if (mirror < num_copies - 1) {
                                        mirror += 1;
index 9ee38c7..c174bdd 100644 (file)
@@ -366,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) {
@@ -404,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;
index 32e2d26..9d2408c 100644 (file)
--- a/disk-io.c
+++ b/disk-io.c
@@ -370,8 +370,7 @@ struct extent_buffer* read_tree_block(
                        ret = -EIO;
                        break;
                }
-               num_copies = btrfs_num_copies(&fs_info->mapping_tree,
-                                             eb->start, eb->len);
+               num_copies = btrfs_num_copies(fs_info, eb->start, eb->len);
                if (num_copies == 1) {
                        ignore = 1;
                        continue;
index 5fb62e7..a84b10e 100644 (file)
@@ -884,8 +884,7 @@ static int read_data_extent(struct metadump_struct *md,
        int cur_mirror;
        int ret;
 
-       num_copies = btrfs_num_copies(&root->fs_info->mapping_tree, logical,
-                                     bytes_left);
+       num_copies = btrfs_num_copies(root->fs_info, logical, bytes_left);
 
        /* Try our best to read data, just like read_tree_block() */
        for (cur_mirror = 0; cur_mirror < num_copies; cur_mirror++) {
index 1ff90f0..89e39e4 100644 (file)
--- a/volumes.c
+++ b/volumes.c
@@ -1215,8 +1215,9 @@ int btrfs_alloc_data_chunk(struct btrfs_trans_handle *trans,
        return ret;
 }
 
-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 cache_extent *ce;
        struct map_lookup *map;
        int ret;
index 59e4316..26d8881 100644 (file)
--- a/volumes.h
+++ b/volumes.h
@@ -228,7 +228,7 @@ int btrfs_update_device(struct btrfs_trans_handle *trans,
 int btrfs_scan_one_device(int fd, const char *path,
                          struct btrfs_fs_devices **fs_devices_ret,
                          u64 *total_devs, u64 super_offset, unsigned sbflags);
-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 list_head *btrfs_scanned_uuids(void);
 int btrfs_add_system_chunk(struct btrfs_root *root, struct btrfs_key *key,
                           struct btrfs_chunk *chunk, int item_size);