btrfs-tests.c (5e2aa2ed08e2e280121dc7cf5609c87d464f12ef) | btrfs-tests.c (7c55ee0c4afba4434d973117234577ae6ff77a1c) |
---|---|
1/* 2 * Copyright (C) 2013 Fusion IO. All rights reserved. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public 6 * License v2 as published by the Free Software Foundation. 7 * 8 * This program is distributed in the hope that it will be useful, --- 7 unchanged lines hidden (view full) --- 16 * Boston, MA 021110-1307, USA. 17 */ 18 19#include <linux/fs.h> 20#include <linux/mount.h> 21#include <linux/magic.h> 22#include "btrfs-tests.h" 23#include "../ctree.h" | 1/* 2 * Copyright (C) 2013 Fusion IO. All rights reserved. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public 6 * License v2 as published by the Free Software Foundation. 7 * 8 * This program is distributed in the hope that it will be useful, --- 7 unchanged lines hidden (view full) --- 16 * Boston, MA 021110-1307, USA. 17 */ 18 19#include <linux/fs.h> 20#include <linux/mount.h> 21#include <linux/magic.h> 22#include "btrfs-tests.h" 23#include "../ctree.h" |
24#include "../free-space-cache.h" 25#include "../free-space-tree.h" 26#include "../transaction.h" |
|
24#include "../volumes.h" 25#include "../disk-io.h" 26#include "../qgroup.h" 27 28static struct vfsmount *test_mnt = NULL; 29 30static const struct super_operations btrfs_test_super_ops = { 31 .alloc_inode = btrfs_alloc_inode, --- 85 unchanged lines hidden (view full) --- 117 fs_info->qgroup_tree = RB_ROOT; 118 fs_info->qgroup_ulist = NULL; 119 atomic64_set(&fs_info->tree_mod_seq, 0); 120 INIT_LIST_HEAD(&fs_info->dirty_qgroups); 121 INIT_LIST_HEAD(&fs_info->dead_roots); 122 INIT_LIST_HEAD(&fs_info->tree_mod_seq_list); 123 INIT_RADIX_TREE(&fs_info->buffer_radix, GFP_ATOMIC); 124 INIT_RADIX_TREE(&fs_info->fs_roots_radix, GFP_ATOMIC); | 27#include "../volumes.h" 28#include "../disk-io.h" 29#include "../qgroup.h" 30 31static struct vfsmount *test_mnt = NULL; 32 33static const struct super_operations btrfs_test_super_ops = { 34 .alloc_inode = btrfs_alloc_inode, --- 85 unchanged lines hidden (view full) --- 120 fs_info->qgroup_tree = RB_ROOT; 121 fs_info->qgroup_ulist = NULL; 122 atomic64_set(&fs_info->tree_mod_seq, 0); 123 INIT_LIST_HEAD(&fs_info->dirty_qgroups); 124 INIT_LIST_HEAD(&fs_info->dead_roots); 125 INIT_LIST_HEAD(&fs_info->tree_mod_seq_list); 126 INIT_RADIX_TREE(&fs_info->buffer_radix, GFP_ATOMIC); 127 INIT_RADIX_TREE(&fs_info->fs_roots_radix, GFP_ATOMIC); |
128 extent_io_tree_init(&fs_info->freed_extents[0], NULL); 129 extent_io_tree_init(&fs_info->freed_extents[1], NULL); 130 fs_info->pinned_extents = &fs_info->freed_extents[0]; |
|
125 return fs_info; 126} 127 128static void btrfs_free_dummy_fs_info(struct btrfs_fs_info *fs_info) 129{ 130 struct radix_tree_iter iter; 131 void **slot; 132 --- 31 unchanged lines hidden (view full) --- 164 return; 165 if (root->node) 166 free_extent_buffer(root->node); 167 if (root->fs_info) 168 btrfs_free_dummy_fs_info(root->fs_info); 169 kfree(root); 170} 171 | 131 return fs_info; 132} 133 134static void btrfs_free_dummy_fs_info(struct btrfs_fs_info *fs_info) 135{ 136 struct radix_tree_iter iter; 137 void **slot; 138 --- 31 unchanged lines hidden (view full) --- 170 return; 171 if (root->node) 172 free_extent_buffer(root->node); 173 if (root->fs_info) 174 btrfs_free_dummy_fs_info(root->fs_info); 175 kfree(root); 176} 177 |
178struct btrfs_block_group_cache * 179btrfs_alloc_dummy_block_group(unsigned long length) 180{ 181 struct btrfs_block_group_cache *cache; 182 183 cache = kzalloc(sizeof(*cache), GFP_NOFS); 184 if (!cache) 185 return NULL; 186 cache->free_space_ctl = kzalloc(sizeof(*cache->free_space_ctl), 187 GFP_NOFS); 188 if (!cache->free_space_ctl) { 189 kfree(cache); 190 return NULL; 191 } 192 193 cache->key.objectid = 0; 194 cache->key.offset = length; 195 cache->key.type = BTRFS_BLOCK_GROUP_ITEM_KEY; 196 cache->sectorsize = 4096; 197 cache->full_stripe_len = 4096; 198 199 INIT_LIST_HEAD(&cache->list); 200 INIT_LIST_HEAD(&cache->cluster_list); 201 INIT_LIST_HEAD(&cache->bg_list); 202 btrfs_init_free_space_ctl(cache); 203 mutex_init(&cache->free_space_lock); 204 205 return cache; 206} 207 208void btrfs_free_dummy_block_group(struct btrfs_block_group_cache *cache) 209{ 210 if (!cache) 211 return; 212 __btrfs_remove_free_space_cache(cache->free_space_ctl); 213 kfree(cache->free_space_ctl); 214 kfree(cache); 215} 216 217void btrfs_init_dummy_trans(struct btrfs_trans_handle *trans) 218{ 219 memset(trans, 0, sizeof(*trans)); 220 trans->transid = 1; 221 INIT_LIST_HEAD(&trans->qgroup_ref_list); 222 trans->type = __TRANS_DUMMY; 223} |
|