summary refs log tree commit diff
path: root/fs/btrfs
diff options
context:
space:
mode:
authorNaohiro Aota <naota@elisp.net>2023-06-06 14:36:36 +0900
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-07-19 16:22:13 +0200
commit9634e5360bd3ac86788fbbce426c862cb58b6fd9 (patch)
treecfd4f629fe97b5278e882c4d24a328987f6c090b /fs/btrfs
parentd9f1e518ab05dcc657e5ce318fa9418ee3db07e2 (diff)
downloadlinux-9634e5360bd3ac86788fbbce426c862cb58b6fd9.tar.gz
btrfs: reinsert BGs failed to reclaim
commit 7e27180994383b7c741ad87749db01e4989a02ba upstream.

The reclaim process can temporarily fail. For example, if the space is
getting tight, it fails to make the block group read-only. If there are no
further writes on that block group, the block group will never get back to
the reclaim list, and the BG never gets reclaimed. In a certain workload,
we can leave many such block groups never reclaimed.

So, let's get it back to the list and give it a chance to be reclaimed.

Fixes: 18bb8bbf13c1 ("btrfs: zoned: automatically reclaim zones")
CC: stable@vger.kernel.org # 5.15+
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/block-group.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index 94f50bc8df0d..30b264eb9d20 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -1642,6 +1642,8 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)
 		}
 
 next:
+		if (ret)
+			btrfs_mark_bg_to_reclaim(bg);
 		btrfs_put_block_group(bg);
 
 		mutex_unlock(&fs_info->reclaim_bgs_lock);