mbox series

[00/19] btrfs: delayed refs cleanups

Message ID cover.1713052088.git.josef@toxicpanda.com (mailing list archive)
Headers show
Series btrfs: delayed refs cleanups | expand

Message

Josef Bacik April 13, 2024, 11:53 p.m. UTC
Hello,

While I was fixing the snapshot deletion corruption I noticed a lot of silly
duplication when it comes to delayed refs.  We have two things to refer to
references, and use different names for the same thing, anybody who doesn't know
what this code does would understandably be confused.

I reworked all of this to consolidate everything into btrfs_delayed_ref_node,
and got rid of the type specific wrapper structs.  I made the initialization of
the btrfs_ref for the actions clearer instead of a 6 argument initialization
function.  I used this simplification to reduce the duplicated code around
adding new delayed refs.  The result is a net removal of 130 lines of code, and
makes several of the call chains clearer as we just pass the
btrfs_delayed_ref_node around where we can.

I want to cleanup how we lookup delayed ref heads and how we handle those cases,
but I'm much more cautious around that code because there's some guarantees
about parallel modifications that are maintained by the current status quo, and
I'm afraid cleaning that code up will result in subtle bugs.

These cleanups should be relatively safe as they have no behavior changes.  I've
run it through fstests to validate nothing broke.  Thanks,

Josef

Josef Bacik (19):
  btrfs: add a helper to get the delayed ref node from the data/tree ref
  btrfs: embed data_ref and tree_ref in btrfs_delayed_ref_node
  btrfs: do not use a function to initialize btrfs_ref
  btrfs: move ref_root into btrfs_ref
  btrfs: pass btrfs_ref to init_delayed_ref_common
  btrfs: initialize btrfs_delayed_ref_head with btrfs_ref
  btrfs: move ref specific initialization into init_delayed_ref_common
  btrfs: simplify delayed ref tracepoints
  btrfs: unify the btrfs_add_delayed_*_ref helpers into one helper
  btrfs: rename ->len to ->num_bytes in btrfs_ref
  btrfs: move ->parent and ->ref_root into btrfs_delayed_ref_node
  btrfs: rename btrfs_data_ref->ino to ->objectid
  btrfs: make __btrfs_inc_extent_ref take a btrfs_delayed_ref_node
  btrfs: drop unnecessary arguments from __btrfs_free_extent
  btrfs: make the insert backref helpers take a btrfs_delayed_ref_node
  btrfs: stop referencing btrfs_delayed_data_ref directly
  btrfs: stop referencing btrfs_delayed_tree_ref directly
  btrfs: remove the btrfs_delayed_ref_node container helpers
  btrfs: replace btrfs_delayed_*_ref with btrfs_*_ref

 fs/btrfs/backref.c           |  40 ++--
 fs/btrfs/delayed-ref.c       | 369 +++++++++++------------------------
 fs/btrfs/delayed-ref.h       | 148 +++++++-------
 fs/btrfs/extent-tree.c       | 273 ++++++++++++--------------
 fs/btrfs/file.c              |  79 ++++----
 fs/btrfs/inode-item.c        |  16 +-
 fs/btrfs/ref-verify.c        |   8 +-
 fs/btrfs/relocation.c        |  84 +++++---
 fs/btrfs/tree-log.c          |  17 +-
 include/trace/events/btrfs.h |  56 ++----
 10 files changed, 479 insertions(+), 611 deletions(-)