From 471ee988c0d0390727c01801835e15599d84208c Mon Sep 17 00:00:00 2001 From: David Sterba Date: Thu, 25 Jun 2020 17:18:24 +0200 Subject: [PATCH] btrfs: lift start and end parameters to callers of insert_state Let callers of insert_state to set up the extent state to allow further simplifications of the parameters. Signed-off-by: David Sterba --- fs/btrfs/extent_io.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 5e0d5a6ae6e6f..5b67e899f05a9 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -524,21 +524,14 @@ static void set_state_bits(struct extent_io_tree *tree, * probably isn't what you want to call (see set/clear_extent_bit). */ static int insert_state(struct extent_io_tree *tree, - struct extent_state *state, u64 start, u64 end, + struct extent_state *state, struct rb_node ***node_in, struct rb_node **parent_in, u32 *bits, struct extent_changeset *changeset) { struct rb_node **node; struct rb_node *parent; - - if (end < start) { - btrfs_err(tree->fs_info, - "insert state: end < start %llu %llu", end, start); - WARN_ON(1); - } - state->start = start; - state->end = end; + const u64 end = state->end; set_state_bits(tree, state, bits, changeset); @@ -563,7 +556,7 @@ static int insert_state(struct extent_io_tree *tree, } else { btrfs_err(tree->fs_info, "found node %llu %llu on insert of %llu %llu", - entry->start, entry->end, start, end); + entry->start, entry->end, state->start, end); return -EEXIST; } } @@ -1027,8 +1020,9 @@ again: if (!node) { prealloc = alloc_extent_state_atomic(prealloc); BUG_ON(!prealloc); - err = insert_state(tree, prealloc, start, end, - &p, &parent, &bits, changeset); + prealloc->start = start; + prealloc->end = end; + err = insert_state(tree, prealloc, &p, &parent, &bits, changeset); if (err) extent_io_tree_panic(tree, err); @@ -1144,8 +1138,9 @@ hit_next: * Avoid to free 'prealloc' if it can be merged with * the later extent. */ - err = insert_state(tree, prealloc, start, this_end, - NULL, NULL, &bits, changeset); + prealloc->start = start; + prealloc->end = this_end; + err = insert_state(tree, prealloc, NULL, NULL, &bits, changeset); if (err) extent_io_tree_panic(tree, err); @@ -1268,8 +1263,9 @@ again: err = -ENOMEM; goto out; } - err = insert_state(tree, prealloc, start, end, - &p, &parent, &bits, NULL); + prealloc->start = start; + prealloc->end = end; + err = insert_state(tree, prealloc, &p, &parent, &bits, NULL); if (err) extent_io_tree_panic(tree, err); cache_state(prealloc, cached_state); @@ -1366,8 +1362,9 @@ hit_next: * Avoid to free 'prealloc' if it can be merged with * the later extent. */ - err = insert_state(tree, prealloc, start, this_end, - NULL, NULL, &bits, NULL); + prealloc->start = start; + prealloc->end = this_end; + err = insert_state(tree, prealloc, NULL, NULL, &bits, NULL); if (err) extent_io_tree_panic(tree, err); cache_state(prealloc, cached_state); -- 2.39.5