summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2020-06-25 18:11:31 +0200
committerDavid Sterba <dsterba@suse.com>2022-07-25 17:45:35 +0200
commitfb8f07d2d8e80738d5c6094e332950bfd0842b7a (patch)
treea1a7f1d81447cb8f343eaa35859e72f8eb5d5e32
parent6d92b304ec6b929f9aa87ae96488daf180d07585 (diff)
downloadlinux-fb8f07d2d8e80738d5c6094e332950bfd0842b7a.tar.bz2
btrfs: add fast path for extent_state insertion
In two cases the exact location where to insert the extent state is known at the call time so we don't need to pass it to insert_state that takes the fast path. Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--fs/btrfs/extent_io.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 20ba7c272e2d..937c8eafe861 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -570,6 +570,20 @@ insert_new:
}
/*
+ * Insert state to @tree to the location given by @node and @parent.
+ */
+static void insert_state_fast(struct extent_io_tree *tree,
+ struct extent_state *state, struct rb_node **node,
+ struct rb_node *parent, unsigned bits,
+ struct extent_changeset *changeset)
+{
+ set_state_bits(tree, state, bits, changeset);
+ rb_link_node(&state->rb_node, parent, node);
+ rb_insert_color(&state->rb_node, &tree->state);
+ merge_state(tree, state);
+}
+
+/*
* split a given extent state struct in two, inserting the preallocated
* struct 'prealloc' as the newly created second half. 'split' indicates an
* offset inside 'orig' where it should be split.
@@ -1021,10 +1035,7 @@ again:
BUG_ON(!prealloc);
prealloc->start = start;
prealloc->end = end;
- err = insert_state(tree, prealloc, &p, &parent, bits, changeset);
- if (err)
- extent_io_tree_panic(tree, err);
-
+ insert_state_fast(tree, prealloc, p, parent, bits, changeset);
cache_state(prealloc, cached_state);
prealloc = NULL;
goto out;
@@ -1264,9 +1275,7 @@ again:
}
prealloc->start = start;
prealloc->end = end;
- err = insert_state(tree, prealloc, &p, &parent, bits, NULL);
- if (err)
- extent_io_tree_panic(tree, err);
+ insert_state_fast(tree, prealloc, p, parent, bits, NULL);
cache_state(prealloc, cached_state);
prealloc = NULL;
goto out;