Skip to content

Commit 84fe47a

Browse files
josefbacikkdave
authored andcommitted
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: Nikolay Borisov <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 0096420 commit 84fe47a

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

fs/btrfs/space-info.c

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -258,14 +258,11 @@ do { \
258258
spin_unlock(&__rsv->lock); \
259259
} while (0)
260260

261-
void btrfs_dump_space_info(struct btrfs_fs_info *fs_info,
262-
struct btrfs_space_info *info, u64 bytes,
263-
int dump_block_groups)
261+
static void __btrfs_dump_space_info(struct btrfs_fs_info *fs_info,
262+
struct btrfs_space_info *info)
264263
{
265-
struct btrfs_block_group_cache *cache;
266-
int index = 0;
264+
lockdep_assert_held(&info->lock);
267265

268-
spin_lock(&info->lock);
269266
btrfs_info(fs_info, "space_info %llu has %llu free, is %sfull",
270267
info->flags,
271268
info->total_bytes - btrfs_space_info_used(info, true),
@@ -275,14 +272,26 @@ void btrfs_dump_space_info(struct btrfs_fs_info *fs_info,
275272
info->total_bytes, info->bytes_used, info->bytes_pinned,
276273
info->bytes_reserved, info->bytes_may_use,
277274
info->bytes_readonly);
278-
spin_unlock(&info->lock);
279275

280276
DUMP_BLOCK_RSV(fs_info, global_block_rsv);
281277
DUMP_BLOCK_RSV(fs_info, trans_block_rsv);
282278
DUMP_BLOCK_RSV(fs_info, chunk_block_rsv);
283279
DUMP_BLOCK_RSV(fs_info, delayed_block_rsv);
284280
DUMP_BLOCK_RSV(fs_info, delayed_refs_rsv);
285281

282+
}
283+
284+
void btrfs_dump_space_info(struct btrfs_fs_info *fs_info,
285+
struct btrfs_space_info *info, u64 bytes,
286+
int dump_block_groups)
287+
{
288+
struct btrfs_block_group_cache *cache;
289+
int index = 0;
290+
291+
spin_lock(&info->lock);
292+
__btrfs_dump_space_info(fs_info, info);
293+
spin_unlock(&info->lock);
294+
286295
if (!dump_block_groups)
287296
return;
288297

@@ -696,6 +705,11 @@ static bool maybe_fail_all_tickets(struct btrfs_fs_info *fs_info,
696705
u64 tickets_id = space_info->tickets_id;
697706
u64 first_ticket_bytes = 0;
698707

708+
if (btrfs_test_opt(fs_info, ENOSPC_DEBUG)) {
709+
btrfs_info(fs_info, "cannot satisfy tickets, dumping space info");
710+
__btrfs_dump_space_info(fs_info, space_info);
711+
}
712+
699713
while (!list_empty(&space_info->tickets) &&
700714
tickets_id == space_info->tickets_id) {
701715
ticket = list_first_entry(&space_info->tickets,
@@ -716,6 +730,10 @@ static bool maybe_fail_all_tickets(struct btrfs_fs_info *fs_info,
716730
else if (first_ticket_bytes > ticket->bytes)
717731
return true;
718732

733+
if (btrfs_test_opt(fs_info, ENOSPC_DEBUG))
734+
btrfs_info(fs_info, "failing ticket with %llu bytes",
735+
ticket->bytes);
736+
719737
list_del_init(&ticket->list);
720738
ticket->error = -ENOSPC;
721739
wake_up(&ticket->wait);

0 commit comments

Comments
 (0)