Linux-BTRFS Archive mirror
 help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: [PATCH 00/19] btrfs: delayed refs cleanups
Date: Sat, 13 Apr 2024 19:53:10 -0400	[thread overview]
Message-ID: <cover.1713052088.git.josef@toxicpanda.com> (raw)

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(-)

-- 
2.43.0


             reply	other threads:[~2024-04-13 23:53 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-13 23:53 Josef Bacik [this message]
2024-04-13 23:53 ` [PATCH 01/19] btrfs: add a helper to get the delayed ref node from the data/tree ref Josef Bacik
2024-04-15 12:37   ` Filipe Manana
2024-04-13 23:53 ` [PATCH 02/19] btrfs: embed data_ref and tree_ref in btrfs_delayed_ref_node Josef Bacik
2024-04-15 12:38   ` Filipe Manana
2024-04-13 23:53 ` [PATCH 03/19] btrfs: do not use a function to initialize btrfs_ref Josef Bacik
2024-04-15 12:40   ` Filipe Manana
2024-04-13 23:53 ` [PATCH 04/19] btrfs: move ref_root into btrfs_ref Josef Bacik
2024-04-15 12:40   ` Filipe Manana
2024-04-13 23:53 ` [PATCH 05/19] btrfs: pass btrfs_ref to init_delayed_ref_common Josef Bacik
2024-04-15 12:43   ` Filipe Manana
2024-04-13 23:53 ` [PATCH 06/19] btrfs: initialize btrfs_delayed_ref_head with btrfs_ref Josef Bacik
2024-04-15 12:44   ` Filipe Manana
2024-04-13 23:53 ` [PATCH 07/19] btrfs: move ref specific initialization into init_delayed_ref_common Josef Bacik
2024-04-15 12:44   ` Filipe Manana
2024-04-13 23:53 ` [PATCH 08/19] btrfs: simplify delayed ref tracepoints Josef Bacik
2024-04-15 12:45   ` Filipe Manana
2024-04-13 23:53 ` [PATCH 09/19] btrfs: unify the btrfs_add_delayed_*_ref helpers into one helper Josef Bacik
2024-04-15 12:48   ` Filipe Manana
2024-04-13 23:53 ` [PATCH 10/19] btrfs: rename ->len to ->num_bytes in btrfs_ref Josef Bacik
2024-04-15 12:49   ` Filipe Manana
2024-04-13 23:53 ` [PATCH 11/19] btrfs: move ->parent and ->ref_root into btrfs_delayed_ref_node Josef Bacik
2024-04-15 12:56   ` Filipe Manana
2024-04-13 23:53 ` [PATCH 12/19] btrfs: rename btrfs_data_ref->ino to ->objectid Josef Bacik
2024-04-15 12:57   ` Filipe Manana
2024-04-13 23:53 ` [PATCH 13/19] btrfs: make __btrfs_inc_extent_ref take a btrfs_delayed_ref_node Josef Bacik
2024-04-15 13:00   ` Filipe Manana
2024-04-13 23:53 ` [PATCH 14/19] btrfs: drop unnecessary arguments from __btrfs_free_extent Josef Bacik
2024-04-15 13:00   ` Filipe Manana
2024-04-13 23:53 ` [PATCH 15/19] btrfs: make the insert backref helpers take a btrfs_delayed_ref_node Josef Bacik
2024-04-15 13:01   ` Filipe Manana
2024-04-13 23:53 ` [PATCH 16/19] btrfs: stop referencing btrfs_delayed_data_ref directly Josef Bacik
2024-04-15 13:04   ` Filipe Manana
2024-04-13 23:53 ` [PATCH 17/19] btrfs: stop referencing btrfs_delayed_tree_ref directly Josef Bacik
2024-04-15 13:05   ` Filipe Manana
2024-04-13 23:53 ` [PATCH 18/19] btrfs: remove the btrfs_delayed_ref_node container helpers Josef Bacik
2024-04-15 13:06   ` Filipe Manana
2024-04-13 23:53 ` [PATCH 19/19] btrfs: replace btrfs_delayed_*_ref with btrfs_*_ref Josef Bacik
2024-04-15 13:11   ` Filipe Manana

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.1713052088.git.josef@toxicpanda.com \
    --to=josef@toxicpanda.com \
    --cc=kernel-team@fb.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 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 read-only IMAP folder(s) and NNTP newsgroup(s).