From b06a4ea95b53c38641508248d80685ff78ad49f0 Mon Sep 17 00:00:00 2001 From: Chris Mason Date: Tue, 22 Sep 2009 14:48:44 -0400 Subject: [PATCH] --- yaml --- r: 165915 b: refs/heads/master c: 7ce618db9878689f87897b673fa3329070860fc7 h: refs/heads/master i: 165913: 0a68123356047adaa581cf22c0279b71d364413b 165911: 044a14f8542555363bbbe407200d683109ceba8a v: v3 --- [refs] | 2 +- trunk/fs/btrfs/extent-tree.c | 20 +++++++------------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/[refs] b/[refs] index 171e45554a4a..f25ed6289aa0 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 33b4d47f5e24b986f486d7de9a2df915ad1fdfbc +refs/heads/master: 7ce618db9878689f87897b673fa3329070860fc7 diff --git a/trunk/fs/btrfs/extent-tree.c b/trunk/fs/btrfs/extent-tree.c index 1b9b87870f51..90d314eeff6d 100644 --- a/trunk/fs/btrfs/extent-tree.c +++ b/trunk/fs/btrfs/extent-tree.c @@ -6756,22 +6756,16 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr) /* * if this is the last block group we have in this space, we can't - * relocate it. + * relocate it unless we're able to allocate a new chunk below. + * + * Otherwise, we need to make sure we have room in the space to handle + * all of the extents from this block group. If we can, we're good */ - if (space_info->total_bytes == block_group->key.offset) { - ret = -1; - spin_unlock(&space_info->lock); - goto out; - } - - /* - * need to make sure we have room in the space to handle all of the - * extents from this block group. If we can, we're good - */ - if (space_info->bytes_used + space_info->bytes_reserved + + if ((space_info->total_bytes != block_group->key.offset) && + (space_info->bytes_used + space_info->bytes_reserved + space_info->bytes_pinned + space_info->bytes_readonly + btrfs_block_group_used(&block_group->item) < - space_info->total_bytes) { + space_info->total_bytes)) { spin_unlock(&space_info->lock); goto out; }