Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 252286
b: refs/heads/master
c: 34d52cb
h: refs/heads/master
v: v3
  • Loading branch information
Li Zefan committed Apr 25, 2011
1 parent 0e7358c commit 394fdc8
Show file tree
Hide file tree
Showing 5 changed files with 272 additions and 224 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f38b6e754d8cc4605ac21d9c1094d569d88b163b
refs/heads/master: 34d52cb6c50b5a43901709998f59fb1c5a43dc4a
7 changes: 1 addition & 6 deletions trunk/fs/btrfs/ctree.h
Original file line number Diff line number Diff line change
Expand Up @@ -830,9 +830,6 @@ struct btrfs_block_group_cache {
u64 bytes_super;
u64 flags;
u64 sectorsize;
int extents_thresh;
int free_extents;
int total_bitmaps;
unsigned int ro:1;
unsigned int dirty:1;
unsigned int iref:1;
Expand All @@ -847,9 +844,7 @@ struct btrfs_block_group_cache {
struct btrfs_space_info *space_info;

/* free space cache stuff */
spinlock_t tree_lock;
struct rb_root free_space_offset;
u64 free_space;
struct btrfs_free_space_ctl *free_space_ctl;

/* block group cache stuff */
struct rb_node cache_node;
Expand Down
37 changes: 19 additions & 18 deletions trunk/fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ void btrfs_put_block_group(struct btrfs_block_group_cache *cache)
WARN_ON(cache->pinned > 0);
WARN_ON(cache->reserved > 0);
WARN_ON(cache->reserved_pinned > 0);
kfree(cache->free_space_ctl);
kfree(cache);
}
}
Expand Down Expand Up @@ -4893,7 +4894,7 @@ wait_block_group_cache_progress(struct btrfs_block_group_cache *cache,
return 0;

wait_event(caching_ctl->wait, block_group_cache_done(cache) ||
(cache->free_space >= num_bytes));
(cache->free_space_ctl->free_space >= num_bytes));

put_caching_control(caching_ctl);
return 0;
Expand Down Expand Up @@ -8551,25 +8552,23 @@ int btrfs_read_block_groups(struct btrfs_root *root)
ret = -ENOMEM;
goto error;
}
cache->free_space_ctl = kzalloc(sizeof(*cache->free_space_ctl),
GFP_NOFS);
if (!cache->free_space_ctl) {
kfree(cache);
ret = -ENOMEM;
goto error;
}

atomic_set(&cache->count, 1);
spin_lock_init(&cache->lock);
spin_lock_init(&cache->tree_lock);
cache->fs_info = info;
INIT_LIST_HEAD(&cache->list);
INIT_LIST_HEAD(&cache->cluster_list);

if (need_clear)
cache->disk_cache_state = BTRFS_DC_CLEAR;

/*
* we only want to have 32k of ram per block group for keeping
* track of free space, and if we pass 1/2 of that we want to
* start converting things over to using bitmaps
*/
cache->extents_thresh = ((1024 * 32) / 2) /
sizeof(struct btrfs_free_space);

read_extent_buffer(leaf, &cache->item,
btrfs_item_ptr_offset(leaf, path->slots[0]),
sizeof(cache->item));
Expand All @@ -8580,6 +8579,8 @@ int btrfs_read_block_groups(struct btrfs_root *root)
cache->flags = btrfs_block_group_flags(&cache->item);
cache->sectorsize = root->sectorsize;

btrfs_init_free_space_ctl(cache);

/*
* We need to exclude the super stripes now so that the space
* info has super bytes accounted for, otherwise we'll think
Expand Down Expand Up @@ -8666,26 +8667,26 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans,
cache = kzalloc(sizeof(*cache), GFP_NOFS);
if (!cache)
return -ENOMEM;
cache->free_space_ctl = kzalloc(sizeof(*cache->free_space_ctl),
GFP_NOFS);
if (!cache->free_space_ctl) {
kfree(cache);
return -ENOMEM;
}

cache->key.objectid = chunk_offset;
cache->key.offset = size;
cache->key.type = BTRFS_BLOCK_GROUP_ITEM_KEY;
cache->sectorsize = root->sectorsize;
cache->fs_info = root->fs_info;

/*
* we only want to have 32k of ram per block group for keeping track
* of free space, and if we pass 1/2 of that we want to start
* converting things over to using bitmaps
*/
cache->extents_thresh = ((1024 * 32) / 2) /
sizeof(struct btrfs_free_space);
atomic_set(&cache->count, 1);
spin_lock_init(&cache->lock);
spin_lock_init(&cache->tree_lock);
INIT_LIST_HEAD(&cache->list);
INIT_LIST_HEAD(&cache->cluster_list);

btrfs_init_free_space_ctl(cache);

btrfs_set_block_group_used(&cache->item, bytes_used);
btrfs_set_block_group_chunk_objectid(&cache->item, chunk_objectid);
cache->flags = type;
Expand Down
Loading

0 comments on commit 394fdc8

Please sign in to comment.