summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2019-02-28 21:47:58 -0500
committerDavid Sterba <dsterba@suse.com>2019-04-29 13:02:18 -0400
commitc258d6e36442eb5d3363f6dbc0e6f2c162bfb66d (patch)
tree00a1e8b15ef51787be08ad85e79957699d719603
parent3b1da515c64e18bdd6a13348313f1168396b3722 (diff)
btrfs: Introduce fs_info to extent_io_tree
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>
-rw-r--r--fs/btrfs/disk-io.c8
-rw-r--r--fs/btrfs/extent_io.c5
-rw-r--r--fs/btrfs/extent_io.h4
-rw-r--r--fs/btrfs/inode.c4
-rw-r--r--fs/btrfs/relocation.c8
-rw-r--r--fs/btrfs/tests/btrfs-tests.c4
-rw-r--r--fs/btrfs/tests/extent-io-tests.c2
-rw-r--r--fs/btrfs/transaction.c2
8 files changed, 20 insertions, 17 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index c4404e1e9cfb..26493c2fc237 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1211,7 +1211,7 @@ static void __setup_root(struct btrfs_root *root, struct btrfs_fs_info *fs_info,
1211 root->log_transid_committed = -1; 1211 root->log_transid_committed = -1;
1212 root->last_log_commit = 0; 1212 root->last_log_commit = 0;
1213 if (!dummy) 1213 if (!dummy)
1214 extent_io_tree_init(&root->dirty_log_pages, NULL); 1214 extent_io_tree_init(fs_info, &root->dirty_log_pages, NULL);
1215 1215
1216 memset(&root->root_key, 0, sizeof(root->root_key)); 1216 memset(&root->root_key, 0, sizeof(root->root_key));
1217 memset(&root->root_item, 0, sizeof(root->root_item)); 1217 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)
2141 inode->i_mapping->a_ops = &btree_aops; 2141 inode->i_mapping->a_ops = &btree_aops;
2142 2142
2143 RB_CLEAR_NODE(&BTRFS_I(inode)->rb_node); 2143 RB_CLEAR_NODE(&BTRFS_I(inode)->rb_node);
2144 extent_io_tree_init(&BTRFS_I(inode)->io_tree, inode); 2144 extent_io_tree_init(fs_info, &BTRFS_I(inode)->io_tree, inode);
2145 BTRFS_I(inode)->io_tree.track_uptodate = 0; 2145 BTRFS_I(inode)->io_tree.track_uptodate = 0;
2146 extent_map_tree_init(&BTRFS_I(inode)->extent_tree); 2146 extent_map_tree_init(&BTRFS_I(inode)->extent_tree);
2147 2147
@@ -2751,8 +2751,8 @@ int open_ctree(struct super_block *sb,
2751 fs_info->block_group_cache_tree = RB_ROOT; 2751 fs_info->block_group_cache_tree = RB_ROOT;
2752 fs_info->first_logical_byte = (u64)-1; 2752 fs_info->first_logical_byte = (u64)-1;
2753 2753
2754 extent_io_tree_init(&fs_info->freed_extents[0], NULL); 2754 extent_io_tree_init(fs_info, &fs_info->freed_extents[0], NULL);
2755 extent_io_tree_init(&fs_info->freed_extents[1], NULL); 2755 extent_io_tree_init(fs_info, &fs_info->freed_extents[1], NULL);
2756 fs_info->pinned_extents = &fs_info->freed_extents[0]; 2756 fs_info->pinned_extents = &fs_info->freed_extents[0];
2757 set_bit(BTRFS_FS_BARRIER, &fs_info->flags); 2757 set_bit(BTRFS_FS_BARRIER, &fs_info->flags);
2758 2758
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index ca8b8e785cf3..139f2fe3092f 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -232,9 +232,10 @@ void __cold extent_io_exit(void)
232 bioset_exit(&btrfs_bioset); 232 bioset_exit(&btrfs_bioset);
233} 233}
234 234
235void extent_io_tree_init(struct extent_io_tree *tree, 235void extent_io_tree_init(struct btrfs_fs_info *fs_info,
236 void *private_data) 236 struct extent_io_tree *tree, void *private_data)
237{ 237{
238 tree->fs_info = fs_info;
238 tree->state = RB_ROOT; 239 tree->state = RB_ROOT;
239 tree->ops = NULL; 240 tree->ops = NULL;
240 tree->dirty_bytes = 0; 241 tree->dirty_bytes = 0;
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index 08749e0b9c32..e63215d69299 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -108,6 +108,7 @@ struct extent_io_ops {
108 108
109struct extent_io_tree { 109struct extent_io_tree {
110 struct rb_root state; 110 struct rb_root state;
111 struct btrfs_fs_info *fs_info;
111 void *private_data; 112 void *private_data;
112 u64 dirty_bytes; 113 u64 dirty_bytes;
113 int track_uptodate; 114 int track_uptodate;
@@ -239,7 +240,8 @@ typedef struct extent_map *(get_extent_t)(struct btrfs_inode *inode,
239 u64 start, u64 len, 240 u64 start, u64 len,
240 int create); 241 int create);
241 242
242void extent_io_tree_init(struct extent_io_tree *tree, void *private_data); 243void extent_io_tree_init(struct btrfs_fs_info *fs_info,
244 struct extent_io_tree *tree, void *private_data);
243int try_release_extent_mapping(struct page *page, gfp_t mask); 245int try_release_extent_mapping(struct page *page, gfp_t mask);
244int try_release_extent_buffer(struct page *page); 246int try_release_extent_buffer(struct page *page);
245int lock_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, 247int lock_extent_bits(struct extent_io_tree *tree, u64 start, u64 end,
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index cef875a2c475..2436bc50f21d 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -9182,8 +9182,8 @@ struct inode *btrfs_alloc_inode(struct super_block *sb)
9182 9182
9183 inode = &ei->vfs_inode; 9183 inode = &ei->vfs_inode;
9184 extent_map_tree_init(&ei->extent_tree); 9184 extent_map_tree_init(&ei->extent_tree);
9185 extent_io_tree_init(&ei->io_tree, inode); 9185 extent_io_tree_init(fs_info, &ei->io_tree, inode);
9186 extent_io_tree_init(&ei->io_failure_tree, inode); 9186 extent_io_tree_init(fs_info, &ei->io_failure_tree, inode);
9187 ei->io_tree.track_uptodate = 1; 9187 ei->io_tree.track_uptodate = 1;
9188 ei->io_failure_tree.track_uptodate = 1; 9188 ei->io_failure_tree.track_uptodate = 1;
9189 atomic_set(&ei->sync_writers, 0); 9189 atomic_set(&ei->sync_writers, 0);
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index ddf028509931..955da7baa665 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -4222,7 +4222,7 @@ out:
4222 return inode; 4222 return inode;
4223} 4223}
4224 4224
4225static struct reloc_control *alloc_reloc_control(void) 4225static struct reloc_control *alloc_reloc_control(struct btrfs_fs_info *fs_info)
4226{ 4226{
4227 struct reloc_control *rc; 4227 struct reloc_control *rc;
4228 4228
@@ -4234,7 +4234,7 @@ static struct reloc_control *alloc_reloc_control(void)
4234 INIT_LIST_HEAD(&rc->dirty_subvol_roots); 4234 INIT_LIST_HEAD(&rc->dirty_subvol_roots);
4235 backref_cache_init(&rc->backref_cache); 4235 backref_cache_init(&rc->backref_cache);
4236 mapping_tree_init(&rc->reloc_root_tree); 4236 mapping_tree_init(&rc->reloc_root_tree);
4237 extent_io_tree_init(&rc->processed_blocks, NULL); 4237 extent_io_tree_init(fs_info, &rc->processed_blocks, NULL);
4238 return rc; 4238 return rc;
4239} 4239}
4240 4240
@@ -4276,7 +4276,7 @@ int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start)
4276 return -ETXTBSY; 4276 return -ETXTBSY;
4277 } 4277 }
4278 4278
4279 rc = alloc_reloc_control(); 4279 rc = alloc_reloc_control(fs_info);
4280 if (!rc) { 4280 if (!rc) {
4281 btrfs_put_block_group(bg); 4281 btrfs_put_block_group(bg);
4282 return -ENOMEM; 4282 return -ENOMEM;
@@ -4472,7 +4472,7 @@ int btrfs_recover_relocation(struct btrfs_root *root)
4472 if (list_empty(&reloc_roots)) 4472 if (list_empty(&reloc_roots))
4473 goto out; 4473 goto out;
4474 4474
4475 rc = alloc_reloc_control(); 4475 rc = alloc_reloc_control(fs_info);
4476 if (!rc) { 4476 if (!rc) {
4477 err = -ENOMEM; 4477 err = -ENOMEM;
4478 goto out; 4478 goto out;
diff --git a/fs/btrfs/tests/btrfs-tests.c b/fs/btrfs/tests/btrfs-tests.c
index 8a59597f1883..cc1e5d017dc0 100644
--- a/fs/btrfs/tests/btrfs-tests.c
+++ b/fs/btrfs/tests/btrfs-tests.c
@@ -115,8 +115,8 @@ struct btrfs_fs_info *btrfs_alloc_dummy_fs_info(u32 nodesize, u32 sectorsize)
115 INIT_LIST_HEAD(&fs_info->tree_mod_seq_list); 115 INIT_LIST_HEAD(&fs_info->tree_mod_seq_list);
116 INIT_RADIX_TREE(&fs_info->buffer_radix, GFP_ATOMIC); 116 INIT_RADIX_TREE(&fs_info->buffer_radix, GFP_ATOMIC);
117 INIT_RADIX_TREE(&fs_info->fs_roots_radix, GFP_ATOMIC); 117 INIT_RADIX_TREE(&fs_info->fs_roots_radix, GFP_ATOMIC);
118 extent_io_tree_init(&fs_info->freed_extents[0], NULL); 118 extent_io_tree_init(fs_info, &fs_info->freed_extents[0], NULL);
119 extent_io_tree_init(&fs_info->freed_extents[1], NULL); 119 extent_io_tree_init(fs_info, &fs_info->freed_extents[1], NULL);
120 fs_info->pinned_extents = &fs_info->freed_extents[0]; 120 fs_info->pinned_extents = &fs_info->freed_extents[0];
121 set_bit(BTRFS_FS_STATE_DUMMY_FS_INFO, &fs_info->fs_state); 121 set_bit(BTRFS_FS_STATE_DUMMY_FS_INFO, &fs_info->fs_state);
122 122
diff --git a/fs/btrfs/tests/extent-io-tests.c b/fs/btrfs/tests/extent-io-tests.c
index 3c46d7f23456..6ac9770a974c 100644
--- a/fs/btrfs/tests/extent-io-tests.c
+++ b/fs/btrfs/tests/extent-io-tests.c
@@ -77,7 +77,7 @@ static int test_find_delalloc(u32 sectorsize)
77 return -ENOMEM; 77 return -ENOMEM;
78 } 78 }
79 79
80 extent_io_tree_init(&tmp, NULL); 80 extent_io_tree_init(NULL, &tmp, NULL);
81 81
82 /* 82 /*
83 * First go through and create and mark all of our pages dirty, we pin 83 * First go through and create and mark all of our pages dirty, we pin
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index e4e665f422fc..bc8ed44ad8c8 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -274,7 +274,7 @@ loop:
274 INIT_LIST_HEAD(&cur_trans->deleted_bgs); 274 INIT_LIST_HEAD(&cur_trans->deleted_bgs);
275 spin_lock_init(&cur_trans->dropped_roots_lock); 275 spin_lock_init(&cur_trans->dropped_roots_lock);
276 list_add_tail(&cur_trans->list, &fs_info->trans_list); 276 list_add_tail(&cur_trans->list, &fs_info->trans_list);
277 extent_io_tree_init(&cur_trans->dirty_pages, 277 extent_io_tree_init(fs_info, &cur_trans->dirty_pages,
278 fs_info->btree_inode); 278 fs_info->btree_inode);
279 fs_info->generation++; 279 fs_info->generation++;
280 cur_trans->transid = fs_info->generation; 280 cur_trans->transid = fs_info->generation;