[f2fs-dev] [PATCH v2 0/3] f2fs: fix read extent cache merge and add debug interface

Yongpeng Yang <[email protected]> Sat, 15 Aug 2026 00:49:25 +0800
Newsgroups net.sourceforge.lists.linux-f2fs-devel
Message-ID <[email protected]>
From: Yongpeng Yang <[email protected]>

This series fixes a read extent cache merge bug and adds a sysfs-based
debug interface for inspecting the in-memory extent tree, which is
otherwise invisible to userspace (fsck can only see the on-disk i_ext,
never the in-memory rbtree).

Changes since v1 (RESEND [1]):

- Patch 1 (was 1/5) reuse the result of __is_back_mergeable().

- Dropped [PATCH RESEND 2/5] "only initialize largest extent without
  extent_node at inode init": no benefit was observed in practice.

- Patch 2 (was 3/5) unchanged.

- Dropped [PATCH RESEND 4/5] "add extent_access_mode to track extent
  cache access patterns": on phones the read extent node memory budget
  is small, and no hit-ratio improvement was observed in performance
  tests.

- Patch 3 (was 5/5) -- replace the ioctl with a write-only per-sb sysfs
  entry `extent_cache_debug`. Writing a file descriptor to it resolves
  the inode in the writer's context, dumps the largest extent and every
  rbtree node (fofs/blk/len) to the kernel log via f2fs_info(); inspect
  with "dmesg | grep ino=<ino>". A matching f2fs_io `extent_cache`
  subcommand is added in f2fs-tools.

[1] https://lore.kernel.org/all/[email protected]/

Patch 1: fix extent merge failure when largest extent is not in rb-tree.
  When the largest extent exists only as a hint with no rbtree node
  (e.g. after shrink eviction), a newly inserted extent that is
  mergeable with it is not merged, leaving a gap that fiemap reports as
  separate extents.  Merge the new extent with the largest before the
  normal lookup.

Patch 2: punch largest extent instead of dropping it entirely on
  overlap.  Keep the larger remaining left/right portion after a
  partial overlap instead of discarding the whole largest extent,
  preserving cache coverage for truncate/overwrite.

Patch 3: dump read extent cache via sysfs for debugging.

Yongpeng Yang (3):
  f2fs: fix extent merge failure when largest extent is not in rb-tree
  f2fs: punch largest extent instead of dropping it entirely on overlap
  f2fs: dump read extent cache via sysfs for debugging

 fs/f2fs/extent_cache.c | 100 ++++++++++++++++++++++++++++++++++++++---
 fs/f2fs/f2fs.h         |   1 +
 fs/f2fs/sysfs.c        |  18 +++++++
 3 files changed, 112 insertions(+), 7 deletions(-)

--
2.43.0


_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel