aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fb.com>2014-05-07 17:06:09 -0400
committerChris Mason <clm@fb.com>2014-06-09 20:20:49 -0400
commitfaa2dbf004e89e8f7ccd28fbe6f07c308417b8ae (patch)
treeb700876fe08b8830d4e8686c039f4241cc9cb5e2 /fs/btrfs/disk-io.c
parentfcebe4562dec83b3f8d3088d77584727b09130b2 (diff)
Btrfs: add sanity tests for new qgroup accounting code
This exercises the various parts of the new qgroup accounting code. We do some basic stuff and do some things with the shared refs to make sure all that code works. I had to add a bunch of infrastructure because I needed to be able to insert items into a fake tree without having to do all the hard work myself, hopefully this will be usefull in the future. Thanks, Signed-off-by: Josef Bacik <jbacik@fb.com> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 77f92a32e230..0c0fa78ef452 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1110,6 +1110,11 @@ struct extent_buffer *btrfs_find_tree_block(struct btrfs_root *root,
1110struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root, 1110struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root,
1111 u64 bytenr, u32 blocksize) 1111 u64 bytenr, u32 blocksize)
1112{ 1112{
1113#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
1114 if (unlikely(test_bit(BTRFS_ROOT_DUMMY_ROOT, &root->state)))
1115 return alloc_test_extent_buffer(root->fs_info, bytenr,
1116 blocksize);
1117#endif
1113 return alloc_extent_buffer(root->fs_info, bytenr, blocksize); 1118 return alloc_extent_buffer(root->fs_info, bytenr, blocksize);
1114} 1119}
1115 1120
@@ -1288,6 +1293,7 @@ struct btrfs_root *btrfs_alloc_dummy_root(void)
1288 return ERR_PTR(-ENOMEM); 1293 return ERR_PTR(-ENOMEM);
1289 __setup_root(4096, 4096, 4096, 4096, root, NULL, 1); 1294 __setup_root(4096, 4096, 4096, 4096, root, NULL, 1);
1290 set_bit(BTRFS_ROOT_DUMMY_ROOT, &root->state); 1295 set_bit(BTRFS_ROOT_DUMMY_ROOT, &root->state);
1296 root->alloc_bytenr = 0;
1291 1297
1292 return root; 1298 return root;
1293} 1299}
@@ -2089,7 +2095,7 @@ static void free_root_pointers(struct btrfs_fs_info *info, int chunk_root)
2089 free_root_extent_buffers(info->chunk_root); 2095 free_root_extent_buffers(info->chunk_root);
2090} 2096}
2091 2097
2092static void del_fs_roots(struct btrfs_fs_info *fs_info) 2098void btrfs_free_fs_roots(struct btrfs_fs_info *fs_info)
2093{ 2099{
2094 int ret; 2100 int ret;
2095 struct btrfs_root *gang[8]; 2101 struct btrfs_root *gang[8];
@@ -2969,7 +2975,7 @@ fail_qgroup:
2969fail_trans_kthread: 2975fail_trans_kthread:
2970 kthread_stop(fs_info->transaction_kthread); 2976 kthread_stop(fs_info->transaction_kthread);
2971 btrfs_cleanup_transaction(fs_info->tree_root); 2977 btrfs_cleanup_transaction(fs_info->tree_root);
2972 del_fs_roots(fs_info); 2978 btrfs_free_fs_roots(fs_info);
2973fail_cleaner: 2979fail_cleaner:
2974 kthread_stop(fs_info->cleaner_kthread); 2980 kthread_stop(fs_info->cleaner_kthread);
2975 2981
@@ -3504,8 +3510,10 @@ void btrfs_drop_and_free_fs_root(struct btrfs_fs_info *fs_info,
3504 if (test_bit(BTRFS_FS_STATE_ERROR, &fs_info->fs_state)) 3510 if (test_bit(BTRFS_FS_STATE_ERROR, &fs_info->fs_state))
3505 btrfs_free_log(NULL, root); 3511 btrfs_free_log(NULL, root);
3506 3512
3507 __btrfs_remove_free_space_cache(root->free_ino_pinned); 3513 if (root->free_ino_pinned)
3508 __btrfs_remove_free_space_cache(root->free_ino_ctl); 3514 __btrfs_remove_free_space_cache(root->free_ino_pinned);
3515 if (root->free_ino_ctl)
3516 __btrfs_remove_free_space_cache(root->free_ino_ctl);
3509 free_fs_root(root); 3517 free_fs_root(root);
3510} 3518}
3511 3519
@@ -3655,7 +3663,7 @@ int close_ctree(struct btrfs_root *root)
3655 3663
3656 btrfs_sysfs_remove_one(fs_info); 3664 btrfs_sysfs_remove_one(fs_info);
3657 3665
3658 del_fs_roots(fs_info); 3666 btrfs_free_fs_roots(fs_info);
3659 3667
3660 btrfs_put_block_group_cache(fs_info); 3668 btrfs_put_block_group_cache(fs_info);
3661 3669