linux-btrfs.vger.kernel.org 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 5/9] btrfs: don't do backref modification for metadata for extent tree v2
Date: Wed, 15 Dec 2021 15:43:41 -0500	[thread overview]
Message-ID: <93e8cecd8b11b8eeee846d7a07ebd198c2730726.1639600854.git.josef@toxicpanda.com> (raw)
In-Reply-To: <cover.1639600854.git.josef@toxicpanda.com>

For extent tree v2 we will no longer track references for metadata in
the extent tree.  Make changes at the alloc and free sides so the proper
accounting is done but skip the extent tree modification parts.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/extent-tree.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 0c1988a7f845..369489394660 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -2957,7 +2957,6 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
 	struct btrfs_extent_item *ei;
 	struct btrfs_extent_inline_ref *iref;
 	int ret;
-	int is_data;
 	int extent_slot = 0;
 	int found_extent = 0;
 	int num_to_del = 1;
@@ -2966,6 +2965,11 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
 	u64 bytenr = node->bytenr;
 	u64 num_bytes = node->num_bytes;
 	bool skinny_metadata = btrfs_fs_incompat(info, SKINNY_METADATA);
+	bool is_data = owner_objectid >= BTRFS_FIRST_FREE_OBJECTID;
+
+	if (btrfs_fs_incompat(info, EXTENT_TREE_V2) && !is_data)
+		return do_free_extent_accounting(trans, bytenr, num_bytes,
+						 is_data);
 
 	extent_root = btrfs_extent_root(info, bytenr);
 	ASSERT(extent_root);
@@ -2974,8 +2978,6 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
 	if (!path)
 		return -ENOMEM;
 
-	is_data = owner_objectid >= BTRFS_FIRST_FREE_OBJECTID;
-
 	if (!is_data && refs_to_drop != 1) {
 		btrfs_crit(info,
 "invalid refs_to_drop, dropping more than 1 refs for tree block %llu refs_to_drop %u",
@@ -4706,6 +4708,9 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,
 	u64 flags = extent_op->flags_to_set;
 	bool skinny_metadata = btrfs_fs_incompat(fs_info, SKINNY_METADATA);
 
+	if (btrfs_fs_incompat(fs_info, EXTENT_TREE_V2))
+		goto out;
+
 	ref = btrfs_delayed_node_to_tree_ref(node);
 
 	extent_key.objectid = node->bytenr;
@@ -4759,7 +4764,7 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,
 
 	btrfs_mark_buffer_dirty(leaf);
 	btrfs_free_path(path);
-
+out:
 	return alloc_reserved_extent(trans, node->bytenr, fs_info->nodesize);
 }
 
-- 
2.26.3


  parent reply	other threads:[~2021-12-15 20:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-15 20:43 [PATCH 0/9] btrfs: extent-tree-v2, gc and no meta ref counting Josef Bacik
2021-12-15 20:43 ` [PATCH 1/9] btrfs: remove BUG_ON(ret) in alloc_reserved_tree_block Josef Bacik
2021-12-15 20:43 ` [PATCH 2/9] btrfs: add a alloc_reserved_extent helper Josef Bacik
2021-12-15 20:43 ` [PATCH 3/9] btrfs: remove `last_ref` from the extent freeing code Josef Bacik
2021-12-15 20:43 ` [PATCH 4/9] btrfs: add a do_free_extent_accounting helper Josef Bacik
2021-12-15 20:43 ` Josef Bacik [this message]
2021-12-15 20:43 ` [PATCH 6/9] btrfs: add definitions and read support for the garbage collection tree Josef Bacik
2021-12-15 20:43 ` [PATCH 7/9] btrfs: add a btrfs_first_item helper Josef Bacik
2021-12-15 20:43 ` [PATCH 8/9] btrfs: turn evict_refill_and_join into a real helper Josef Bacik
2021-12-15 20:43 ` [PATCH 9/9] btrfs: add garbage collection tree support Josef Bacik

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=93e8cecd8b11b8eeee846d7a07ebd198c2730726.1639600854.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 NNTP newsgroup(s).