]> www.infradead.org Git - users/willy/xarray.git/commitdiff
btrfs: Introduce fs_info to extent_io_tree
authorQu Wenruo <wqu@suse.com>
Fri, 1 Mar 2019 02:47:58 +0000 (10:47 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 29 Apr 2019 17:02:18 +0000 (19:02 +0200)
This patch will add a new member fs_info to extent_io_tree.

This provides the basis for later trace events to distinguish the output
between different btrfs filesystems. While this increases the size of
the structure, we want to know the source of the trace events and
passing the fs_info as an argument to all contexts is not possible.

The selftests are now allowed to set it to NULL as they don't use the
tracepoints.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/disk-io.c
fs/btrfs/extent_io.c
fs/btrfs/extent_io.h
fs/btrfs/inode.c
fs/btrfs/relocation.c
fs/btrfs/tests/btrfs-tests.c
fs/btrfs/tests/extent-io-tests.c
fs/btrfs/transaction.c

index c4404e1e9cfbaf5cff2bf52a44731075a6c313cf..26493c2fc23780fd9762d329a317bceab086c967 100644 (file)
@@ -1211,7 +1211,7 @@ static void __setup_root(struct btrfs_root *root, struct btrfs_fs_info *fs_info,
        root->log_transid_committed = -1;
        root->last_log_commit = 0;
        if (!dummy)
-               extent_io_tree_init(&root->dirty_log_pages, NULL);
+               extent_io_tree_init(fs_info, &root->dirty_log_pages, NULL);
 
        memset(&root->root_key, 0, sizeof(root->root_key));
        memset(&root->root_item, 0, sizeof(root->root_item));
@@ -2141,7 +2141,7 @@ static void btrfs_init_btree_inode(struct btrfs_fs_info *fs_info)
        inode->i_mapping->a_ops = &btree_aops;
 
        RB_CLEAR_NODE(&BTRFS_I(inode)->rb_node);
-       extent_io_tree_init(&BTRFS_I(inode)->io_tree, inode);
+       extent_io_tree_init(fs_info, &BTRFS_I(inode)->io_tree, inode);
        BTRFS_I(inode)->io_tree.track_uptodate = 0;
        extent_map_tree_init(&BTRFS_I(inode)->extent_tree);
 
@@ -2751,8 +2751,8 @@ int open_ctree(struct super_block *sb,
        fs_info->block_group_cache_tree = RB_ROOT;
        fs_info->first_logical_byte = (u64)-1;
 
-       extent_io_tree_init(&fs_info->freed_extents[0], NULL);
-       extent_io_tree_init(&fs_info->freed_extents[1], NULL);
+       extent_io_tree_init(fs_info, &fs_info->freed_extents[0], NULL);
+       extent_io_tree_init(fs_info, &fs_info->freed_extents[1], NULL);
        fs_info->pinned_extents = &fs_info->freed_extents[0];
        set_bit(BTRFS_FS_BARRIER, &fs_info->flags);
 
index ca8b8e785cf3a17f963449058210d1f0ff4cfd0d..139f2fe3092f8acfa86d46b92c75c979d435ebfc 100644 (file)
@@ -232,9 +232,10 @@ void __cold extent_io_exit(void)
        bioset_exit(&btrfs_bioset);
 }
 
-void extent_io_tree_init(struct extent_io_tree *tree,
-                        void *private_data)
+void extent_io_tree_init(struct btrfs_fs_info *fs_info,
+                        struct extent_io_tree *tree, void *private_data)
 {
+       tree->fs_info = fs_info;
        tree->state = RB_ROOT;
        tree->ops = NULL;
        tree->dirty_bytes = 0;
index 08749e0b9c32d52a8c70ce1c08a8f8f2cda2f614..e63215d692994873c8feef42ea47e6521f52d03d 100644 (file)
@@ -108,6 +108,7 @@ struct extent_io_ops {
 
 struct extent_io_tree {
        struct rb_root state;
+       struct btrfs_fs_info *fs_info;
        void *private_data;
        u64 dirty_bytes;
        int track_uptodate;
@@ -239,7 +240,8 @@ typedef struct extent_map *(get_extent_t)(struct btrfs_inode *inode,
                                          u64 start, u64 len,
                                          int create);
 
-void extent_io_tree_init(struct extent_io_tree *tree, void *private_data);
+void extent_io_tree_init(struct btrfs_fs_info *fs_info,
+                        struct extent_io_tree *tree, void *private_data);
 int try_release_extent_mapping(struct page *page, gfp_t mask);
 int try_release_extent_buffer(struct page *page);
 int lock_extent_bits(struct extent_io_tree *tree, u64 start, u64 end,
index cef875a2c475879c3a0a0dae562a8fadca452e82..2436bc50f21dfb23a2b31f01c2c62c0f1327b533 100644 (file)
@@ -9182,8 +9182,8 @@ struct inode *btrfs_alloc_inode(struct super_block *sb)
 
        inode = &ei->vfs_inode;
        extent_map_tree_init(&ei->extent_tree);
-       extent_io_tree_init(&ei->io_tree, inode);
-       extent_io_tree_init(&ei->io_failure_tree, inode);
+       extent_io_tree_init(fs_info, &ei->io_tree, inode);
+       extent_io_tree_init(fs_info, &ei->io_failure_tree, inode);
        ei->io_tree.track_uptodate = 1;
        ei->io_failure_tree.track_uptodate = 1;
        atomic_set(&ei->sync_writers, 0);
index ddf028509931289ab54c6a6feab771e6ed36f2d5..955da7baa66588d4756366abe984aa9a86e17632 100644 (file)
@@ -4222,7 +4222,7 @@ out:
        return inode;
 }
 
-static struct reloc_control *alloc_reloc_control(void)
+static struct reloc_control *alloc_reloc_control(struct btrfs_fs_info *fs_info)
 {
        struct reloc_control *rc;
 
@@ -4234,7 +4234,7 @@ static struct reloc_control *alloc_reloc_control(void)
        INIT_LIST_HEAD(&rc->dirty_subvol_roots);
        backref_cache_init(&rc->backref_cache);
        mapping_tree_init(&rc->reloc_root_tree);
-       extent_io_tree_init(&rc->processed_blocks, NULL);
+       extent_io_tree_init(fs_info, &rc->processed_blocks, NULL);
        return rc;
 }
 
@@ -4276,7 +4276,7 @@ int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start)
                return -ETXTBSY;
        }
 
-       rc = alloc_reloc_control();
+       rc = alloc_reloc_control(fs_info);
        if (!rc) {
                btrfs_put_block_group(bg);
                return -ENOMEM;
@@ -4472,7 +4472,7 @@ int btrfs_recover_relocation(struct btrfs_root *root)
        if (list_empty(&reloc_roots))
                goto out;
 
-       rc = alloc_reloc_control();
+       rc = alloc_reloc_control(fs_info);
        if (!rc) {
                err = -ENOMEM;
                goto out;
index 8a59597f188385a711458fc01a00acde8cfa6f38..cc1e5d017dc0159a14cde5e165cdf1805ad0f8b6 100644 (file)
@@ -115,8 +115,8 @@ struct btrfs_fs_info *btrfs_alloc_dummy_fs_info(u32 nodesize, u32 sectorsize)
        INIT_LIST_HEAD(&fs_info->tree_mod_seq_list);
        INIT_RADIX_TREE(&fs_info->buffer_radix, GFP_ATOMIC);
        INIT_RADIX_TREE(&fs_info->fs_roots_radix, GFP_ATOMIC);
-       extent_io_tree_init(&fs_info->freed_extents[0], NULL);
-       extent_io_tree_init(&fs_info->freed_extents[1], NULL);
+       extent_io_tree_init(fs_info, &fs_info->freed_extents[0], NULL);
+       extent_io_tree_init(fs_info, &fs_info->freed_extents[1], NULL);
        fs_info->pinned_extents = &fs_info->freed_extents[0];
        set_bit(BTRFS_FS_STATE_DUMMY_FS_INFO, &fs_info->fs_state);
 
index 3c46d7f2345663fc384e1e7fcbfdb968d5410952..6ac9770a974cb1f2b4cd88525007130dd56cdaa8 100644 (file)
@@ -77,7 +77,7 @@ static int test_find_delalloc(u32 sectorsize)
                return -ENOMEM;
        }
 
-       extent_io_tree_init(&tmp, NULL);
+       extent_io_tree_init(NULL, &tmp, NULL);
 
        /*
         * First go through and create and mark all of our pages dirty, we pin
index e4e665f422fc4c87b05181211b73ca2097e3b7c2..bc8ed44ad8c8a1212455c6f2d9f65f8df2977405 100644 (file)
@@ -274,7 +274,7 @@ loop:
        INIT_LIST_HEAD(&cur_trans->deleted_bgs);
        spin_lock_init(&cur_trans->dropped_roots_lock);
        list_add_tail(&cur_trans->list, &fs_info->trans_list);
-       extent_io_tree_init(&cur_trans->dirty_pages,
+       extent_io_tree_init(fs_info, &cur_trans->dirty_pages,
                             fs_info->btree_inode);
        fs_info->generation++;
        cur_trans->transid = fs_info->generation;