diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2010-11-09 07:55:34 +0100 |
---|---|---|
committer | Li Zefan <lizf@cn.fujitsu.com> | 2011-01-26 18:04:46 +0100 |
commit | 5e71b5d5ec07e4b3fb4c78c4e4b108ff667f123f (patch) | |
tree | 4fdb07b18c010f132d10b074bff60226b6517a08 /fs | |
parent | btrfs: Free fully occupied bitmap in cluster (diff) | |
download | linux-5e71b5d5ec07e4b3fb4c78c4e4b108ff667f123f.tar.xz linux-5e71b5d5ec07e4b3fb4c78c4e4b108ff667f123f.zip |
btrfs: Update stats when allocating from a cluster
When allocating extent entry from a cluster, we should update
the free_space and free_extents fields of the block group.
Reviewed-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/free-space-cache.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index cb0137e4047f..2974c4744d5c 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -1843,15 +1843,26 @@ u64 btrfs_alloc_from_cluster(struct btrfs_block_group_cache *block_group, entry->offset += bytes; entry->bytes -= bytes; - if (entry->bytes == 0) { + if (entry->bytes == 0) rb_erase(&entry->offset_index, &cluster->root); - kfree(entry); - } break; } out: spin_unlock(&cluster->lock); + if (!ret) + return 0; + + spin_lock(&block_group->tree_lock); + + block_group->free_space -= bytes; + if (entry->bytes == 0) { + block_group->free_extents--; + kfree(entry); + } + + spin_unlock(&block_group->tree_lock); + return ret; } |