This is a note to let you know that I've just added the patch titled btrfs: move out now unused BG from the reclaim list to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: btrfs-move-out-now-unused-bg-from-the-reclaim-list.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From a9f189716cf15913c453299d72f69c51a9b0f86b Mon Sep 17 00:00:00 2001 From: Naohiro Aota <naota@xxxxxxxxx> Date: Tue, 6 Jun 2023 14:36:34 +0900 Subject: btrfs: move out now unused BG from the reclaim list From: Naohiro Aota <naota@xxxxxxxxx> commit a9f189716cf15913c453299d72f69c51a9b0f86b upstream. 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: 18bb8bbf13c1 ("btrfs: zoned: automatically reclaim zones") CC: stable@xxxxxxxxxxxxxxx # 5.15+ Reviewed-by: Filipe Manana <fdmanana@xxxxxxxx> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@xxxxxxx> Signed-off-by: Naohiro Aota <naohiro.aota@xxxxxxx> Signed-off-by: David Sterba <dsterba@xxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/btrfs/block-group.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -1475,11 +1475,14 @@ void btrfs_mark_bg_unused(struct btrfs_b { struct btrfs_fs_info *fs_info = bg->fs_info; + trace_btrfs_add_unused_block_group(bg); spin_lock(&fs_info->unused_bgs_lock); if (list_empty(&bg->bg_list)) { btrfs_get_block_group(bg); - trace_btrfs_add_unused_block_group(bg); list_add_tail(&bg->bg_list, &fs_info->unused_bgs); + } else { + /* Pull out the block group from the reclaim_bgs list. */ + list_move_tail(&bg->bg_list, &fs_info->unused_bgs); } spin_unlock(&fs_info->unused_bgs_lock); } Patches currently in stable-queue which might be from naota@xxxxxxxxx are queue-5.15/btrfs-bail-out-reclaim-process-if-filesystem-is-read-only.patch queue-5.15/btrfs-move-out-now-unused-bg-from-the-reclaim-list.patch queue-5.15/btrfs-delete-unused-bgs-while-reclaiming-bgs.patch queue-5.15/btrfs-reinsert-bgs-failed-to-reclaim.patch