Message ID | 85ad4b193c5c4dcc803449feff008f06bd61808f.1654706034.git.dsterba@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Extent tree search cleanups | expand |
On 8.06.22 г. 19:43 ч., David Sterba wrote: > 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> > --- > fs/btrfs/extent_io.c | 24 +++++++++++++++++------- > 1 file changed, 17 insertions(+), 7 deletions(-) > > diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c > index 9b1dfe4363c9..00a6a2d0b112 100644 > --- a/fs/btrfs/extent_io.c > +++ b/fs/btrfs/extent_io.c > @@ -569,6 +569,21 @@ static int insert_state(struct extent_io_tree *tree, > return 0; > } > > +/* > + * Insert state to the tree to a location given by @p_ that @p_ seems incomplete? <snip>
On Wed, Jun 15, 2022 at 05:19:31PM +0300, Nikolay Borisov wrote: > > > On 8.06.22 г. 19:43 ч., David Sterba wrote: > > 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> > > --- > > fs/btrfs/extent_io.c | 24 +++++++++++++++++------- > > 1 file changed, 17 insertions(+), 7 deletions(-) > > > > diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c > > index 9b1dfe4363c9..00a6a2d0b112 100644 > > --- a/fs/btrfs/extent_io.c > > +++ b/fs/btrfs/extent_io.c > > @@ -569,6 +569,21 @@ static int insert_state(struct extent_io_tree *tree, > > return 0; > > } > > > > +/* > > + * Insert state to the tree to a location given by @p_ > > that @p_ seems incomplete? That's a typo and the variable got renamed to 'node', fixed.
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 9b1dfe4363c9..00a6a2d0b112 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -569,6 +569,21 @@ static int insert_state(struct extent_io_tree *tree, return 0; } +/* + * Insert state to the tree to a location given by @p_ + */ +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 @@ -1021,10 +1036,7 @@ int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, u32 bits, 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 +1276,7 @@ int convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, } 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;
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> --- fs/btrfs/extent_io.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-)