From: Qu Wenruo <wqu@xxxxxxxx> commit 534f7eff9239c1b0af852fc33f5af2b62c00eddf upstream. Although there are several patches improving the extent map shrinker, there are still reports of too frequent shrinker behavior, taking too much CPU for the kswapd process. So let's only enable extent shrinker for now, until we got more comprehensive understanding and a better solution. Link: https://lore.kernel.org/linux-btrfs/3df4acd616a07ef4d2dc6bad668701504b412ffc.camel@xxxxxxxxxxxx/ Link: https://lore.kernel.org/linux-btrfs/c30fd6b3-ca7a-4759-8a53-d42878bf84f7@xxxxxxxxx/ Fixes: 956a17d9d050 ("btrfs: add a shrinker for extent maps") CC: stable@xxxxxxxxxxxxxxx # 6.10+ Signed-off-by: Qu Wenruo <wqu@xxxxxxxx> Reviewed-by: David Sterba <dsterba@xxxxxxxx> Signed-off-by: David Sterba <dsterba@xxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/btrfs/super.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -2387,7 +2387,13 @@ static long btrfs_nr_cached_objects(stru trace_btrfs_extent_map_shrinker_count(fs_info, nr); - return nr; + /* + * Only report the real number for DEBUG builds, as there are reports of + * serious performance degradation caused by too frequent shrinks. + */ + if (IS_ENABLED(CONFIG_BTRFS_DEBUG)) + return nr; + return 0; } static long btrfs_free_cached_objects(struct super_block *sb, struct shrink_control *sc) Patches currently in stable-queue which might be from wqu@xxxxxxxx are queue-6.10/btrfs-send-allow-cloning-non-aligned-extent-if-it-ends-at-i_size.patch queue-6.10/btrfs-only-enable-extent-map-shrinker-for-debug-builds.patch queue-6.10/btrfs-tree-checker-add-dev-extent-item-checks.patch queue-6.10/btrfs-tree-checker-reject-btrfs_ft_unknown-dir-type.patch