mbox series

[v2,00/15] btrfs: add a shrinker for extent maps

Message ID cover.1712837044.git.fdmanana@suse.com (mailing list archive)
Headers show
Series btrfs: add a shrinker for extent maps | expand

Message

Filipe Manana April 11, 2024, 4:18 p.m. UTC
From: Filipe Manana <fdmanana@suse.com>

Currently we don't limit the amount of extent maps we can have for inodes
from a subvolume tree, which can result in excessive use of memory and in
some cases in running into OOM situations. This was reported some time ago
by a user and it's specially easier to trigger with direct IO.

The shrinker itself is patch 13/15, what comes before is simple preparatory
work and the rest just trace events. More details in the change logs.

V2: Split patch 09/11 into 3.
    Added two patches to export and use helper to find inode in a root.
    Updated patch 13/15 to use the helper for finding next inode and
    removed the #ifdef for 32 bits case which is irrelevant as on 32 bits
    systems we can't ever have more than ULONG_MAX extent maps allocated.

Filipe Manana (15):
  btrfs: pass an inode to btrfs_add_extent_mapping()
  btrfs: tests: error out on unexpected extent map reference count
  btrfs: simplify add_extent_mapping() by removing pointless label
  btrfs: pass the extent map tree's inode to add_extent_mapping()
  btrfs: pass the extent map tree's inode to clear_em_logging()
  btrfs: pass the extent map tree's inode to remove_extent_mapping()
  btrfs: pass the extent map tree's inode to replace_extent_mapping()
  btrfs: pass the extent map tree's inode to setup_extent_mapping()
  btrfs: pass the extent map tree's inode to try_merge_map()
  btrfs: add a global per cpu counter to track number of used extent maps
  btrfs: export find_next_inode() as btrfs_find_first_inode()
  btrfs: use btrfs_find_first_inode() at btrfs_prune_dentries()
  btrfs: add a shrinker for extent maps
  btrfs: update comment for btrfs_set_inode_full_sync() about locking
  btrfs: add tracepoints for extent map shrinker events

 fs/btrfs/btrfs_inode.h            |   9 +-
 fs/btrfs/disk-io.c                |   5 +
 fs/btrfs/extent_io.c              |   2 +-
 fs/btrfs/extent_map.c             | 297 ++++++++++++++++++++++++------
 fs/btrfs/extent_map.h             |   9 +-
 fs/btrfs/fs.h                     |   4 +
 fs/btrfs/inode.c                  | 126 +++++++------
 fs/btrfs/relocation.c             | 105 +++--------
 fs/btrfs/tests/extent-map-tests.c | 216 ++++++++++++----------
 fs/btrfs/tree-log.c               |   4 +-
 include/trace/events/btrfs.h      |  92 +++++++++
 11 files changed, 579 insertions(+), 290 deletions(-)