Commit 84fe47a4 authored by Josef Bacik's avatar Josef Bacik Committed by David Sterba

btrfs: add enospc debug messages for ticket failure

When debugging weird enospc problems it's handy to be able to dump the
space info when we wake up all tickets, and see what the ticket values
are.  This helped me figure out cases where we were enospc'ing when we
shouldn't have been.
Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 0096420a
...@@ -258,14 +258,11 @@ do { \ ...@@ -258,14 +258,11 @@ do { \
spin_unlock(&__rsv->lock); \ spin_unlock(&__rsv->lock); \
} while (0) } while (0)
void btrfs_dump_space_info(struct btrfs_fs_info *fs_info, static void __btrfs_dump_space_info(struct btrfs_fs_info *fs_info,
struct btrfs_space_info *info, u64 bytes, struct btrfs_space_info *info)
int dump_block_groups)
{ {
struct btrfs_block_group_cache *cache; lockdep_assert_held(&info->lock);
int index = 0;
spin_lock(&info->lock);
btrfs_info(fs_info, "space_info %llu has %llu free, is %sfull", btrfs_info(fs_info, "space_info %llu has %llu free, is %sfull",
info->flags, info->flags,
info->total_bytes - btrfs_space_info_used(info, true), info->total_bytes - btrfs_space_info_used(info, true),
...@@ -275,7 +272,6 @@ void btrfs_dump_space_info(struct btrfs_fs_info *fs_info, ...@@ -275,7 +272,6 @@ void btrfs_dump_space_info(struct btrfs_fs_info *fs_info,
info->total_bytes, info->bytes_used, info->bytes_pinned, info->total_bytes, info->bytes_used, info->bytes_pinned,
info->bytes_reserved, info->bytes_may_use, info->bytes_reserved, info->bytes_may_use,
info->bytes_readonly); info->bytes_readonly);
spin_unlock(&info->lock);
DUMP_BLOCK_RSV(fs_info, global_block_rsv); DUMP_BLOCK_RSV(fs_info, global_block_rsv);
DUMP_BLOCK_RSV(fs_info, trans_block_rsv); DUMP_BLOCK_RSV(fs_info, trans_block_rsv);
...@@ -283,6 +279,19 @@ void btrfs_dump_space_info(struct btrfs_fs_info *fs_info, ...@@ -283,6 +279,19 @@ void btrfs_dump_space_info(struct btrfs_fs_info *fs_info,
DUMP_BLOCK_RSV(fs_info, delayed_block_rsv); DUMP_BLOCK_RSV(fs_info, delayed_block_rsv);
DUMP_BLOCK_RSV(fs_info, delayed_refs_rsv); DUMP_BLOCK_RSV(fs_info, delayed_refs_rsv);
}
void btrfs_dump_space_info(struct btrfs_fs_info *fs_info,
struct btrfs_space_info *info, u64 bytes,
int dump_block_groups)
{
struct btrfs_block_group_cache *cache;
int index = 0;
spin_lock(&info->lock);
__btrfs_dump_space_info(fs_info, info);
spin_unlock(&info->lock);
if (!dump_block_groups) if (!dump_block_groups)
return; return;
...@@ -696,6 +705,11 @@ static bool maybe_fail_all_tickets(struct btrfs_fs_info *fs_info, ...@@ -696,6 +705,11 @@ static bool maybe_fail_all_tickets(struct btrfs_fs_info *fs_info,
u64 tickets_id = space_info->tickets_id; u64 tickets_id = space_info->tickets_id;
u64 first_ticket_bytes = 0; u64 first_ticket_bytes = 0;
if (btrfs_test_opt(fs_info, ENOSPC_DEBUG)) {
btrfs_info(fs_info, "cannot satisfy tickets, dumping space info");
__btrfs_dump_space_info(fs_info, space_info);
}
while (!list_empty(&space_info->tickets) && while (!list_empty(&space_info->tickets) &&
tickets_id == space_info->tickets_id) { tickets_id == space_info->tickets_id) {
ticket = list_first_entry(&space_info->tickets, ticket = list_first_entry(&space_info->tickets,
...@@ -716,6 +730,10 @@ static bool maybe_fail_all_tickets(struct btrfs_fs_info *fs_info, ...@@ -716,6 +730,10 @@ static bool maybe_fail_all_tickets(struct btrfs_fs_info *fs_info,
else if (first_ticket_bytes > ticket->bytes) else if (first_ticket_bytes > ticket->bytes)
return true; return true;
if (btrfs_test_opt(fs_info, ENOSPC_DEBUG))
btrfs_info(fs_info, "failing ticket with %llu bytes",
ticket->bytes);
list_del_init(&ticket->list); list_del_init(&ticket->list);
ticket->error = -ENOSPC; ticket->error = -ENOSPC;
wake_up(&ticket->wait); wake_up(&ticket->wait);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment