Skip to content

Commit

Permalink
btrfs: Output more info for enospc_debug mount option
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Qu Wenruo authored and David Sterba committed Apr 4, 2016
1 parent 264813a commit 0305bc2
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -9386,15 +9386,23 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr)
u64 dev_min = 1;
u64 dev_nr = 0;
u64 target;
int debug;
int index;
int full = 0;
int ret = 0;

debug = btrfs_test_opt(root, ENOSPC_DEBUG);

block_group = btrfs_lookup_block_group(root->fs_info, bytenr);

/* odd, couldn't find the block group, leave it alone */
if (!block_group)
if (!block_group) {
if (debug)
btrfs_warn(root->fs_info,
"can't find block group for bytenr %llu",
bytenr);
return -1;
}

min_free = btrfs_block_group_used(&block_group->item);

Expand Down Expand Up @@ -9448,8 +9456,13 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr)
* this is just a balance, so if we were marked as full
* we know there is no space for a new chunk
*/
if (full)
if (full) {
if (debug)
btrfs_warn(root->fs_info,
"no space to alloc new chunk for block group %llu",
block_group->key.objectid);
goto out;
}

index = get_block_group_index(block_group);
}
Expand Down Expand Up @@ -9496,6 +9509,10 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr)
ret = -1;
}
}
if (debug && ret == -1)
btrfs_warn(root->fs_info,
"no space to allocate a new chunk for block group %llu",
block_group->key.objectid);
mutex_unlock(&root->fs_info->chunk_mutex);
btrfs_end_transaction(trans, root);
out:
Expand Down

0 comments on commit 0305bc2

Please sign in to comment.