Skip to content

Commit e0af248

Browse files
wangxiaoguangkdave
authored andcommitted
btrfs: fix one bug that process may endlessly wait for ticket in wait_reserve_ticket()
If can_overcommit() in btrfs_calc_reclaim_metadata_size() returns true, btrfs_async_reclaim_metadata_space() will not reclaim metadata space, just return directly and also forget to wake up process which are waiting for their tickets, so these processes will wait endlessly. Fstests case generic/172 with mount option "-o compress=lzo" have revealed this bug in my test machine. Here if we have tickets to handle, we must handle them first. Signed-off-by: Wang Xiaoguang <[email protected]> Reviewed-by: Josef Bacik <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent a9b1fc8 commit e0af248

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

fs/btrfs/extent-tree.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4901,18 +4901,18 @@ btrfs_calc_reclaim_metadata_size(struct btrfs_root *root,
49014901
u64 expected;
49024902
u64 to_reclaim = 0;
49034903

4904-
to_reclaim = min_t(u64, num_online_cpus() * SZ_1M, SZ_16M);
4905-
if (can_overcommit(root, space_info, to_reclaim,
4906-
BTRFS_RESERVE_FLUSH_ALL))
4907-
return 0;
4908-
49094904
list_for_each_entry(ticket, &space_info->tickets, list)
49104905
to_reclaim += ticket->bytes;
49114906
list_for_each_entry(ticket, &space_info->priority_tickets, list)
49124907
to_reclaim += ticket->bytes;
49134908
if (to_reclaim)
49144909
return to_reclaim;
49154910

4911+
to_reclaim = min_t(u64, num_online_cpus() * SZ_1M, SZ_16M);
4912+
if (can_overcommit(root, space_info, to_reclaim,
4913+
BTRFS_RESERVE_FLUSH_ALL))
4914+
return 0;
4915+
49164916
used = space_info->bytes_used + space_info->bytes_reserved +
49174917
space_info->bytes_pinned + space_info->bytes_readonly +
49184918
space_info->bytes_may_use;

0 commit comments

Comments
 (0)