All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] btrfs: further cleanup on dirty_cowonly_roots and switch_commits
@ 2026-10-13  5:41 Qu Wenruo
  2026-10-13  5:41 ` [PATCH v2 1/3] btrfs: always remove quota_root from dirty_cowonly_roots Qu Wenruo
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Qu Wenruo @ 2026-10-13  5:41 UTC (permalink / raw)
  To: linux-btrfs

[CHANGELOG]
v2:
- Add a patch to release qgroup swapped blocks during btrfs_put_root()
  This is addressing a real but rare memory leak.

- Replace the btrfs_extent_io_tree_release() with an ASSERT()
  As cowonly roots should never have dirty_log_pages populated.
  That is only utilized by log trees, and log trees are already poperly
  cleaned up in btrfs_drop_all_logs()

- Remove the btrfs_qgroup_clean_swapped_blocks() call in
  btrfs_free_fs_roots()
  As we have a dedicated cleanup during btrfs_put_root(), no need to do
  it inside btrfs_free_fs_roots()

Sashiko mentioned that dirty_cowonly_roots can still be non-empty if a
transaction aborts during commit_cowonly_roots().

However it should not cause any problem, as after a transaction is
aborted, no one will ever touch dirty_cowonly_roots.
So even if it has some dangling pointers, as long as no one is reading
it, it's completely fine.

Furthermore, dirty_cowonly_roots contains roots that are not subvolume
nor log trees, thus they should not have swapped qgroup blocks nor
dirty_log_pages. This means no memory leak from those two members
either.

But we're still depending on such quirky behavior, and it's only going
to cause more false alerts from various LLMs, e.g. Sashiko is already
reporting problems on this.

This series address all those minor problems by:

- Remove quota_root from dirty_cowonly_roots during
  btrfs_quota_disable()
  This prepares for the final patch as we're adding a reader for
  dirty_cowonly_roots during unmount.

- Cleanup qgroup swapped blocks during btrfs_put_root()
  This is to address a real possible memory leak, that some dirty
  subvolumes can have qgroup swapped blocks, and that can leak memory
  if not properly handled.

- Cleanup dirty_cowonly_roots during btrfs_free_fs_roots()
  This to remove the quirky dirty_cowonly_roots handling, and relies on
  explicit removal during unmount.

  Also add a new ASSERT() to make sure that roots linked into
  dirty_cowonly_roots() has no dirty_log_pages.


*** BLURB HERE ***

Qu Wenruo (3):
  btrfs: always remove quota_root from dirty_cowonly_roots
  btrfs: cleanup qgroup swapped blocks at root release
  btrfs: cleanup dirty_cowonly_roots during btrfs_free_fs_roots()

 fs/btrfs/disk-io.c | 20 ++++++++++++++++++++
 fs/btrfs/qgroup.c  | 10 ++++++----
 2 files changed, 26 insertions(+), 4 deletions(-)

-- 
2.56.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-10-13 16:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-13  5:41 [PATCH v2 0/3] btrfs: further cleanup on dirty_cowonly_roots and switch_commits Qu Wenruo
2026-10-13  5:41 ` [PATCH v2 1/3] btrfs: always remove quota_root from dirty_cowonly_roots Qu Wenruo
2026-10-13 16:52   ` Filipe Manana
2026-10-13  5:41 ` [PATCH v2 2/3] btrfs: cleanup qgroup swapped blocks at root release Qu Wenruo
2026-10-13 16:52   ` Filipe Manana
2026-10-13  5:41 ` [PATCH v2 3/3] btrfs: cleanup dirty_cowonly_roots during btrfs_free_fs_roots() Qu Wenruo
2026-10-13 16:55   ` Filipe Manana

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.