aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorJosef Bacik <josef@redhat.com>2010-10-15 15:13:32 -0400
committerJosef Bacik <josef@redhat.com>2010-10-22 15:54:56 -0400
commit6d48755d02b150de7f47e7b4753202f2fc9f990f (patch)
tree82bfa3265acbec93df92c9e0a5dced4e9b224208 /fs/btrfs
parent89a55897a2fbbceb94480952784004bf23911d38 (diff)
Btrfs: fix reservation code for mixed block groups
The global reservation stuff tries to add together DATA and METADATA used in order to figure out how much to reserve for everything, but this doesn't work right for mixed block groups. Instead if we have mixed block groups just set data used to 0. Also with mixed block groups we will use bytes_may_use for keeping track of delalloc bytes, so we need to take that into account in our reservation calculations. Signed-off-by: Josef Bacik <josef@redhat.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/extent-tree.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 4669c6f8a44..0f27f7b4880 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3213,7 +3213,8 @@ static int reserve_metadata_bytes(struct btrfs_block_rsv *block_rsv,
3213 3213
3214 spin_lock(&space_info->lock); 3214 spin_lock(&space_info->lock);
3215 unused = space_info->bytes_used + space_info->bytes_reserved + 3215 unused = space_info->bytes_used + space_info->bytes_reserved +
3216 space_info->bytes_pinned + space_info->bytes_readonly; 3216 space_info->bytes_pinned + space_info->bytes_readonly +
3217 space_info->bytes_may_use;
3217 3218
3218 if (unused < space_info->total_bytes) 3219 if (unused < space_info->total_bytes)
3219 unused = space_info->total_bytes - unused; 3220 unused = space_info->total_bytes - unused;
@@ -3507,6 +3508,8 @@ static u64 calc_global_metadata_size(struct btrfs_fs_info *fs_info)
3507 3508
3508 sinfo = __find_space_info(fs_info, BTRFS_BLOCK_GROUP_METADATA); 3509 sinfo = __find_space_info(fs_info, BTRFS_BLOCK_GROUP_METADATA);
3509 spin_lock(&sinfo->lock); 3510 spin_lock(&sinfo->lock);
3511 if (sinfo->flags & BTRFS_BLOCK_GROUP_DATA)
3512 data_used = 0;
3510 meta_used = sinfo->bytes_used; 3513 meta_used = sinfo->bytes_used;
3511 spin_unlock(&sinfo->lock); 3514 spin_unlock(&sinfo->lock);
3512 3515
@@ -3534,7 +3537,8 @@ static void update_global_block_rsv(struct btrfs_fs_info *fs_info)
3534 block_rsv->size = num_bytes; 3537 block_rsv->size = num_bytes;
3535 3538
3536 num_bytes = sinfo->bytes_used + sinfo->bytes_pinned + 3539 num_bytes = sinfo->bytes_used + sinfo->bytes_pinned +
3537 sinfo->bytes_reserved + sinfo->bytes_readonly; 3540 sinfo->bytes_reserved + sinfo->bytes_readonly +
3541 sinfo->bytes_may_use;
3538 3542
3539 if (sinfo->total_bytes > num_bytes) { 3543 if (sinfo->total_bytes > num_bytes) {
3540 num_bytes = sinfo->total_bytes - num_bytes; 3544 num_bytes = sinfo->total_bytes - num_bytes;