diff options
| author | Qu Wenruo <quwenruo@cn.fujitsu.com> | 2016-03-22 23:38:17 -0400 |
|---|---|---|
| committer | David Sterba <dsterba@suse.com> | 2016-04-04 10:29:22 -0400 |
| commit | 0305bc279317a6ba261a663cc32721d78e6544cf (patch) | |
| tree | 2e9c33cdef202e9a5b4dba65e1f3ed89fa30d222 | |
| parent | 264813acb1c756aebc337b16b832604a0c9aadaf (diff) | |
btrfs: Output more info for enospc_debug mount option
As one user in mail list report reproducible balance ENOSPC error, it's
better to add more debug info for enospc_debug mount option.
Reported-by: Marc Haber <mh+linux-btrfs@zugschlus.de>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
| -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: |
