]> git.baikalelectronics.ru Git - kernel.git/commitdiff
btrfs: lift start and end parameters to callers of insert_state
authorDavid Sterba <dsterba@suse.com>
Thu, 25 Jun 2020 15:18:24 +0000 (17:18 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 25 Jul 2022 15:45:35 +0000 (17:45 +0200)
Let callers of insert_state to set up the extent state to allow further
simplifications of the parameters.

Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent_io.c

index 5e0d5a6ae6e6f93ddef8a36f4e0a329580f84e4a..5b67e899f05a9d4b023f3b533cd6fdb5b776176b 100644 (file)
@@ -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);