Skip to content

Commit cfbc0ff

Browse files
committed
Merge tag 'for-6.10-rc6-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
Pull btrfs fix from David Sterba: "A fixup for a recent fix that prevents an infinite loop during block group reclaim. Unfortunately it introduced an unsafe way of updating block group list and could race with relocation. This could be hit on fast devices when relocation/balance does not have enough space" * tag 'for-6.10-rc6-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux: btrfs: fix adding block group to a reclaim list and the unused list during reclaim
2 parents 9903efb + 48f091f commit cfbc0ff

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

fs/btrfs/block-group.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,8 +1924,17 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)
19241924
next:
19251925
if (ret) {
19261926
/* Refcount held by the reclaim_bgs list after splice. */
1927-
btrfs_get_block_group(bg);
1928-
list_add_tail(&bg->bg_list, &retry_list);
1927+
spin_lock(&fs_info->unused_bgs_lock);
1928+
/*
1929+
* This block group might be added to the unused list
1930+
* during the above process. Move it back to the
1931+
* reclaim list otherwise.
1932+
*/
1933+
if (list_empty(&bg->bg_list)) {
1934+
btrfs_get_block_group(bg);
1935+
list_add_tail(&bg->bg_list, &retry_list);
1936+
}
1937+
spin_unlock(&fs_info->unused_bgs_lock);
19291938
}
19301939
btrfs_put_block_group(bg);
19311940

0 commit comments

Comments
 (0)