Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 155917
b: refs/heads/master
c: 9630308
h: refs/heads/master
i:
  155915: acc0eb7
v: v3
  • Loading branch information
Josef Bacik authored and Chris Mason committed Jul 24, 2009
1 parent 0635451 commit bf57f8f
Show file tree
Hide file tree
Showing 5 changed files with 827 additions and 217 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: 83121942b28daffc9526b14b7843d8cdbd3db641
refs/heads/master: 963030817060e4f109be1993b9ae8f81dbf5e11a
8 changes: 7 additions & 1 deletion trunk/fs/btrfs/ctree.h
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,9 @@ struct btrfs_free_cluster {
/* first extent starting offset */
u64 window_start;

/* if this cluster simply points at a bitmap in the block group */
bool points_to_bitmap;

struct btrfs_block_group_cache *block_group;
/*
* when a cluster is allocated from a block group, we put the
Expand All @@ -726,6 +729,10 @@ struct btrfs_block_group_cache {
u64 pinned;
u64 reserved;
u64 flags;
u64 sectorsize;
int extents_thresh;
int free_extents;
int total_bitmaps;
int cached;
int ro;
int dirty;
Expand All @@ -734,7 +741,6 @@ struct btrfs_block_group_cache {

/* free space cache stuff */
spinlock_t tree_lock;
struct rb_root free_space_bytes;
struct rb_root free_space_offset;

/* block group cache stuff */
Expand Down
25 changes: 24 additions & 1 deletion trunk/fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -3649,7 +3649,6 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans,
goto loop;
checks:
search_start = stripe_align(root, offset);

/* move on to the next group */
if (search_start + num_bytes >= search_end) {
btrfs_add_free_space(block_group, offset, num_bytes);
Expand Down Expand Up @@ -7040,6 +7039,16 @@ int btrfs_read_block_groups(struct btrfs_root *root)
mutex_init(&cache->cache_mutex);
INIT_LIST_HEAD(&cache->list);
INIT_LIST_HEAD(&cache->cluster_list);
cache->sectorsize = root->sectorsize;

/*
* 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 Down Expand Up @@ -7091,6 +7100,15 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans,
cache->key.objectid = chunk_offset;
cache->key.offset = size;
cache->key.type = BTRFS_BLOCK_GROUP_ITEM_KEY;
cache->sectorsize = root->sectorsize;

/*
* 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);
Expand All @@ -7103,6 +7121,11 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans,
cache->flags = type;
btrfs_set_block_group_flags(&cache->item, type);

cache->cached = 1;
ret = btrfs_add_free_space(cache, chunk_offset, size);
BUG_ON(ret);
remove_sb_from_cache(root, cache);

ret = update_space_info(root->fs_info, cache->flags, size, bytes_used,
&cache->space_info);
BUG_ON(ret);
Expand Down
Loading

0 comments on commit bf57f8f

Please sign in to comment.