diff options
-rw-r--r-- | fs/btrfs/extent-tree.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 53e12977bfd0..85074845c562 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -9386,15 +9386,23 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr) | |||
9386 | u64 dev_min = 1; | 9386 | u64 dev_min = 1; |
9387 | u64 dev_nr = 0; | 9387 | u64 dev_nr = 0; |
9388 | u64 target; | 9388 | u64 target; |
9389 | int debug; | ||
9389 | int index; | 9390 | int index; |
9390 | int full = 0; | 9391 | int full = 0; |
9391 | int ret = 0; | 9392 | int ret = 0; |
9392 | 9393 | ||
9394 | debug = btrfs_test_opt(root, ENOSPC_DEBUG); | ||
9395 | |||
9393 | block_group = btrfs_lookup_block_group(root->fs_info, bytenr); | 9396 | block_group = btrfs_lookup_block_group(root->fs_info, bytenr); |
9394 | 9397 | ||
9395 | /* odd, couldn't find the block group, leave it alone */ | 9398 | /* odd, couldn't find the block group, leave it alone */ |
9396 | if (!block_group) | 9399 | if (!block_group) { |
9400 | if (debug) | ||
9401 | btrfs_warn(root->fs_info, | ||
9402 | "can't find block group for bytenr %llu", | ||
9403 | bytenr); | ||
9397 | return -1; | 9404 | return -1; |
9405 | } | ||
9398 | 9406 | ||
9399 | min_free = btrfs_block_group_used(&block_group->item); | 9407 | min_free = btrfs_block_group_used(&block_group->item); |
9400 | 9408 | ||
@@ -9448,8 +9456,13 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr) | |||
9448 | * this is just a balance, so if we were marked as full | 9456 | * this is just a balance, so if we were marked as full |
9449 | * we know there is no space for a new chunk | 9457 | * we know there is no space for a new chunk |
9450 | */ | 9458 | */ |
9451 | if (full) | 9459 | if (full) { |
9460 | if (debug) | ||
9461 | btrfs_warn(root->fs_info, | ||
9462 | "no space to alloc new chunk for block group %llu", | ||
9463 | block_group->key.objectid); | ||
9452 | goto out; | 9464 | goto out; |
9465 | } | ||
9453 | 9466 | ||
9454 | index = get_block_group_index(block_group); | 9467 | index = get_block_group_index(block_group); |
9455 | } | 9468 | } |
@@ -9496,6 +9509,10 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr) | |||
9496 | ret = -1; | 9509 | ret = -1; |
9497 | } | 9510 | } |
9498 | } | 9511 | } |
9512 | if (debug && ret == -1) | ||
9513 | btrfs_warn(root->fs_info, | ||
9514 | "no space to allocate a new chunk for block group %llu", | ||
9515 | block_group->key.objectid); | ||
9499 | mutex_unlock(&root->fs_info->chunk_mutex); | 9516 | mutex_unlock(&root->fs_info->chunk_mutex); |
9500 | btrfs_end_transaction(trans, root); | 9517 | btrfs_end_transaction(trans, root); |
9501 | out: | 9518 | out: |