linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC 0/3] btrfs: qgroup: Pause and resume qgroup for subvolume removal
@ 2019-07-31 10:23 Qu Wenruo
  2019-07-31 10:23 ` [PATCH RFC 1/3] btrfs: Refactor btrfs_clean_one_deleted_snapshot() to use fs_info other than root Qu Wenruo
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Qu Wenruo @ 2019-07-31 10:23 UTC (permalink / raw)
  To: linux-btrfs

Btrfs qgroup has one big performance overhead for certain snapshot drop.

Current btrfs_drop_snapshot() will try its best to find the highest
shared node, and just drop one ref of that common node.
This behavior is good for minimize extent tree modification, but a
disaster for qgroup.

Example:
      Root 300  Root 301
        A         B
        | \     / |
        |    X    |
        | /     \ |
        C         D
      /   \     /   \
     E     F    G    H
    / \   / \  / \   / \
   I   J K  L  M  N O   P

In above case, if we're dropping root 301, btrfs_drop_snapshot() will
only drop one ref for tree block C and D.

But for qgroup, tree blocks E~P also have their owner changed, from
300, 301 to 300 only.

Currently we use btrfs_qgroup_trace_subtree() to manually re-dirty tree
block E~P. And since such ref change happens in one transaction for each
ref drop, we can't split the overhead to different transactions.

This could cause qgroup extent record flood, hugely damage performance
or even cause OOM for too many qgroup extent records.


Unfortunately unlike previous qgroup + balance optimization, we can't
really do much to help.
So to make the problem less obvious, let's just pause qgroup and resume
it for snapshot drop, and queue a rescan automatically.

For independent subvolume or small snapshot, we don't really need to do
such pause/rescan workaround, as regular per-tree-block dropping is
pretty qgroup friendly.

Qu Wenruo (3):
  btrfs: Refactor btrfs_clean_one_deleted_snapshot() to use fs_info
    other than root
  btrfs: qgroup: Introduce quota pause infrastrucutre
  btrfs: Pause and resume qgroup for snapshot drop

 fs/btrfs/ctree.h       |  3 +-
 fs/btrfs/disk-io.c     |  9 ++---
 fs/btrfs/extent-tree.c | 13 ++++++-
 fs/btrfs/qgroup.c      | 79 ++++++++++++++++++++++++++++++++++++++++--
 fs/btrfs/qgroup.h      |  3 ++
 fs/btrfs/relocation.c  |  4 +--
 fs/btrfs/transaction.c |  8 ++---
 fs/btrfs/transaction.h |  2 +-
 8 files changed, 106 insertions(+), 15 deletions(-)

-- 
2.22.0


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

end of thread, other threads:[~2019-07-31 10:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-31 10:23 [PATCH RFC 0/3] btrfs: qgroup: Pause and resume qgroup for subvolume removal Qu Wenruo
2019-07-31 10:23 ` [PATCH RFC 1/3] btrfs: Refactor btrfs_clean_one_deleted_snapshot() to use fs_info other than root Qu Wenruo
2019-07-31 10:23 ` [PATCH RFC 2/3] btrfs: qgroup: Introduce quota pause infrastrucutre Qu Wenruo
2019-07-31 10:23 ` [PATCH RFC 3/3] btrfs: Pause and resume qgroup for snapshot drop Qu Wenruo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).