Commit be744175 authored by Chris Mason's avatar Chris Mason Committed by David Woodhouse

Btrfs: more allocator enhancements

Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent be08c1b9
...@@ -26,8 +26,10 @@ int set_radix_bit(struct radix_tree_root *radix, unsigned long bit) ...@@ -26,8 +26,10 @@ int set_radix_bit(struct radix_tree_root *radix, unsigned long bit)
if (ret) if (ret)
return ret; return ret;
} }
set_bit(bit_slot, bits + 1); ret = test_and_set_bit(bit_slot, bits + 1);
return 0; if (ret < 0)
ret = 1;
return ret;
} }
int test_radix_bit(struct radix_tree_root *radix, unsigned long bit) int test_radix_bit(struct radix_tree_root *radix, unsigned long bit)
......
...@@ -257,6 +257,8 @@ struct btrfs_block_group_cache { ...@@ -257,6 +257,8 @@ struct btrfs_block_group_cache {
struct btrfs_block_group_item item; struct btrfs_block_group_item item;
u64 first_free; u64 first_free;
u64 last_alloc; u64 last_alloc;
u64 pinned;
int data;
}; };
struct crypto_hash; struct crypto_hash;
...@@ -264,12 +266,12 @@ struct btrfs_fs_info { ...@@ -264,12 +266,12 @@ struct btrfs_fs_info {
struct btrfs_root *extent_root; struct btrfs_root *extent_root;
struct btrfs_root *tree_root; struct btrfs_root *tree_root;
struct btrfs_root *dev_root; struct btrfs_root *dev_root;
struct btrfs_block_group_cache *block_group_cache;
struct radix_tree_root fs_roots_radix; struct radix_tree_root fs_roots_radix;
struct radix_tree_root pending_del_radix; struct radix_tree_root pending_del_radix;
struct radix_tree_root pinned_radix; struct radix_tree_root pinned_radix;
struct radix_tree_root dev_radix; struct radix_tree_root dev_radix;
struct radix_tree_root block_group_radix; struct radix_tree_root block_group_radix;
struct radix_tree_root block_group_data_radix;
u64 extent_tree_insert[BTRFS_MAX_LEVEL * 3]; u64 extent_tree_insert[BTRFS_MAX_LEVEL * 3];
int extent_tree_insert_nr; int extent_tree_insert_nr;
...@@ -1072,7 +1074,8 @@ static inline void btrfs_mark_buffer_dirty(struct buffer_head *bh) ...@@ -1072,7 +1074,8 @@ static inline void btrfs_mark_buffer_dirty(struct buffer_head *bh)
/* extent-tree.c */ /* extent-tree.c */
struct btrfs_block_group_cache *btrfs_find_block_group(struct btrfs_root *root, struct btrfs_block_group_cache *btrfs_find_block_group(struct btrfs_root *root,
struct btrfs_block_group_cache struct btrfs_block_group_cache
*hint, int data); *hint, u64 search_start,
int data);
int btrfs_inc_root_ref(struct btrfs_trans_handle *trans, int btrfs_inc_root_ref(struct btrfs_trans_handle *trans,
struct btrfs_root *root); struct btrfs_root *root);
struct buffer_head *btrfs_alloc_free_block(struct btrfs_trans_handle *trans, struct buffer_head *btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
......
...@@ -554,6 +554,7 @@ struct btrfs_root *open_ctree(struct super_block *sb) ...@@ -554,6 +554,7 @@ struct btrfs_root *open_ctree(struct super_block *sb)
INIT_RADIX_TREE(&fs_info->fs_roots_radix, GFP_NOFS); INIT_RADIX_TREE(&fs_info->fs_roots_radix, GFP_NOFS);
INIT_RADIX_TREE(&fs_info->dev_radix, GFP_NOFS); INIT_RADIX_TREE(&fs_info->dev_radix, GFP_NOFS);
INIT_RADIX_TREE(&fs_info->block_group_radix, GFP_KERNEL); INIT_RADIX_TREE(&fs_info->block_group_radix, GFP_KERNEL);
INIT_RADIX_TREE(&fs_info->block_group_data_radix, GFP_KERNEL);
INIT_LIST_HEAD(&fs_info->trans_list); INIT_LIST_HEAD(&fs_info->trans_list);
sb_set_blocksize(sb, 4096); sb_set_blocksize(sb, 4096);
fs_info->running_transaction = NULL; fs_info->running_transaction = NULL;
...@@ -582,7 +583,6 @@ struct btrfs_root *open_ctree(struct super_block *sb) ...@@ -582,7 +583,6 @@ struct btrfs_root *open_ctree(struct super_block *sb)
} }
mutex_init(&fs_info->trans_mutex); mutex_init(&fs_info->trans_mutex);
mutex_init(&fs_info->fs_mutex); mutex_init(&fs_info->fs_mutex);
fs_info->block_group_cache = NULL;
__setup_root(sb->s_blocksize, dev_root, __setup_root(sb->s_blocksize, dev_root,
fs_info, BTRFS_DEV_TREE_OBJECTID); fs_info, BTRFS_DEV_TREE_OBJECTID);
......
This diff is collapsed.
...@@ -811,7 +811,7 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans, ...@@ -811,7 +811,7 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
BTRFS_I(inode)->root = root; BTRFS_I(inode)->root = root;
group = btrfs_find_block_group(root, group, 0); group = btrfs_find_block_group(root, group, 0, 0);
BTRFS_I(inode)->block_group = group; BTRFS_I(inode)->block_group = group;
inode->i_uid = current->fsuid; inode->i_uid = current->fsuid;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment