Skip to content

Commit a9f1897

Browse files
naotakdave
authored andcommitted
btrfs: move out now unused BG from the reclaim list
An unused block group is easy to remove to free up space and should be reclaimed fast. Such block group can often already be a target of the reclaim process. As we check list_empty(&bg->bg_list), we keep it in the reclaim list. That block group is never reclaimed until the file system is filled e.g. up to 75%. Instead, we can move unused block group to the unused list and delete it fast. Fixes: 18bb8bb ("btrfs: zoned: automatically reclaim zones") CC: [email protected] # 5.15+ Reviewed-by: Filipe Manana <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Signed-off-by: Naohiro Aota <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 3ed0161 commit a9f1897

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

fs/btrfs/block-group.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1633,11 +1633,14 @@ void btrfs_mark_bg_unused(struct btrfs_block_group *bg)
16331633
{
16341634
struct btrfs_fs_info *fs_info = bg->fs_info;
16351635

1636+
trace_btrfs_add_unused_block_group(bg);
16361637
spin_lock(&fs_info->unused_bgs_lock);
16371638
if (list_empty(&bg->bg_list)) {
16381639
btrfs_get_block_group(bg);
1639-
trace_btrfs_add_unused_block_group(bg);
16401640
list_add_tail(&bg->bg_list, &fs_info->unused_bgs);
1641+
} else {
1642+
/* Pull out the block group from the reclaim_bgs list. */
1643+
list_move_tail(&bg->bg_list, &fs_info->unused_bgs);
16411644
}
16421645
spin_unlock(&fs_info->unused_bgs_lock);
16431646
}

0 commit comments

Comments
 (0)