From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH v2 0/3] btrfs: further cleanup on dirty_cowonly_roots and switch_commits
Date: Tue, 13 Oct 2026 16:11:16 +1030 [thread overview]
Message-ID: <cover.1791869895.git.wqu@suse.com> (raw)
[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
next reply other threads:[~2026-10-13 5:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 5:41 Qu Wenruo [this message]
2026-10-13 5:41 ` [PATCH v2 1/3] btrfs: always remove quota_root from dirty_cowonly_roots Qu Wenruo
2026-10-13 5:41 ` [PATCH v2 2/3] btrfs: cleanup qgroup swapped blocks at root release Qu Wenruo
2026-10-13 5:41 ` [PATCH v2 3/3] btrfs: cleanup dirty_cowonly_roots during btrfs_free_fs_roots() Qu Wenruo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1791869895.git.wqu@suse.com \
--to=wqu@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.